Jump to content
  • 0

Call binded atcommand on item script!


Question

Posted

Good day,please help me!  Bindatcommands are not working in the item scripts.

TXT Example:

40574,Moonlight Bell,Moonbell,11,0,,0,,,,,0xFFFFFFFF,63,2,,,,,,{ specialeffect2 549; soundeffectall "moonlight_move.wav",0; atcommand "@bonus"; },{},{}

 

@bonus is a custom npc bind atcommand that I use to apply random options to the gear.

sbuster2.png.fabc393851cd0aba191e6fe0e7c3ff93.png

Oncommand only works with typing or talking to the NPC, but I want activate the script by using the item above.

sbuster2.thumb.png.f3a5b217251b801782abef83991249a0.png

 

What can I do?

3 answers to this question

Recommended Posts

  • 0
Posted

Heya,

You should use a function instead for items calling script code. So your script would become:

function	script	F_AtBonus	{
	mes "Kitsune Fox Blessings";
	mes "...";
	next;
	
	switch(select("...")) {
		
	}
	
	end;
}

-	script	atcmd_bonus	-1,{
	end;
OnInit:
	bindatcmd "bonus", strnpcinfo(0) + "::OnCommand";
	end;
OnCommand:
	callfunc("F_AtBonus");
	end;
}

And your item script would be:

{ specialeffect2 549; soundeffectall "moonlight_move.wav",0; callfunc("F_AtBonus"); }

Alternatively, you can use doevent directly. So your code would be:

{ specialeffect2 549; soundeffectall "moonlight_move.wav",0; doevent "bonus_atcmd::OnCommand";}

Though... doevent is a tricky script command and usually isn't something I'd recommend using if you can avoid it. But, it will work in your case.

  • 0
Posted
On 6/16/2022 at 5:39 AM, iraciz said:

Bindatcommands are not working in the item scripts.

*useatcmd "<command>";

This command will execute a script-bound atcommand for the attached RID. If the
supplied command is not bound to any script, this command will act like 'atcommand'
and attempt to execute a source-defined command.

The three .@atcmd_***** variables will NOT be set when invoking script-bound atcommands
in this way.

 

  • Upvote 1
  • 0
Posted
On 6/17/2022 at 2:01 PM, Emistry said:
*useatcmd "<command>";

This command will execute a script-bound atcommand for the attached RID. If the
supplied command is not bound to any script, this command will act like 'atcommand'
and attempt to execute a source-defined command.

The three .@atcmd_***** variables will NOT be set when invoking script-bound atcommands
in this way.

 

Never knew this one existed, thank you Emistry! This is much simpler.

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...