Ok, just figure I'd start a new thread since it had no relevance to my other thread, since it was based solely on the repick system.
So I was wondering how do you know what to put in the SubString(<w/e>,<here>,<and here>).
Heres what I'm trying to do, I followed what you did for your repick command haxorico, maybe it's something completely different thats the problem, I'm not sure.
Spoiler:
function GodlyItem takes nothing returns nothing local string bum=StringCase(GetEventPlayerChatString(),false) if SubString(bum,7,10)=="all"then call UnitAddItemByIdSwapped('I02Z',GetTriggerUnit()) call UnitAddItemByIdSwapped('I047',GetTriggerUnit()) call UnitAddItemByIdSwapped('I046',GetTriggerUnit()) call UnitAddItemByIdSwapped('I04N',GetTriggerUnit()) call UnitAddItemByIdSwapped('I04O',GetTriggerUnit()) call UnitAddItemByIdSwapped('I04P',GetTriggerUnit()) call UnitAddItemByIdSwapped('I05H',GetTriggerUnit()) call UnitAddItemByIdSwapped('I05G',GetTriggerUnit()) call UnitAddItemByIdSwapped('I05F',GetTriggerUnit()) endif set bum="" endfunction
function main local integer godlooper=0 loop exitwhen godlooper>=1 call TriggerRegisterPlayerChatEvent(trgGodly,Player(godlooper),"-godly",false) call TriggerAddAction(trgGodly,function GodlyItem) set godlooper=godlooper+1 endloop
I didn't tested it if it would work so I don't recommend for you to use it. IIRC that's how JJ's CP handles strings.
Another questions pops out is. Why are you using SubStrings? If you're just gonna make a "-godly all" as a exact match. But if you still want to use substrings this could help you.
function main call TriggerAddAction(trgGodly,function GodlyItem)
Re: -godly all command on teve map
Posted: November 30th, 2011, 4:23 am
by Risugami
It doesn't work because you didn't have a condition. I am not in my computer right now so...
First of all, put call 'TriggerRegisterPlayerChatEvent(trgGodly,GetTriggerPlayer(),"-godly all",true)' into a new function or something that returns boolean so you'll make that as condition. So whenever it returns true it will call function GodlyItem. Which creates the items and such.
local trigger t = CreateTrigger() local integer i = 0 loop exitwhen i>11 call TriggerRegisterPlayerChatEvent( t, Player(i), "-godly all", true) set i = i+1 endloop call TriggerAddCondition(t, Condition(function GI_Conditions)) call TriggerAddAction(t, function GI_Actions)
It should work with all players but I didn't tested it really. But well it should work.
Re: -godly all command on teve map
Posted: November 30th, 2011, 5:13 am
by Kyoshiro
just a question. since when can units have more than 6 inv slots?
Re: -godly all command on teve map
Posted: November 30th, 2011, 5:53 am
by haxorico
wtf? Why are you guys making it so complicated?
Your code is good, I suspect you didn't use CreateTrigger() on globals but used null as its given by default. Here is the full code you need to have.
function GodlyItem takes nothing returns nothing local string bum=StringCase(GetEventPlayerChatString(),false) if SubString(bum,0,10)=="-godly all"then call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Success - The code detected the command") else call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"You wrote " + GetEventPlayerChatString() + " and not -godly all") endif set bum="" endfunction
function main takes nothing returns nothing local integer godlooper=0 loop exitwhen godlooper>=1 call TriggerRegisterPlayerChatEvent(trgGodly,Player(godlooper),"-",false) call TriggerAddAction(trgGodly,function GodlyItem) set godlooper=godlooper+1 endloop endfunction
Re: -godly all command on teve map
Posted: November 30th, 2011, 6:00 am
by Durge
Technically shouldn't this work also? Chattrigger is set as null in globals
I never tried spawning items etc, just never needed to. The question is. Is the structure okay? And no, the code above will not work and I will explain why.
This what happens in maps: The maps loading function main. Inside it, it is given event commands like RegisterPlayerChatEvent, meaning that everytime the Player mentioned in there is writing something, run a function. The player who used that specific event, is the TriggeringPlayer.
What you did, was as it initilizes, tell it to activate the event for the TriggeringPlayer, which is? No one ran any trigger so it doesnt know who to give the event to. That is why we use a loop to give it to all 12 players (0-11). Also, what is calling the function Chattrg?
And lastly, the way I wrote it, is so if you have more command strings, you can just place them inside, without making it all over again. I gave a structure and gave an example on how to use that structure.