function GetPlayer takes string s returns player
if (s == "red" or s == udg_DIPS_Faction[0] or s == udg_DIPS_Name[0]) then
return Player(0)
elseif (s == "blue" or s == udg_DIPS_Faction[1] or s == udg_DIPS_Name[1]) then
return Player(1)
elseif (s == "teal" or s == udg_DIPS_Faction[2] or s == udg_DIPS_Name[2]) then
return Player(2)
elseif (s == "purple" or s == udg_DIPS_Faction[3] or s == udg_DIPS_Name[3]) then
return Player(3)
elseif (s == "yellow" or s == udg_DIPS_Faction[4] or s == udg_DIPS_Name[4]) then
return Player(4)
elseif (s == "orange" or s == udg_DIPS_Faction[5] or s == udg_DIPS_Name[5]) then
return Player(5)
elseif (s == "green" or s == udg_DIPS_Faction[6] or s == udg_DIPS_Name[6]) then
return Player(6)
elseif (s == "pink" or s == udg_DIPS_Faction[7] or s == udg_DIPS_Name[7]) then
return Player(7)
elseif (s == "gray" or s == "grey" or s == udg_DIPS_Faction[8] or s == udg_DIPS_Name[8]) then
return Player(8)
elseif (s == "light blue" or s == "lightblue" or s == "lb" or s == udg_DIPS_Faction[9] or s == udg_DIPS_Name[9]) then
return Player(9)
elseif (s == "dark green" or s == "darkgreen" or s == "dg" or s == udg_DIPS_Faction[10] or s == udg_DIPS_Name[10]) then
return Player(10)
elseif (s == "brown" or s == udg_DIPS_Faction[11] or s == udg_DIPS_Name[11]) then
return Player(11)
endif
return null
endfunction
function AllyCommand takes string s returns boolean
if (s == "-ally") then
return true
endif
return false
endfunction
function NeutralCommand takes string s returns boolean
if (s == "-neutral" or s == "-na" or s == "-peace") then
return true
endif
return false
endfunction
function WarCommand takes string s returns boolean
if (s == "-war" or s == "-unally") then
return true
endif
return false
endfunction
// How?
function GetSpacing takes string s returns integer
local integer i = 0
loop
if (1 == 1) then
return i
endif
exitwhen i == StringLength(s)
endloop
return 0
endfunction
function Commands_Actions takes nothing returns boolean
local integer i = GetSpacing(GetEventPlayerChatString())
local string s1 = "First part of the substring 0-where the devide is."
local string s2 = "Second part of the subtring after the devide"
local player p = GetPlayer(s2)
local trigger t
if (p != null) then
if (AllyCommand(s1) == true) then
set t = gg_trg_Ally
set udg_DIPS_PlayerGiving = GetTriggerPlayer()
set udg_DIPS_PlayerRecieving = p
call ConditionalTriggerExecute(t)
elseif (NeutralCommand(s1) == true) then
set t = gg_trg_Neutral
set udg_DIPS_PlayerGiving = GetTriggerPlayer()
set udg_DIPS_PlayerRecieving = p
call ConditionalTriggerExecute(t)
elseif (WarCommand(s1) == true) then
set t = gg_trg_War
set udg_DIPS_PlayerGiving = GetTriggerPlayer()
set udg_DIPS_PlayerRecieving = p
call ConditionalTriggerExecute(t)
endif
endif
set t = null
set p = null
return false
endfunction
//===========================================================================
function InitTrig_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 Commands_Actions ))
set t = null
endfunction