View Single Post
Old 03-02-2008, 10:32 PM   #39
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
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.
__________________
#FF.Pickup ยค Fortress-Forever pickups

My Non-official Maps
Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic
Beta FF_Myth - FF_Redlight_Greenlight

Sick of the people on the internet, always moanin'. They just moan.
- Karl Pilkington

Last edited by squeek.; 03-03-2008 at 01:54 AM.
squeek. is offline   Reply With Quote