- Joined
- Nov 30, 2007
- Messages
- 1,202
JASS:
function DiplomacyMain takes nothing returns boolean
local string s = GetEventPlayerChatString()
local integer curWord = 1
local string word1 = ""
local string word2 = ""
local string word3 = ""
local string word4 = ""
local player p1 = GetTriggerPlayer()
local player p2
local integer i = 2
call DisplayTextToForce( GetPlayersAll(), "Working this far..." )
loop
exitwhen i > StringLength(s)
if (SubStringBJ(s,i,i) == " ") then
set curWord = curWord + 1
else
if (curWord == 1) then
set word1 = word1 + SubStringBJ(s, i, i)
elseif (curWord == 2) then
set word2 = word2 + SubStringBJ(s, i, i)
elseif (curWord == 3) then
set word3 = word3 + SubStringBJ(s, i, i)
elseif (curWord == 4) then
set word4 = word4 + SubStringBJ(s, i, i)
endif
endif
set i = i + 1
endloop
set p2 = Player(PlayerCommand(word2))
call DisplayTextToForce( GetPlayersAll(), "Word 1: " + word1 )
call DisplayTextToForce( GetPlayersAll(), "Word 2: " + word2 )
call DisplayTextToForce( GetPlayersAll(), "Word 3: " + word3 )
call DisplayTextToForce( GetPlayersAll(), "Word 4: " + word4 )
set p1 = null
set p2 = null
return false
endfunction
//===========================================================================
function InitTrig_Diplomacy_Commands takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(1), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(2), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(3), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(4), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(5), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(6), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(7), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(8), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(9), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(10), "-", false )
call TriggerRegisterPlayerChatEvent( t, Player(11), "-", false )
call TriggerAddCondition( t, Condition( function DiplomacyMain) )
set t = null
endfunction
Tried to make a trigger that retrieves 4 words from the entered string.
It works til the first word, when i try "-hi" but if i type "-hi ho" it crashes.
Oh I know what it was.... I think Player("ho") makes it crash xD