wc3edit.net
https://forum.wc3edit.net/

[Jass]Help with this function idk where is my mistake
http://forum.wc3edit.net/deprotection-cheating-f64/help-with-this-function-idk-where-is-my-mistake-t29118.html
Page 1 of 1

Author:  eddydu555 [ March 21st, 2014, 12:41 am ]
Post subject:  [Jass]Help with this function idk where is my mistake

Hello,I want to use the "-clickkill" to enable JJXSKFUNC1 which kills all units i select,but after using the code below i cant open the map,help me please i am not really good in Jass i just copied this from another cheat pack

Spoiler:
Code:
locals
trigger gg_trg_JJXSK=CreateTrigger()

under -gold command

elseif SubString(s2s,0,12)=="-clickill on"then
loop
call ExecuteFunc("JJXSKFUNC1")
endloop

[b]under endglobals[/b]
function JJXSKFUNC1 takes nothing returns nothing
call ResetTrigger(gg_trg_JJXSK)
call TriggerClearActions(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_JJXSK,GetTriggerPlayer(),true)
call TriggerAddAction(gg_trg_JJXSK,function JJXSKFUNC2)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
endfunction

function JJXSKFUNC2 takes nothing returns nothing
call KillUnit(GetTriggerUnit())
endfunction

Author:  KangTooJee [ March 21st, 2014, 5:10 pm ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

try put func JJXSKFUNC2 script above func JJXSKFUNC1

Author:  haxorico [ March 21st, 2014, 7:24 pm ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

If you cant oppen the map you have a syntax error.
Press F9 in jasscraft.
Also you need to paste the war3map.j file so we can see how to fix as you might have placed it in a bad place or used a bad variable name, there can be a lot of reason to make a code file not work.

Author:  eddydu555 [ March 22nd, 2014, 12:38 am ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

Thanks guys i made it work by putting JJXSKFUNC2 above JJXSKFUNC1 and removing loop & endloop
Thats the working code:

Spoiler:
Code:
under locals
trigger gg_trg_JJXSK=CreateTrigger()

under -gold command

elseif SubString(s2s,0,12)=="-clickill on"then
call ExecuteFunc("JJXSKFUNC1")


under endglobals
function JJXSKFUNC2 takes nothing returns nothing
call KillUnit(GetTriggerUnit())
endfunction
function JJXSKFUNC1 takes nothing returns nothing
call ResetTrigger(gg_trg_JJXSK)
call TriggerClearActions(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_JJXSK,GetTriggerPlayer(),true)
call TriggerAddAction(gg_trg_JJXSK,function JJXSKFUNC2)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
endfunction


But i have another question,I want to know what does take more space in the map between that working code above and this one below:

Spoiler:
Code:
under locals
trigger gg_trg_JJXSK=CreateTrigger()

under -gold command

elseif SubString(s2s,0,12)=="-clickill on"then
call ResetTrigger(gg_trg_JJXSK)
call TriggerClearActions(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_JJXSK,GetTriggerPlayer(),true)
call TriggerAddAction(gg_trg_JJXSK,function JJXSKFUNC)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)

under endglobals
function JJXSKFUNC takes nothing returns nothing
call KillUnit(GetTriggerUnit())
endfunction


I already made the code below before making the one above it but i wasnt sure if there is a difference in the taken space so thats my second question :D

Author:  haxorico [ March 22nd, 2014, 4:09 am ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

Cant understand your question... What do you mean it takes space?

Author:  eddydu555 [ March 22nd, 2014, 4:47 am ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

when you add stuff to a war3map.j you increase its size which increase the map's size

I did two codes which have the same result and i want to use the one which will make the war3map.j less bigger then possible :D


EDIT:after putting both codes in separated .j files and saving them i found out that the one with the command fused with JJXSKFUNC1 takes less space on the map than the one were the command calls for ExecuteFun"JJXSKFUNC1"

there is 98 bytes difference between the two files but it might be bigger if it was multiple codes,so now i just learned that making a command fused with a function like below...

Spoiler:
Code:
under locals
trigger gg_trg_JJXSK=CreateTrigger()

under -gold command

elseif SubString(s2s,0,12)=="-clickill on"then
call ExecuteFunc("JJXSKFUNC1")


under endglobals
function JJXSKFUNC2 takes nothing returns nothing
call KillUnit(GetTriggerUnit())
endfunction
function JJXSKFUNC1 takes nothing returns nothing
call ResetTrigger(gg_trg_JJXSK)
call TriggerClearActions(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_JJXSK,GetTriggerPlayer(),true)
call TriggerAddAction(gg_trg_JJXSK,function JJXSKFUNC2)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
endfunction


takes less place than making the command calls for the function like below

Spoiler:
Code:
under locals
trigger gg_trg_JJXSK=CreateTrigger()

under -gold command

elseif SubString(s2s,0,12)=="-clickill on"then
call ResetTrigger(gg_trg_JJXSK)
call TriggerClearActions(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_JJXSK,GetTriggerPlayer(),true)
call TriggerAddAction(gg_trg_JJXSK,function JJXSKFUNC)
call TriggerSleepAction(.02)
call EnableTrigger(gg_trg_JJXSK)
call TriggerSleepAction(.02)

under endglobals
function JJXSKFUNC takes nothing returns nothing
call KillUnit(GetTriggerUnit())
endfunction


Thanks for your help mates :D

Author:  haxorico [ March 22nd, 2014, 5:06 am ]
Post subject:  Re: [Jass]Help with this function idk where is my mistake

Of course deleting more lines of code will decrease its size, but code isn't always just about size. Most aspect of any code is to make sure any one can just read it and understand it. Seperating big codes to small functions is very common, and in fact needed.
But meh, won't matter. Less code = less space. But that won't mean more efficiency.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/