Moderator
M
Moderator
15:56, 20th Aug 2013
PurgeandFire: Approved. Useful.
PurgeandFire: Approved. Useful.
GiveGoldSystemConfig

Events


Map initialization

Conditions

Actions


-------- This is the string command you want to activate the give gold. The capitilaztion matters for this code. so -giveGold and -givegold are different. --------


-------- I gave you the option to put a space after the give gold command. If you want -givegold to be the command then -givegold01 would give money to player 01 red. --------


-------- The reason this is -givegold01 is because i needed to add room for player 10 11 and 12. so this works for all players in game. --------


Set giveGoldString = -giveGold


-------- --------


-------- --------


-------- This allows you to tax the gold being traded. So lets say i give 100 gold to player 2 and the tax is 10% ( type in .10 for 10 percent) then i will lose 100 gold but only give player 2 90 gold. --------


Set giveGoldTax = 0.10


-------- --------


-------- --------


-------- Delete these variables after copying to ur map. --------


-------- --------


-------- --------


-------- This boolean lets u set if u want the player to be able to give gold. the index is for player red so player 1 gets the 1 index number. --------


-------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give gold. --------


Set giveGoldBoolGiverPlayer[1] = True


-------- --------


-------- --------


-------- This boolean lets u set if u want the player to be able to recieve gold. the index is for player red so player 1 gets the 1 index number. --------


-------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give gold. --------


Set giveGoldBoolReceivePlayer[1] = True


-------- --------


-------- --------


Set giveGoldLength1 = 0


Set giveGoldLength2 = 0
// 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
GiveLumberSystemConfig

Events


Map initialization

Conditions

Actions


-------- This is the string command you want to activate the give lumber. The capitilaztion matters for this code. so -giveLumber and -givelumber are different. --------


-------- I gave you the option to put a space after the give Lumber command. If you want -giveLumber to be the command then -giveLumber01 would give money to player 01 red. --------


-------- The reason this is -giveLumber01 is because i needed to add room for player 10 11 and 12. so this works for all players in game. --------


Set giveLumberString = -giveLumber


-------- --------


-------- --------


-------- This allows you to tax the lumber being traded. So lets say i give 100 lumber to player 2 and the tax is 10% ( type in .10 for 10 percent) then i will lose 100 lumber but only give player 2 90 lumber. --------


Set giveLumberTax = 0.10


-------- --------


-------- --------


-------- Delete these variables after copying to ur map. --------


-------- --------


-------- --------


-------- This boolean lets u set if u want the player to be able to give lumber. the index is for player red so player 1 gets the 1 index number. --------


-------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give lumber. --------


Set giveLumberBoolGiverPlayer[1] = True


-------- --------


-------- --------


-------- This boolean lets u set if u want the player to be able to recieve lumber. the index is for player red so player 1 gets the 1 index number. --------


-------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give lumber. --------


Set giveLumberBoolReceivePlayer[1] = True


-------- --------


-------- --------


Set giveLumberLength1 = 0


Set giveLumberLength2 = 0
// 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