Lua:IsPlayer
From Fortress Forever Wiki
Jump to navigationJump to search|
IsPlayerIsPlayer is used to see if an entity index being passed into a function is a player or not. UsageIsPlayer( ent_id ) InputThe ent_id passed in is simply an integer index that refers to an entities game code ENTINDEX(). OutputThe output is true or false depending if ent_id is a player or not. ExampleHere'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
|