Resource:Spawnmanager/getSpawnpointTeam

From Multi Theft Auto: Wiki
Revision as of 19:32, 19 October 2007 by Talidan (talk | contribs) (New page: {{Server function}} __NOTOC__ This function returns the team element from a particular spawnpoint. ==Syntax== <syntaxhighlight lang="lua"> team getSpawnpointTeam ( spawnpoint spawn ) ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns the team element from a particular spawnpoint.

Syntax

team getSpawnpointTeam ( spawnpoint spawn )              

Required Arguments

  • spawn: A valid spawnpoint element.

Returns

If the spawnpoint given is valid and has a team, it returns a team element representing the team players will join when spawning there, false otherwise.

Example

This example outputs which team, if any, the spawnpoint is associated with when a player spawns.

function checkPlayerSpawn ( theSpawnpoint )
	local outString = "Player spawned"
	local spawnTeam
	
	if ( theSpawnpoint ) then
		outString = outString .. " on a spawnpoint"
		
		spawnTeam = call(getResourceFromName("spawnmanager", "getSpawnpointTeam", theSpawnpoint )
		if ( spawnTeam ) then
			outString = outString .. " for team: " .. getTeamName ( spawnTeam )
		end
	end
	
	outString = outString .. "."
	outputChatBox ( outString )
end
addEventHandler ( "onPlayerSpawn", getRootElement(), checkPlayerSpawn )