Quote:
Originally Posted by TheWetMule
Anyway, got another one for you, is there a way to restock people ,constantly, no matter where they are without the use of mass trigger_ff_scripts :X?
|
Add this to
startup():
Code:
AddScheduleRepeating( "Restock", RESTOCK_ITERATION_TIME, restock )
And then here's the bulk of the code:
Code:
playerStateTable = {}
RESTOCK_ITERATION_TIME = 1
function player_spawn( player_id )
local player = GetPlayer(player_id)
-- Remove any players not on a team from table
for playerx, recordx in pairs(playerStateTable) do
ConsoleToAll("RECORD: "..playerStateTable[playerx].restock)
local playert = GetPlayerByID( playerx )
if (playert:GetTeamId() ~= Team.kRed) and (playert:GetTeamId() ~= Team.kBlue) and (playert:GetTeamId() ~= Team.kGreen) and (playert:GetTeamId() ~= Team.kYellow) then
playerStateTable[playerx] = nil
end
end
-- add to table and set restock to 1
playerStateTable[player:GetId()] = {restock = 1}
end
function restock()
for playerx, recordx in pairs(playerStateTable) do
if playerStateTable[playerx].restock == 1 then
local player = GetPlayerByID( playerx )
player:AddHealth( 400 )
player:AddArmor( 400 )
player:AddAmmo(Ammo.kCells, 400)
player:AddAmmo(Ammo.kShells, 400)
player:AddAmmo(Ammo.kNails, 400)
player:AddAmmo(Ammo.kRockets, 400)
player:AddAmmo(Ammo.kGren1, 400)
player:AddAmmo(Ammo.kGren2, 400)
end
end
end
This will restock every 1 second. Change RESTOCK_ITERATION_TIME if it's too long/too short.