Moderator
M
Moderator
15:56, 20th Aug 2013
PurgeandFire: Approved. Useful.
PurgeandFire: Approved. Useful.
// Give Gold System v 1.0.1.4
// by deathismyfriend
function GiveGoldSystemActions takes nothing returns boolean
local string entered
local string sub1
local integer recp // recieving player
local integer money
local integer p = GetPlayerId( GetTriggerPlayer())
local integer i
local playerstate psrg
if udg_giveGoldBoolGiverPlayer[ p+1] then
set entered = GetEventPlayerChatString()
set sub1 = SubString( entered, 0, udg_giveGoldLength1)
set recp = S2I( SubString( entered, udg_giveGoldLength1, udg_giveGoldLength2))
if recp != p + 1 then
if sub1 == udg_giveGoldString and udg_giveGoldBoolReceivePlayer[ recp] then
set money = S2I( SubString( entered, udg_giveGoldLength2, StringLength( entered)))
set psrg = PLAYER_STATE_RESOURCE_GOLD
set i = GetPlayerState( Player( p), psrg)
if money < i then
call SetPlayerState( Player( recp), psrg, GetPlayerState( Player( recp), psrg) + R2I( I2R( money) * udg_giveGoldTax))
else
call SetPlayerState( Player( recp), psrg, GetPlayerState( Player( recp), psrg) + R2I( I2R( i) * udg_giveGoldTax))
endif
call SetPlayerState( Player( p), psrg, i - money)
set psrg = null
endif
endif
endif
return false
endfunction
function GiveGoldSystemSetup takes nothing returns nothing
local trigger t = CreateTrigger()
local integer L = 0
local integer i = StringLength( udg_giveGoldString)
loop
exitwhen L > 11
call TriggerRegisterPlayerChatEvent( t, Player( L), udg_giveGoldString, false)
set L = L + 1
endloop
call TriggerAddCondition( t, Condition( function GiveGoldSystemActions))
set udg_giveGoldLength1 = i
set udg_giveGoldLength2 = i + 2
set udg_giveGoldTax = 1.00 - udg_giveGoldTax
call DestroyTimer( GetExpiredTimer())
set t = null
endfunction
//===========================================================================
function InitTrig_GiveGoldSystemCode takes nothing returns nothing
call TimerStart( CreateTimer(), 0.00, false, function GiveGoldSystemSetup)
endfunction
// Give Lumber System v 1.0.1.4
// by deathismyfriend
function GiveLumberSystemActions takes nothing returns boolean
local string entered
local string sub1
local integer recp // recieving player
local integer lumber
local integer p = GetPlayerId( GetTriggerPlayer())
local integer i
local playerstate psrl
if udg_giveLumberBoolGiverPlayer[ p+1] then
set entered = GetEventPlayerChatString()
set sub1 = SubString( entered, 0, udg_giveLumberLength1)
set recp = S2I( SubString( entered, udg_giveLumberLength1, udg_giveLumberLength2))
if recp != p + 1 then
if sub1 == udg_giveLumberString and udg_giveGoldBoolReceivePlayer[ recp] then
set lumber = S2I( SubString( entered, udg_giveLumberLength2, StringLength( entered)))
set psrl = PLAYER_STATE_RESOURCE_LUMBER
set i = GetPlayerState( Player( p), psrl)
if lumber < i then
call SetPlayerState( Player( recp), psrl, GetPlayerState( Player( recp), psrl) + R2I( I2R( lumber) * udg_giveLumberTax))
else
call SetPlayerState( Player(recp), psrl, GetPlayerState( Player( recp), psrl) + R2I( I2R( i) * udg_giveLumberTax))
endif
call SetPlayerState( Player( p), psrl, i - lumber)
set psrl = null
endif
endif
endif
return false
endfunction
function GiveLumberSystemSetup takes nothing returns nothing
local trigger t = CreateTrigger()
local integer L = 0
local integer i = StringLength( udg_giveLumberString)
loop
exitwhen L > 11
call TriggerRegisterPlayerChatEvent( t, Player( L), udg_giveLumberString, false)
set L = L + 1
endloop
call TriggerAddCondition( t, Condition( function GiveLumberSystemActions))
set udg_giveLumberLength1 = i
set udg_giveLumberLength2 = i + 2
call DestroyTimer( GetExpiredTimer())
set t = null
endfunction
//===========================================================================
function InitTrig_GiveLumberSystemCode takes nothing returns nothing
call TimerStart( CreateTimer(), 0.00, false, function GiveLumberSystemSetup)
endfunction