Difference between revisions of "Lua:IsPlayer"
From Fortress Forever Wiki
Jump to navigationJump to searchMulchman MM (talk | contribs) |
Mulchman MM (talk | contribs) |
||
| Line 13: | Line 13: | ||
===Example=== | ===Example=== | ||
| − | Here's an example of seeing if someone touching a trigger_ff_script named "red_goal" is a player or not and then giving that | + | Here's an example of seeing if someone touching a trigger_ff_script named "red_goal" is a player or not and then giving that players team a point: |
<pre>-- In the map's .LUA file... | <pre>-- In the map's .LUA file... | ||
| Line 23: | Line 23: | ||
function red_goal:ontouch( ent_id ) | function red_goal:ontouch( ent_id ) | ||
if IsPlayer( ent_id ) then | if IsPlayer( ent_id ) then | ||
| − | -- Add 1 point to the players | + | -- Add 1 point to the players team |
AddTeamScore( GetPlayerTeam( ent_id ), 1 ) | AddTeamScore( GetPlayerTeam( ent_id ), 1 ) | ||
end | end | ||
Revision as of 10:36, 19 June 2006
IsPlayer
IsPlayer is used to see if an entity index being passed into a function is a player or not.
Usage
IsPlayer( ent_id )
Input
The ent_id passed in is simply an integer index that refers to an entities game code ENTINDEX().
Output
The output is true or false depending if ent_id is a player or not.
Example
Here's an example of seeing if someone touching a trigger_ff_script named "red_goal" is a player or not and then giving that players team a point:
-- In the map's .LUA file...
-- Define red_goal trigger_ff_script
red_goal = trigger_ff_script:new({})
-- When we're touched by a player, do something
function red_goal:ontouch( ent_id )
if IsPlayer( ent_id ) then
-- Add 1 point to the players team
AddTeamScore( GetPlayerTeam( ent_id ), 1 )
end
end