"create" block isn't running

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
When using this trigger "join" and "quit" work fine, but the "create" block is not.

JASS:
scope PartySystem initializer Init

globals
   private integer n
   private string array Teams
   private force array team[10]
endglobals

private struct InstanceData
   player player
   string message
   ExpString result
   string teamname
   string playername
endstruct

private function Actions takes nothing returns nothing
   local integer i = 0
   local integer e = 9
   local integer t = 0
   local InstanceData d = InstanceData.create()
   set d.player = GetTriggerPlayer()
   set d.message = GetEventPlayerChatString()
   set d.result = ExplodeString( d.message, " ", 3)
   set d.playername = GetPlayerName( d.player)
   if d.result[1] == "create" then
       call BJDebugMsg("bah")
       set n = n + 1
       set d.teamname = d.result[2]
       set Teams[n] = d.teamname
       call ForceAddPlayer( team[n], d.player)
       call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, d.playername + " has created the team named " + d.teamname + "!")
       loop
       exitwhen i > e
           if i == GetPlayerId( d.player) then
               set i = i + 1
           else
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_CONTROL, false)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_VISION, false)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_XP, false)
               set i = i + 1
           endif
        endloop
    elseif d.result[1] == "join" then
       set t = S2I(d.result[2])
       call ForceAddPlayer( team[t], d.player)
       call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, d.playername + " has joined the " + Teams[t] + "!")
       loop
       exitwhen i > e
           if Player(i) == d.player then
               set i = i + 1
           elseif IsPlayerInForce( Player(i), team[t]) then
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_CONTROL, true)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_VISION, true)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_XP, true)
           endif
       endloop
    elseif d.result[1] == "quit" then
       set t = S2I(d.result[2])
       call ForceAddPlayer( team[t], d.player)
       call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, d.playername + " has quit the " + Teams[t] + "!")
       loop
       exitwhen i > e
           if Player(i) == d.player then
               set i = i + 1
           else
               call ForceRemovePlayer( team[t], d.player)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_CONTROL, false)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_VISION, false)
               call SetPlayerAlliance( d.player, Player(i), ALLIANCE_SHARED_XP, false)
           endif
       endloop
    endif
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    local integer e = 9
    call TriggerAddAction( t, function Actions )
    loop
    exitwhen i > e
        call TriggerRegisterPlayerChatEvent( t, Player(i), "-team", false)
        set team<i> = CreateForce()
        set i = i + 1
    endloop
endfunction
endscope
</i>
 
Reaction score
341
Before I say anything, if you are running patch 1.23b S2I will cause your error.

And If your not, you'd better remove that, seeing as it won't work completely in the new patch.

Try adding a call BJDebugMsg(d.result) at the beginning to see if it's even "create".
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Forgot to say that the debug message does show, but not the second one. The other blocks work, but this one doesn't want to.
 
Reaction score
341
Forgot to say that the debug message does show, but not the second one. The other blocks work, but this one doesn't want to.

I count one message?

I meant for you to do something like;

JASS:
//
   local integer i = 0
   local integer e = 9
   local integer t = 0
   local InstanceData d = InstanceData.create()
   set d.player = GetTriggerPlayer()
   set d.message = GetEventPlayerChatString()
   set d.result = ExplodeString( d.message, &quot; &quot;, 3)
   set d.playername = GetPlayerName( d.player)
   call BJDebugMsg(d.result[1])
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Yes, I did that already and that worked, but the DisplayTextToForce isn't.
 

wraithseeker

Tired.
Reaction score
122
JASS:
set d.teamname = d.result[2]


Shouldn't it be

JASS:
set d.teamname = d.result


You create it and never initialize that d.result[2].
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I'm using Romek's Explode String it creates the array on d.result[].

Edit: I initialized it and it's displaying correctly, but I'll have to test multiplayer in a bit to see if it does work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top