[JASS] Multiple functions

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

[JASS] Multiple functions

Post by haxorico »

well i got my PURE GUI JEW PACK.
but as the title says its PURE GUI.

now i wanna turn it into jass since i know some stuff now.
but the stuff i know about jass is only from converting from GUI to JASS, so i got my self into some kind of a mess =\

here is a command i have for example
Spoiler:
function Trig_JEW_LUMBER_Conditions takes nothing returns boolean
return(IsPlayerInForce(GetTriggerPlayer(),udg_jews_group))
endfunction
function Trig_JEW_LUMBER_Actions takes nothing returns nothing
call AdjustPlayerStateBJ(S2I(SubStringBJ(GetEventPlayerChatString(),8,22)),GetTriggerPlayer(),PLAYER_STATE_RESOURCE_LUMBER)
endfunction
function InitTrig_JEW_LUMBER takes nothing returns nothing
local integer jew_integer=0
set gg_trg_JEW_LUMBER=CreateTrigger()
loop
exitwhen jew_integer>11
call TriggerRegisterPlayerChatEvent(gg_trg_JEW_LUMBER,Player(jew_integer),"-lumber",false)
set jew_integer=jew_integer+1
endloop
call TriggerAddCondition(gg_trg_JEW_LUMBER,Condition(function Trig_JEW_LUMBER_Conditions))
call TriggerAddAction(gg_trg_JEW_LUMBER,function Trig_JEW_LUMBER_Actions)
endfunction

now thats the GUI. (with jass loop) but i saw i can save some space making it like this
Spoiler:
function InitTrig_JEW_LUMBER takes nothing returns boolean
local integer jew_integer=0
set gg_trg_JEW_LUMBER=CreateTrigger()
loop
exitwhen jew_integer>11
call TriggerRegisterPlayerChatEvent(gg_trg_JEW_LUMBER,Player(jew_integer),"-lumber",false)
set jew_integer=jew_integer+1
endloop
call AdjustPlayerStateBJ(S2I(SubStringBJ(GetEventPlayerChatString(),8,22)),GetTriggerPlayer(),PLAYER_STATE_RESOURCE_LUMBER)
return(IsPlayerInForce(GetTriggerPlayer(),udg_jews_group))
endfunction
so i thought. yeah it looks better. i went to look at some othe jass CP's like JJ's and Fai's and i saw smthing diffrent.
they dont have a function for each command. they got like 1 function with all the commands.
here is a small example form JJ's
Spoiler:
if SubString(s2s,0,6)=="-gold "then
call SetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD)+S2I(SubString(s2s,6,13)))
elseif SubString(s2s,0,7)=="-lumber"then
call SetPlayerState(p2p,PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(p2p,PLAYER_STATE_RESOURCE_LUMBER)+S2I(SubString(s2s,8,15)))
elseif SubString(s2s,0,5)=="-mana"then
call CDandMana(p2p,true,"-nomana")
elseif SubString(s2s,0,5)=="-nocd"then
call CDandMana(p2p,false,"-cdon")
elseif SubString(s2s,0,9)=="-showkeys"then
so how can i make all my commands like that? in just 2lines and not 10?
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
UndeadxAssassin
Grammar King
Posts: 2115
Joined: June 22nd, 2008, 10:11 pm
Title: Worst human for 4eva
Location: Mostly USEast

Re: [JASS] Multiple functions

Post by UndeadxAssassin »

From what I see (remember that I've never learned a thing about JASS in my life...) in his cheatpack he has a

call TriggerRegisterPlayerChatEvent(CHEATS,p2p,"-",false)

which, obviously, searches for when someone says something with a - in it. Then he states if the text typed was [code] (-gold, for example) he would then write the steps it should take to carry out said code.
(In this case, call SetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD)+S2I(SubString(s2s,6,13))) which obviously adds the amount of gold.)

Then there's an "elseif" for when the code isn't -gold but something else.
It's basically an if-then function thing. When all the possible codes are done, there's an
endif
there to say that there's no more possibilities.

Hope this helped a bit :D (and hope I wasn't dead wrong =S)
(20:53:52) Bartimaeus: Thank you, Jen.
(20:53:56) Bartimaeus: Truly, you are wise.


(23:44:12) Bartimaeus: I was in pubic school until middle school...


Learn how to extract and read RAW Codes here!

Need help? Click here and ask your question!
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: [JASS] Multiple functions

Post by haxorico »

UndeadxAssassin wrote:From what I see (remember that I've never learned a thing about JASS in my life...) in his cheatpack he has a

call TriggerRegisterPlayerChatEvent(CHEATS,p2p,"-",false)

which, obviously, searches for when someone says something with a - in it. Then he states if the text typed was [code] (-gold, for example) he would then write the steps it should take to carry out said code.
(In this case, call SetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p2p,PLAYER_STATE_RESOURCE_GOLD)+S2I(SubString(s2s,6,13))) which obviously adds the amount of gold.)

Then there's an "elseif" for when the code isn't -gold but something else.
It's basically an if-then function thing. When all the possible codes are done, there's an
endif
there to say that there's no more possibilities.

Hope this helped a bit :D (and hope I wasn't dead wrong =S)

amm ur kinda wrong :D in JJ's CP all commands start with "-" even the activator.
out of what i understood. it makes sure it will start with it. or have it somewhere in the commands.
in anyhow.

how can he make 1 line only for what takes for me like 3?
i have the command. like -gold
make sure that the triggering player is inside jews_group
and the action itself that gives gold

wierd :<
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?