iraciz Posted June 15, 2022 Group: Members Topic Count: 140 Topics Per Day: 0.03 Content Count: 562 Reputation: 111 Joined: 10/05/12 Last Seen: February 12, 2024 Share Posted June 15, 2022 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. Oncommand only works with typing or talking to the NPC, but I want activate the script by using the item above. What can I do? Quote Link to comment Share on other sites More sharing options...
0 Tokei Posted June 16, 2022 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 721 Joined: 11/12/12 Last Seen: 6 hours ago Share Posted June 16, 2022 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. Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted June 17, 2022 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Yesterday at 05:32 PM Share Posted June 17, 2022 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. 1 Quote Link to comment Share on other sites More sharing options...
0 Tokei Posted June 18, 2022 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 721 Joined: 11/12/12 Last Seen: 6 hours ago Share Posted June 18, 2022 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. Quote Link to comment Share on other sites More sharing options...
Question
iraciz
Good day,please help me! Bindatcommands are not working in the item scripts.
TXT Example:
@bonus is a custom npc bind atcommand that I use to apply random options to the gear.
Oncommand only works with typing or talking to the NPC, but I want activate the script by using the item above.
What can I do?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.