Jump to content
  • 0

Temporary Variable in bindatcmd


Question

Posted

This is out of my ability :P 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;
}

2 answers to this question

Recommended Posts

Posted

actually...you can use this..

.@atcmd_parameters$[0]

with this...then you dont need to modify your script command....

set #pass$,.@atcmd_parameters$[0];

type @lock <password>

and it will be your password....saved in the #pass$ variable

Posted

Oh damn! I mis-read this:

*useatcmd "command";
*useatcmd("command");
This command will execute a custom atcommand on the attached RID from a script.
Whether invoked by a script or command, an array .@atcmd_parameters$[] will be
filled with the given parameters, starting with an index of 0.
Example:
  @test Testing Command
The following array values will be generated:
  .@atcmd_parameters$[0] = "Testing"
  .@atcmd_parameters$[1] = "Command"

Thank you for reminding me @Emistry!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...