Difference between revisions of "Lua:player spawn"

From Fortress Forever Wiki
Jump to navigationJump to search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Infobox manual/Header}}
 
This function is called whenever a player spawns in the map.
 
This function is called whenever a player spawns in the map.
  
Line 23: Line 24:
 
</pre>
 
</pre>
  
[[Category:Lua Commands]]
+
[[Category:Lua Callbacks]]
 +
{{Infobox manual/Footer}}

Latest revision as of 11:08, 12 May 2009


This function is called whenever a player spawns in the map.

Here is an example of giving the player full health, full armor, full rockets, full shells, and 1 grenade upon spawning (player_id is the player this event is called on and must be passed in to the functions used as shown in the example):

function player_spawn( player_id )
	-- 400 for overkill. of course the values
	-- get clamped in game code
	AddHealth( player_id, 400 )
	AddArmor( player_id, 400 )

	AddAmmo( player_id, "AMMO_NAILS", -400 )
	AddAmmo( player_id, "AMMO_SHELLS", 400 )
	AddAmmo( player_id, "AMMO_ROCKETS", 400 )
	AddAmmo( player_id, "AMMO_CELLS", -400 )
	AddAmmo( player_id, "AMMO_DETPACK", -1 )
	AddAmmo( player_id, "AMMO_RADIOTAG", -400 )
	AddAmmo( player_id, "AMMO_GREN1", -4 )
	AddAmmo( player_id, "AMMO_GREN2", -4 )

	-- Players get 1 gren1
	AddAmmo( player_id, "AMMO_GREN1", 1 )
end