- Joined
- Apr 23, 2011
- Messages
- 460
Currently, I have an issue with this system I'm coding. Apparently the Initialization for the trigger won't run, so I can't tell if the system is coded incorrectly.
EDIT: Updated code posted below as of 3/27/2012 : 4:10
EDIT: Updated code posted below as of 3/27/2012 : 4:10
JASS:
library CSV2 initializer Init
globals
string array COLOR
string array COLNUM
string array REALNAME
integer array PCOLOR
force PLAYFORCE
boolean ALLIES
boolean ALL
boolean PRIVATE
integer WHOPRIVATE
player SENDPLAYER
string MESSAGE
integer PLAYERCOUNT
endglobals
scope Start
function DoMapSetup takes nothing returns nothing
local integer i = 0
set COLOR[0] = "|c00ff0000"
set COLOR[1] = "|c000000ff"
set COLOR[2] = "|c0000ffff"
set COLOR[3] = "|c00660099"
set COLOR[4] = "|c00ffff00"
set COLOR[5] = "|c00ff6600"
set COLOR[6] = "|c00ff00ff"
set COLOR[8] = "|c0000ff00"
set COLOR[9] = "|c00666666"
set COLOR[10] = "|c009999ff"
set COLOR[11] = "|c00336600"
set COLOR[12] = "|c00000000"
set COLOR[13] = "|c00990000"
set COLOR[14] = "|c00999900"
set COLOR[15] = "|cffffffff"
//------------------------------------------------
set COLNUM[0] = "Red"
set COLNUM[1] = "Blue"
set COLNUM[2] = "Teal"
set COLNUM[3] = "Purple"
set COLNUM[4] = "Yellow"
set COLNUM[5] = "Orange"
set COLNUM[6] = "Pink"
set COLNUM[7] = "Lgreen"
set COLNUM[8] = "Gray"
set COLNUM[9] = "Lblue"
set COLNUM[10] = "Green"
set COLNUM[11] = "Brown"
set COLNUM[12] = "Black"
set COLNUM[13] = "Maroon"
set COLNUM[14] = "Gold"
set COLNUM[15] = "White"
endfunction
struct Text extends array
private static method DisplayTextAll takes nothing returns nothing
local player p = SENDPLAYER
local integer pnum = GetPlayerId( p )
local integer i = 0
local player recP
loop
set recP = Player( i )
if IsPlayerInForce( recP, PLAYFORCE ) == true then
call DisplayTextToPlayer( recP, 0, 0, ( "(All): " + COLOR[PCOLOR[pnum]] + GetPlayerName( p ) + ": " + MESSAGE + "|r" ) )
endif
set i = i + 1
exitwhen i > 11
endloop
set p = null
set recP = null
endmethod
private static method DisplayTextPrivate takes nothing returns nothing
local player p = SENDPLAYER
local integer pnum = GetPlayerId( p )
local player recP = Player( WHOPRIVATE )
call DisplayTextToPlayer( recP, 0, 0, ( "(Private): " + COLOR[PCOLOR[pnum]] + GetPlayerName( p ) + ": " + MESSAGE + "|r" ) )
set p = null
set recP = null
endmethod
private static method DisplayTextAllies takes nothing returns nothing
local player p = SENDPLAYER
local integer pnum = GetPlayerId( p )
local integer i = 0
local player recP
loop
set recP = Player( i )
if IsPlayerInForce( recP, PLAYFORCE ) == true and IsPlayerAlly( recP, p ) == true then
call DisplayTimedTextToPlayer( recP, 0, 0, 8.5, ( "(Allies): " + COLOR[PCOLOR[pnum]] + GetPlayerName( p ) + ": " + MESSAGE + "|r" ) )
endif
set i = i + 1
exitwhen i > 11
endloop
set p = null
set recP = null
endmethod
static method SendMessage takes nothing returns nothing
if ALLIES == true then
call thistype.DisplayTextAllies( )
set ALLIES = false
endif
if ALL == true then
call thistype.DisplayTextAll( )
set ALL = false
endif
if PRIVATE == true then
call thistype.DisplayTextPrivate( )
set PRIVATE = false
endif
endmethod
endstruct
endscope
private function ConvertText takes nothing returns nothing
local string origString = GetEventPlayerChatString( )
local string codeString = SubString( origString, 0, 3 )
local integer end = StringLength( origString )
local integer isAlly = 0
set SENDPLAYER = GetTriggerPlayer( )
if codeString == "-p " then
set PRIVATE = true
set WHOPRIVATE = S2I( SubString( origString, 3, 5 ) )
set MESSAGE = SubString( origString, 3, end )
return
else
set isAlly = isAlly + 1
endif
if codeString == "-al" then
set ALL = true
set MESSAGE = SubString ( origString, 3, end )
return
else
set isAlly = isAlly + 1
endif
if isAlly == 2 then
set ALLIES = true
endif
set MESSAGE = SubString( origString, 0, end )
call Text.SendMessage( )
set origString = null
set codeString = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
local player p
call DoMapSetup()
loop
if GetPlayerSlotState( Player( i ) ) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( Player( i ) ) == MAP_CONTROL_USER then
call TriggerRegisterPlayerChatEvent( t, Player(i), "", false)
endif
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction( t, function ConvertText )
set t = null
endfunction
endlibrary
scope FormForce initializer init
private function FormForce takes nothing returns nothing
local integer i = 0
local player p
loop
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
call ForceAddPlayer(PLAYFORCE, p)
endif
set i = i + 1
exitwhen i > 11
endloop
set p = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, .5, false)
call TriggerAddAction(t, function FormForce)
set t = null
endfunction
endscope
Last edited: