Page 2 of 3

Re: -godly all command on teve map

Posted: November 30th, 2011, 9:23 am
by naturesfury
and who the heck is "GetTriggerUnit()" is there a unit specified? O.o

Re: -godly all command on teve map

Posted: November 30th, 2011, 9:41 am
by haxorico
true, I missed that part. the GetTriggerUnit would have worked if it was a unit-event of any-kind. What you are looking for is probably a GetEnumUnit() which is the unit you picked, although for that to work there is a need a in a loop IIRC...

Re: -godly all command on teve map

Posted: November 30th, 2011, 10:01 pm
by Durge
Could you model what JJ did for his CP?

Spoiler:
local group godgroup=CreateGroup()
local unit godman
loop
set godman=FirstOfGroup(godgroup)
exitwhen godman==null
blah blah blah
blah blah
endloop

Re: -godly all command on teve map

Posted: November 30th, 2011, 10:10 pm
by haxorico
if I remember correctly, it takes the group of units you chose (like if you drag a box around 12 units...)
And it uses the command for the First unit of the group, and after it is done, it loops again and does the same to the 2nd, and again to the 3rd etc... So if you get 12 heroes picked and write -agi 1000, they will all have 1000 agility.

Re: -godly all command on teve map

Posted: November 30th, 2011, 10:22 pm
by Durge
Was the code I posted correct? Cause I just tried it in-game and still would not spawn :-/

Re: -godly all command on teve map

Posted: November 30th, 2011, 11:37 pm
by naturesfury
no o.o you didn't define the group...you just created it...
like the repick system, just use the hero var in the save system
or...even easier, just spawn it on the selected hero?

Re: -godly all command on teve map

Posted: December 1st, 2011, 12:42 am
by haxorico
Here is an example code.
Spoiler:

Code: Select all

globals
trigger trgChat=CreateTrigger()
endglobals

function ChatCommands takes nothing returns nothing
local string str=StringCase(GetEventPlayerChatString(),false)
local group grp=CreateGroup()
local unit unt
if str=="-test"then
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Test worked")
endif
call GroupEnumUnitsSelected(grp,GetTriggerPlayer(),null)
loop
set unt=FirstOfGroup(grp)
exitwhen unt==null
if str=="-kill"then
call KillUnit(unt)
endif
call RemoveLocation(GetUnitLoc(unt))
call GroupRemoveUnit(grp,unt)
endloop
call DestroyGroup(grp)
set str=""
set grp=null
set unt=null
endfunction

function main takes nothing returns nothing
local integer looper=0
loop
exitwhen looper>11
call TriggerRegisterPlayerChatEvent(trgChat,Player(looper),"-",false)
set looper=looper+1
endloop
call TriggerAddAction(trgChat,function ChatCommands)
endfunction
didnt test tho.

Re: -godly all command on teve map

Posted: December 1st, 2011, 1:39 am
by Durge
Wonderful, it worked perfectly haxorico, your 100% pure genius. Thank you everyone who posted here for their feedback and help.

EDIT:Hmm, moving the part that goes into function main into a different call (cause there were some problems with it being in function main) made my -repick command to stop working. I figured it was just string overwrite, so I changed the strings for my godly command, but that didnt seem to help at all, any ideas?

Re: -godly all command on teve map

Posted: December 1st, 2011, 2:43 am
by naturesfury
this would be so much easier if you gave us the map but.......

make sure it was actually called?
maybe put a DisplayTextToPlayer() to see if it happened
if not, make it happen...

make sure variable/function names are correct

make sure you actually selected the unit before typing w.e you typed

if you used substrings, make sure end/start # are right

Re: -godly all command on teve map

Posted: December 1st, 2011, 2:52 am
by Durge
EDIT: Nevermind, I fixed it, thanks for the ideas nature.