[Jass]Help with this function idk where is my mistake

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
eddydu555
Senior Member
Posts: 123
Joined: August 27th, 2010, 7:14 am

[Jass]Help with this function idk where is my mistake

Post by eddydu555 »

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: Select all

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
User avatar
KangTooJee
Old Wrinkly Member
Posts: 202
Joined: September 15th, 2010, 5:09 am
Title: Legenda

Re: [Jass]Help with this function idk where is my mistake

Post by KangTooJee »

try put func JJXSKFUNC2 script above func JJXSKFUNC1
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: [Jass]Help with this function idk where is my mistake

Post by haxorico »

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.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
User avatar
eddydu555
Senior Member
Posts: 123
Joined: August 27th, 2010, 7:14 am

Re: [Jass]Help with this function idk where is my mistake

Post by eddydu555 »

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

Spoiler:

Code: Select all

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: Select all

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
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: [Jass]Help with this function idk where is my mistake

Post by haxorico »

Cant understand your question... What do you mean it takes space?
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
User avatar
eddydu555
Senior Member
Posts: 123
Joined: August 27th, 2010, 7:14 am

Re: [Jass]Help with this function idk where is my mistake

Post by eddydu555 »

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: Select all

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: Select all

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
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: [Jass]Help with this function idk where is my mistake

Post by haxorico »

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.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?