JASS Simple Command

Status
Not open for further replies.
Level 6
Joined
Aug 1, 2009
Messages
159
How can I make a JASS function (not vJASS) command like, -gold x. Where x = the number of gold you want.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Why do you want to use JASS for that? You can do it by using the Trigger Editor. I don't know what you may have heard, but using JASS can actually be less efficient than using the Trigger Editor in certain cases (like cinematics).
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
GUI:
  • Untitled Trigger 065
    • Events
      • Player - Player 1 (Red) types a chat message containing -gold as A substring
      • Player - Player 2 (Blue) types a chat message containing -gold as A substring
      • Player - Player 3 (Teal) types a chat message containing -gold as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -gold
    • Actions
      • Set i1 = (Integer((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i1 Greater than 0
          • i1 Less than 100000
        • Then - Actions
          • Player - Add i1 to (Triggering player) Current gold
        • Else - Actions
JASS:
JASS:
function Add_Gold_Conditions takes nothing returns boolean
    return SubString(GetEventPlayerChatString(), 0, 6) == "-gold "
endfunction

function Add_Gold_Actions takes nothing returns nothing
    local integer i = S2I(SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString())))
    if i > 0 and i < 100000 then
        call SetPlayerState( GetTriggerPlayer() , PLAYER_STATE_RESOURCE_GOLD , GetPlayerState( GetTriggerPlayer() , PLAYER_STATE_RESOURCE_GOLD ) + i )
    endif
endfunction

function InitTrig_Add_Gold takes nothing returns nothing
    local trigger gg_trg_Add_Gold = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerChatEvent( gg_trg_Add_Gold, Player(i), "-gold ", false )
        exitwhen i == 11
        set i = i + 1
    endloop
    call TriggerAddCondition( gg_trg_Add_Gold, Condition( function Add_Gold_Conditions ) )
    call TriggerAddAction( gg_trg_Add_Gold, function Add_Gold_Actions )
endfunction
 
Level 12
Joined
May 21, 2009
Messages
994
Why do you want to use JASS for that? You can do it by using the Trigger Editor. I don't know what you may have heard, but using JASS can actually be less efficient than using the Trigger Editor in certain cases (like cinematics).

Lol you obviously don't know what GUI is made of. Of course you can make it less efficient if you are bad at coding Jass.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Lol you obviously don't know what GUI is made of. Of course you can make it less efficient if you are bad at coding Jass.

I will disregard your insult and explain my first post. I meant that implementing that in JASS requires extra effort than implementing it in GUI. When I'm saying "less efficient", I mean exactly that.
 
Status
Not open for further replies.
Top