Moderator
M
Moderator
18:27, 19th Aug 2013
PurgeandFire: Changes made, approved.
PurgeandFire: Changes made, approved.
// Gold Banking System version 1.0.0.6
// by deathismyfriend
function GoldBankForcedBuying takes player P, integer amount returns boolean
local integer p = GetPlayerId( P)
local integer i
if udg_goldBankGold[ p] >= amount then
set udg_goldBankGold[ p] = udg_goldBankGold[ p] - amount
return true
elseif udg_goldBankGold[ p] + GetPlayerState( P, PLAYER_STATE_RESOURCE_GOLD) >= amount then
set i = amount - udg_goldBankGold[ p]
set udg_goldBankGold[ p] = 0
call SetPlayerState( P, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState( P, PLAYER_STATE_RESOURCE_GOLD) - i)
return true
endif
return false
endfunction
function GoldBankForcedBanking takes player P, integer amount returns nothing
local integer p = GetPlayerId( P)
call SetPlayerState( P, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState( P, PLAYER_STATE_RESOURCE_GOLD) - amount)
set udg_goldBankGold[ p] = udg_goldBankGold[ p] + amount
endfunction
function CheckGoldBankSinglePlayer takes player pl returns nothing
local integer p = GetPlayerId( pl)
call DisplayTextToPlayer( Player( p), 0 , 0, "You have " + I2S( udg_goldBankGold[ p]) + " gold in your bank")
endfunction
function DisplayGoldBankStatusAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
call CheckGoldBankSinglePlayer( Player( L))
set L = L + 1
endloop
endfunction
function GoldBankInterestIncSinglePlayer takes player pl, real r returns nothing
local integer p = GetPlayerId( pl)
set r = r + 1.00
set udg_goldBankGold[ p] = R2I( udg_goldBankGold[ p] * r)
endfunction
function GoldBankInterestIncAll takes real r returns nothing
local integer L = 0
loop
exitwhen L > 11
call GoldBankInterestIncSinglePlayer( Player( L), r)
set L = L + 1
endloop
endfunction
function GoldBankingSystemWithdraw takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local string sub1 = SubString( entered, 0, udg_withdrawGoldBankSystemInt)
local string sub2 = SubString( entered, 0, udg_withdrawGoldAllBankSystemInt)
local integer p = GetPlayerId( GetTriggerPlayer())
local integer gold
local playerstate psrg = PLAYER_STATE_RESOURCE_GOLD
local player pl = Player( p)
if udg_withdrawGoldBoolPlayer[ p + 1] then
if sub1 == udg_withdrawGoldString then
set gold = S2I( SubString( entered, udg_depositGoldBankSystemInt, StringLength( entered)))
if udg_goldBankGold[ p] > gold then
call SetPlayerState( pl, psrg, GetPlayerState( pl, psrg) + gold)
set udg_goldBankGold[ p] = udg_goldBankGold[ p] - gold
else
set gold = udg_goldBankGold[ p]
call SetPlayerState( pl, psrg, GetPlayerState( pl, psrg) + gold)
set udg_goldBankGold[ p] = 0
endif
elseif sub2 == udg_withdrawAllGoldString then
call SetPlayerState( pl, psrg, GetPlayerState( pl, psrg) + udg_goldBankGold[ p])
set udg_goldBankGold[ p] = 0
endif
endif
call CheckGoldBankSinglePlayer( pl)
set pl = null
set psrg = null
return false
endfunction
function GoldBankingSystemDeposit takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local string sub1 = SubString( entered, 0, udg_depositGoldBankSystemInt)
local string sub2 = SubString( entered, 0, udg_depositGoldAllBankSystemInt)
local integer p = GetPlayerId( GetTriggerPlayer())
local integer gold
local playerstate psrg = PLAYER_STATE_RESOURCE_GOLD
local integer i
local player pl = Player( p)
if udg_depositGoldBoolPlayer[ p + 1] then
if sub1 == udg_depositGoldString then
set gold = S2I( SubString( entered, udg_depositGoldBankSystemInt, StringLength( entered)))
set i = GetPlayerState( pl, psrg)
if gold > i then
call SetPlayerState( pl, psrg, 0)
set udg_goldBankGold[ p] = udg_goldBankGold[ p] + i
else
call SetPlayerState( pl, psrg, i - gold)
set udg_goldBankGold[ p] = udg_goldBankGold[ p] + gold
endif
elseif sub2 == udg_depositAllGoldString then
set i = GetPlayerState( pl, psrg)
call SetPlayerState( pl, psrg, 0)
set udg_goldBankGold[ p] = udg_goldBankGold[ p] + i
endif
endif
call CheckGoldBankSinglePlayer( pl)
set pl = null
set psrg = null
return false
endfunction
function GoldBankingSystemCheck takes nothing returns boolean
if SubString( GetEventPlayerChatString(), 0, udg_checkGoldBankSystemInt) == udg_checkBankGoldString then
call CheckGoldBankSinglePlayer( GetTriggerPlayer())
endif
return false
endfunction
function GoldBankingSystemSetup takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call TriggerRegisterPlayerChatEvent( t1, P, udg_withdrawGoldString, false)
call TriggerRegisterPlayerChatEvent( t1, P, udg_withdrawAllGoldString, false)
call TriggerRegisterPlayerChatEvent( t2, P, udg_depositGoldString, false)
call TriggerRegisterPlayerChatEvent( t2, P, udg_depositAllGoldString, false)
call TriggerRegisterPlayerChatEvent( t3, P, udg_checkBankGoldString, false)
endif
set L = L + 1
endloop
set udg_withdrawGoldBankSystemInt = StringLength( udg_withdrawGoldString)
set udg_withdrawGoldAllBankSystemInt = StringLength( udg_withdrawAllGoldString)
set udg_depositGoldBankSystemInt = StringLength( udg_depositGoldString)
set udg_depositGoldAllBankSystemInt = StringLength( udg_depositAllGoldString)
set udg_checkGoldBankSystemInt = StringLength( udg_checkBankGoldString)
call TriggerAddCondition( t1, Condition( function GoldBankingSystemWithdraw))
call TriggerAddCondition( t2, Condition( function GoldBankingSystemDeposit))
call TriggerAddCondition( t3, Condition( function GoldBankingSystemCheck))
call DestroyTimer( GetExpiredTimer())
set P = null
set t1 = null
set t2 = null
set t3 = null
endfunction
//===========================================================================
function InitTrig_GoldBankingSystemCode takes nothing returns nothing
call TimerStart( CreateTimer(), 0.00, false, function GoldBankingSystemSetup)
endfunction
// Lumber Banking System version 1.0.0.6
// by deathismyfriend
function LumberBankForcedBuying takes player P, integer amount returns boolean
local integer p = GetPlayerId( P)
local integer i
if udg_lumberBankLumber[ p] >= amount then
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] - amount
return true
elseif udg_lumberBankLumber[ p] + GetPlayerState( P, PLAYER_STATE_RESOURCE_LUMBER) >= amount then
set i = amount - udg_lumberBankLumber[ p]
set udg_lumberBankLumber[ p] = 0
call SetPlayerState( P, PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState( P, PLAYER_STATE_RESOURCE_LUMBER) - i)
return true
endif
return false
endfunction
function LumberBankForcedBanking takes player P, integer amount returns nothing
local integer p = GetPlayerId( P)
call SetPlayerState( P, PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState( P, PLAYER_STATE_RESOURCE_LUMBER) - amount)
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] + amount
endfunction
function CheckLumberBankSinglePlayer takes player pl returns nothing
local integer p = GetPlayerId( pl)
call DisplayTextToPlayer( Player( p), 0 , 0, "You have " + I2S( udg_lumberBankLumber[ p]) + " lumber in your bank")
endfunction
function DisplayLumberBankStatusAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
call CheckLumberBankSinglePlayer( Player( L))
set L = L + 1
endloop
endfunction
function LumberBankInterestIncSinglePlayer takes player pl, real r returns nothing
local integer p = GetPlayerId( pl)
set r = r + 1.00
set udg_lumberBankLumber[ p] = R2I( udg_lumberBankLumber[ p] * r)
endfunction
function LumberBankInterestIncAll takes real r returns nothing
local integer L = 0
loop
exitwhen L > 11
call LumberBankInterestIncSinglePlayer( Player( L), r)
set L = L + 1
endloop
endfunction
function LumberBankingSystemWithdraw takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local string sub1 = SubString( entered, 0, udg_withdrawLumberBankSystemInt)
local string sub2 = SubString( entered, 0, udg_withdrawLumberAllBankSystemInt)
local integer p = GetPlayerId( GetTriggerPlayer())
local integer lumber
local playerstate psrl = PLAYER_STATE_RESOURCE_LUMBER
local player pl = Player( p)
if udg_withdrawLumberBoolPlayer[ p + 1] then
if sub1 == udg_withdrawLumberString then
set lumber = S2I( SubString( entered, udg_depositLumberBankSystemInt, StringLength( entered)))
if udg_lumberBankLumber[ p] > lumber then
call SetPlayerState( pl, psrl, GetPlayerState( pl, psrl) + lumber)
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] - lumber
else
set lumber = udg_lumberBankLumber[ p]
call SetPlayerState( pl, psrl, GetPlayerState( pl, psrl) + lumber)
set udg_lumberBankLumber[ p] = 0
endif
elseif sub2 == udg_withdrawAllLumberString then
call SetPlayerState( pl, psrl, GetPlayerState( pl, psrl) + udg_lumberBankLumber[ p])
set udg_lumberBankLumber[ p] = 0
endif
endif
call CheckLumberBankSinglePlayer( pl)
set pl = null
set psrl = null
return false
endfunction
function LumberBankingSystemDeposit takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local string sub1 = SubString( entered, 0, udg_depositLumberBankSystemInt)
local string sub2 = SubString( entered, 0, udg_depositLumberAllBankSystemInt)
local integer p = GetPlayerId( GetTriggerPlayer())
local integer lumber
local playerstate psrl = PLAYER_STATE_RESOURCE_LUMBER
local integer i
local player pl = Player( p)
if udg_depositLumberBoolPlayer[ p + 1] then
if sub1 == udg_depositLumberString then
set lumber = S2I( SubString( entered, udg_depositLumberBankSystemInt, StringLength( entered)))
set i = GetPlayerState( pl, psrl)
if lumber > i then
call SetPlayerState( pl, psrl, 0)
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] + i
else
call SetPlayerState( pl, psrl, i - lumber)
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] + lumber
endif
elseif sub2 == udg_depositAllLumberString then
set i = GetPlayerState( pl, psrl)
call SetPlayerState( pl, psrl, 0)
set udg_lumberBankLumber[ p] = udg_lumberBankLumber[ p] + i
endif
endif
call CheckLumberBankSinglePlayer( pl)
set pl = null
set psrl = null
return false
endfunction
function LumberBankingSystemCheck takes nothing returns boolean
if SubString( GetEventPlayerChatString(), 0, udg_checkLumberBankSystemInt) == udg_checkBankLumberString then
call CheckLumberBankSinglePlayer( GetTriggerPlayer())
endif
return false
endfunction
function LumberBankingSystemSetup takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call TriggerRegisterPlayerChatEvent( t1, P, udg_withdrawLumberString, false)
call TriggerRegisterPlayerChatEvent( t1, P, udg_withdrawAllLumberString, false)
call TriggerRegisterPlayerChatEvent( t2, P, udg_depositLumberString, false)
call TriggerRegisterPlayerChatEvent( t2, P, udg_depositAllLumberString, false)
call TriggerRegisterPlayerChatEvent( t3, P, udg_checkBankLumberString, false)
endif
set L = L + 1
endloop
set udg_withdrawLumberBankSystemInt = StringLength( udg_withdrawLumberString)
set udg_withdrawLumberAllBankSystemInt = StringLength( udg_withdrawAllLumberString)
set udg_depositLumberBankSystemInt = StringLength( udg_depositLumberString)
set udg_depositLumberAllBankSystemInt = StringLength( udg_depositAllLumberString)
set udg_checkLumberBankSystemInt = StringLength( udg_checkBankLumberString)
call TriggerAddCondition( t1, Condition( function LumberBankingSystemWithdraw))
call TriggerAddCondition( t2, Condition( function LumberBankingSystemDeposit))
call TriggerAddCondition( t3, Condition( function LumberBankingSystemCheck))
call DestroyTimer( GetExpiredTimer())
set P = null
set t1 = null
set t2 = null
set t3 = null
endfunction
//===========================================================================
function InitTrig_LumberBankingSystemCode takes nothing returns nothing
call TimerStart( CreateTimer(), 0.00, false, function LumberBankingSystemSetup)
endfunction