SpawnPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 50121 by Marcin778 (talk))
Line 1: Line 1:
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
__NOTOC__
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
{{Server function}}
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This function spawns the player at an arbitary point on the map.<br>
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
{{Note|[[setCameraTarget]] must be used to focus on the player. Also, all players have their camera initially faded out after connect. To ensure that the camera is faded in, please do a [[fadeCamera]] after.}}
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Syntax==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
<syntaxhighlight lang="lua">
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
bool spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = getPlayerTeam(thePlayer) ] )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
</syntaxhighlight>
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
{{OOP||[[player]]:spawn||}}
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
===Required Arguments===
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''thePlayer:''' The player you want to spawn.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''x:''' The x co-ordinate to spawn the player at.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''y:''' The y co-ordinate to spawn the player at.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''z:''' The z co-ordinate to spawn the player at.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
===Optional Arguments===
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''rotation:''' rotation of the player on spawn.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''skinID:''' player's skin on spawn. [[Character Skins]]
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''interior:''' interior the player will spawn into. [[Interior IDs]]
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''dimension:''' The ID of the [[dimension]] that the player should be in.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
*'''theTeam:''' the team the player will join.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
===Returns===
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
Returns ''true'' if the player was spawned successfully, ''false'' otherwise.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
==Example==
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This example spawns all the players in the middle of the game map.
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
<syntaxhighlight lang="lua">
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
-- Get a table of all the players
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
players = getElementsByType ( "player" )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
-- Go through every player
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
for playerKey, playerValue in ipairs(players) do
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
-- Spawn them at the desired coordinates
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
spawnPlayer ( playerValue, 0.0, 0.0, 5.0, 90.0, 0 )
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
end
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
</syntaxhighlight>
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
 
Extrem liże hazowi dupsko a Barcioo liże cipsko Trinowi
This example spawns a player when he logs in.
<syntaxhighlight lang="lua">
spawnTeam = createTeam ("Teamname", 255, 0, 0) -- Create team to spawn.
function spawnOnLogin (prevA, curA )
outputChatBox ("Welcome to ...", source, 255, 0, 0, false)
spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) -- spawns player with random skin
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin)
</syntaxhighlight>
 
==See Also==
{{Player_functions}}
[[ru:spawnPlayer]]

Revision as of 18:20, 1 January 2017

This function spawns the player at an arbitary point on the map.

[[{{{image}}}|link=|]] Note: setCameraTarget must be used to focus on the player. Also, all players have their camera initially faded out after connect. To ensure that the camera is faded in, please do a fadeCamera after.

Syntax

bool spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = getPlayerTeam(thePlayer) ] )

OOP Syntax Help! I don't understand this!

Method: player:spawn(...)


Required Arguments

  • thePlayer: The player you want to spawn.
  • x: The x co-ordinate to spawn the player at.
  • y: The y co-ordinate to spawn the player at.
  • z: The z co-ordinate to spawn the player at.

Optional Arguments

  • rotation: rotation of the player on spawn.
  • skinID: player's skin on spawn. Character Skins
  • interior: interior the player will spawn into. Interior IDs
  • dimension: The ID of the dimension that the player should be in.
  • theTeam: the team the player will join.

Returns

Returns true if the player was spawned successfully, false otherwise.

Example

This example spawns all the players in the middle of the game map.

-- Get a table of all the players
players = getElementsByType ( "player" )
-- Go through every player
for playerKey, playerValue in ipairs(players) do
	-- Spawn them at the desired coordinates
	spawnPlayer ( playerValue, 0.0, 0.0, 5.0, 90.0, 0 )
end

This example spawns a player when he logs in.

spawnTeam = createTeam ("Teamname", 255, 0, 0) -- Create team to spawn.
function spawnOnLogin (prevA, curA )
	outputChatBox ("Welcome to ...", source, 255, 0, 0, false)
	spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) -- spawns player with random skin
	fadeCamera (source, true)
	setCameraTarget (source, source)
end
addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin)

See Also