library LocalWeather initializer Init// v1.00 (Snippet)
/*---------------------------------------------------------------------------------------------------
by Dhguardianes:
day la LocalWeather!! chac ban choi dota se thay -weather moonlight v.v.. se co thay doi weather theo player
ban co the su dung -weather bao gom`
-weather off
-weather snow
-weather rain
-weather wind
-weather light
-weather random
-weather moonlight
---------------------------------------------------------------------------------------------------*/
globals
private constant integer Moon = 'LRma'
private constant integer Rain = 'RAlr'
private constant integer Snow = 'SNls'
private constant integer Light = 'LRaa'
private constant integer Wind = 'WNcw'
private constant string Info = "Thay doi thoi tiet bang cach go lenh -weather, ma lenh -weather duoc su dung truong hop sau day; off,random,rain,snow,moonlight,light,wind."
private constant integer array random
private weathereffect weather = null
private player TempPlayer
endglobals
//===========================================================================
//! textmacro LocalWeatherFunc takes thistype,code
if ( ( GetEventPlayerChatString() == "$thistype$" ) ) then
if GetLocalPlayer()==TempPlayer then
call RemoveWeatherEffect( weather )
set weather = AddWeatherEffect(bj_mapInitialPlayableArea, $code$)
call EnableWeatherEffect( weather, true )
endif
return
endif
//! endtextmacro
private function f takes nothing returns nothing
set TempPlayer = GetTriggerPlayer()
//! runtextmacro LocalWeatherFunc("-weather random","random[GetRandomInt(1, 5)]")
//! runtextmacro LocalWeatherFunc("-weather moonlight","Moon")
//! runtextmacro LocalWeatherFunc("-weather light","Light")
//! runtextmacro LocalWeatherFunc("-weather wind","Wind")
//! runtextmacro LocalWeatherFunc("-weather snow","Snow")
//! runtextmacro LocalWeatherFunc("-weather rain","Rain")
if ( ( GetEventPlayerChatString() == "-weather off" ) ) then
if GetLocalPlayer()==TempPlayer then
call RemoveWeatherEffect( weather )
endif
return
endif
if (not ( GetEventPlayerChatString() == "-weather random" ) or ( GetEventPlayerChatString() == "-weather off" ) or ( GetEventPlayerChatString() == "-weather moonlight" ) or ( GetEventPlayerChatString() == "-weather light" ) or ( GetEventPlayerChatString() == "-weather wind" ) or ( GetEventPlayerChatString() == "-weather snow" ) or ( GetEventPlayerChatString() == "-weather rain" ) )then
call DisplayTextToPlayer(TempPlayer,0,0, Info)
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 1
set random [1] = Moon
set random [2] = Rain
set random [3] = Snow
set random [4] = Light
set random [5] = Wind
loop
exitwhen i > 12
call TriggerRegisterPlayerChatEvent( t, Player(i - 1), "-weather", false )
set i = i + 1
endloop
call TriggerAddAction( t, function f )
endfunction
endlibrary