wc3edit.net https://forum.wc3edit.net/ |
|
[ask]'help' costume command for itemID SetItemCharges http://forum.wc3edit.net/deprotection-cheating-f64/help-costume-command-for-itemid-setitemcharges-t37309.html |
Page 1 of 1 |
Author: | EMT [ April 17th, 2020, 7:49 am ] |
Post subject: | [ask]'help' costume command for itemID SetItemCharges |
I tried with logic, but it still can't, can you tell me what's missing from the command that I made? Code: function beta_test takes nothing returns nothing local player beta_trigger = GetTriggerPlayer() local string beta_chat = GetEventPlayerChatString() local string beta_cmd = SubString(src,0,6) local unit beta_unit if(beta_cmd == "-item ")then call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99) endif endfunction function beta_item_init takes nothing returns nothing local trigger t = CreateTrigger() local integer i = 0 loop exitwhen i > 24 call TriggerRegisterPlayerChatEvent(t, Player(i), "-item ", false) set i = i + 1 endloop call TriggerAddAction(t, function beta_test) set t = null endfunction function main takes nothing returns nothing call beta_item_init() endfunction other test command Code: function beta_test takes nothing returns nothing local player beta_trigger = GetTriggerPlayer() local string beta_chat = GetEventPlayerChatString() local string beta_cmd = SubString(src,0,6) local unit beta_unit if(beta_cmd == "-item ")then call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99) endif endfunction function main takes nothing returns nothing call beta_test() endfunction other test #2 Code: function beta_test takes nothing returns nothing local player beta_trigger = GetTriggerPlayer() local string beta_chat = GetEventPlayerChatString() local string beta_cmd = SubString(src,0,6) local unit beta_unit if(beta_cmd == "-item ")then call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99) endif set beta_trigger=null set beta_chat=null set beta_cmd=null set betaunit=null endfunction function beta_item_init takes nothing returns nothing local trigger t = CreateTrigger() local integer i = 0 loop exitwhen i > 24 call TriggerRegisterPlayerChatEvent(t, Player(i), "-item ", false) set i = i + 1 endloop call TriggerAddAction(t, function beta_test) set t = null endfunction function main takes nothing returns nothing call beta_item_init() endfunction Sorry if I asked a lot, oot from the forum rules, if possible please rewrite this script so that I can understand, thank you. My respect to the forum wc3edit.net forum. Sorry if my posts double posts / triple posts, if my posts violate the rules tell me and delete my posts, if possible don't ban me T ^ T. thank you. |
Author: | nuzamacuxe [ April 17th, 2020, 8:39 am ] |
Post subject: | Re: [ask]'help' costume command for itemID SetItemCharges |
You definitely don't know what you are doing. lol. That will never work because there's no unit and the way you used TriggerRegisterPlayerChatEvent is totally wrong. Just copy and paste it: globals Code: unit CC_Unit = null group CC_Group = CreateGroup( ) endglobals Code: function ChatEvent takes trigger Trig, string Text, boolean Bool, code Act returns trigger local integer index = 0 loop call TriggerRegisterPlayerChatEvent( Trig, Player( index ), Text, Bool ) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop if Act != null then call TriggerAddAction( Trig, Act ) endif return Trig endfunction function FindEmptyString takes integer Begin, string Text returns integer local integer i = Begin loop if SubString( Text, i, i + 1 ) == " " then return i endif exitwhen i == StringLength( Text ) set i = i + 1 endloop return StringLength( Text ) endfunction function SelectedUnit takes player target returns unit set CC_Unit = null call GroupEnumUnitsSelected( CC_Group, target, null ) set CC_Unit = FirstOfGroup( CC_Group ) call GroupClear( CC_Group ) return CC_Unit endfunction function CommandsHandler takes nothing returns nothing local integer pid = GetPlayerId( GetTriggerPlayer( ) ) local string text = SubString( GetEventPlayerChatString( ), 1, StringLength( GetEventPlayerChatString( ) ) ) local integer emptyat = FindEmptyString( 0, text ) local string command = StringCase( SubString( text, 0, emptyat ), false ) call SelectedUnit( Player( pid ) ) if command == "item" then call SetItemCharges( UnitAddItemByIdSwapped (ID GOES HERE, CHANGE! DON'T FORGET TO USE APOSTROPHE ( Example: 'itemid' ), CC_Unit), 99 ) endif endfunction function CCommands_Init takes nothing returns nothing call ChatEvent( CreateTrigger( ), "-", false, function CommandsHandler ) endfunction function main Code: call CCommands_Init( ) Simple and clean. There's a way to make it without globals, but whatever. Just use that way for now. |
Author: | EMT [ April 17th, 2020, 9:59 am ] |
Post subject: | Re: [ask]'help' costume command for itemID SetItemCharges |
nuzamacuxe wrote: You definitely don't know what you are doing. lol. That will never work because there's no unit and the way you used TriggerRegisterPlayerChatEvent is totally wrong. ... Simple and clean. There's a way to make it without globals, but whatever. Just use that way for now. I tried to follow this page: http://forum.wc3edit.net/fulfilled-requ ... 37306.html in this code I use logic = owner123 wrote: There's no point requesting a single command btw, it's easier to just add a full cheatpack. But I actually love writing code so I made a custom command anyways. Type -gold x to receive x gold (i.e. -gold 100 gives you 100 gold) This is the code for the command. Simple & short. Spoiler:
thank you nuzamacuxe, i will try to make and understand what you give ^^. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |