This is out of my ability so I'd have to request support from here.
What I'm trying to do is let bindatcmd ability to attach a temp string variable to let use in script.
*bindatcmd "command","<NPC object name>::<event label>"{,<atcommand level>,<charcommand level>};
Hmmm... here is a simple dummy script how would it supposed to work.
- script dummy -1,{
OnInit:
bindatcmd "lock",".@pass$","dummy::onlock";
end;
onlock:
if (.@pass$ == "") { dispbottom "No password entered."; end; }
set #pass, .@pass$;
dispbottom "Account locked.";
}
Here is the block for bindatcmd:
BUILDIN_FUNC(bindatcmd) {
const char* atcmd;
const char* eventName;
int i, level = 0, level2 = 0;
bool create = false;
atcmd = script_getstr(st,2);
eventName = script_getstr(st,3);
if( *atcmd == atcommand_symbol || *atcmd == charcommand_symbol )
atcmd++;
if( script_hasdata(st,4) ) level = script_getnum(st,4);
if( script_hasdata(st,5) ) level2 = script_getnum(st,5);
if( atcmd_binding_count == 0 ) {
CREATE(atcmd_binding,struct atcmd_binding_data*,1);
create = true;
} else {
ARR_FIND(0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command,atcmd) == 0);
if( i < atcmd_binding_count ) {/* update existent entry */
safestrncpy(atcmd_binding[i]->npc_event, eventName, 50);
atcmd_binding[i]->level = level;
atcmd_binding[i]->level2 = level2;
} else
create = true;
}
if( create ) {
i = atcmd_binding_count;
if( atcmd_binding_count++ != 0 )
RECREATE(atcmd_binding,struct atcmd_binding_data*,atcmd_binding_count);
CREATE(atcmd_binding[i],struct atcmd_binding_data,1);
safestrncpy(atcmd_binding[i]->command, atcmd, 50);
safestrncpy(atcmd_binding[i]->npc_event, eventName, 50);
atcmd_binding[i]->level = level;
atcmd_binding[i]->level2 = level2;
}
return 0;
}