SpawnPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 50121 by Marcin778 (talk))
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{服务器函数}}
This function spawns the player at an arbitary point on the map.<br>
此函数是在地图上生成玩家(即刷新或者是重生玩家).<br>
{{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.}}
{{注意|[[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==
==Syntax==
Line 9: Line 9:
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[player]]:spawn||}}
{{OOP||[[player]]:spawn||}}
===Required Arguments===
===必须参数===
*'''thePlayer:''' The player you want to spawn.
*'''thePlayer:''' 你想生成(复活)的玩家.
*'''x:''' The x co-ordinate to spawn the player at.
*'''x:''' 生成(复活)时所在的 x 坐标.
*'''y:''' The y co-ordinate to spawn the player at.
*'''y:''' 生成(复活)时所在的 y 坐标.
*'''z:''' The z co-ordinate to spawn the player at.
*'''z:''' 生成(复活)时所在的 z 坐标.


===Optional Arguments===
===可选参数===
*'''rotation:''' rotation of the player on spawn.
*'''rotation:''' rotation of the player on spawn.
*'''skinID:''' player's skin on spawn. [[Character Skins]]
*'''skinID:''' 生成(重生)玩家的皮肤ID. [[Character Skins]]
*'''interior:''' interior the player will spawn into. [[Interior IDs]]
*'''interior:''' interior the player will spawn into. [[Interior IDs]]
*'''dimension:''' The ID of the [[dimension]] that the player should be in.
*'''dimension:''' The ID of the [[dimension]] that the player should be in.
*'''theTeam:''' the team the player will join.
*'''theTeam:''' 玩家将加入的团队.


===Returns===
===返回===
Returns ''true'' if the player was spawned successfully, ''false'' otherwise.
如果玩家生成(重生)成功,则返回'true',否则返回false.


==Example==  
==例子==  
This example spawns all the players in the middle of the game map.
这个例子生成(重生)服务器内所有的玩家.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Get a table of all the players
-- 获取所有玩家列表
players = getElementsByType ( "player" )
players = getElementsByType ( "player" )
-- Go through every player
-- 通过遍历数组来获获取每一个玩家
for playerKey, playerValue in ipairs(players) do
for playerKey, playerValue in ipairs(players) do
-- Spawn them at the desired coordinates
-- Spawn them at the desired coordinates
Line 37: Line 37:
</syntaxhighlight>
</syntaxhighlight>


This example spawns a player when he logs in.
此例演示在玩家登陆时生成(重生)一个玩家.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
spawnTeam = createTeam ("Teamname", 255, 0, 0) -- Create team to spawn.
spawnTeam = createTeam ("Teamname", 255, 0, 0) -- 创建一个名为"Teamname"的团队.
function spawnOnLogin (prevA, curA )
function spawnOnLogin (prevA, curA )
outputChatBox ("Welcome to ...", source, 255, 0, 0, false)
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
spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) -- 生成(重生)玩家并使玩家皮肤ID数从0到288随机一个数
fadeCamera (source, true)
fadeCamera (source, true)
setCameraTarget (source, source)
setCameraTarget (source, source)

Revision as of 14:15, 10 February 2017

Template:服务器函数 此函数是在地图上生成玩家(即刷新或者是重生玩家).
Template:注意

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(...)


必须参数

  • thePlayer: 你想生成(复活)的玩家.
  • x: 生成(复活)时所在的 x 坐标.
  • y: 生成(复活)时所在的 y 坐标.
  • z: 生成(复活)时所在的 z 坐标.

可选参数

  • rotation: rotation of the player on spawn.
  • skinID: 生成(重生)玩家的皮肤ID. Character Skins
  • interior: interior the player will spawn into. Interior IDs
  • dimension: The ID of the dimension that the player should be in.
  • theTeam: 玩家将加入的团队.

返回

如果玩家生成(重生)成功,则返回'true',否则返回false.

例子

这个例子生成(重生)服务器内所有的玩家.

-- 获取所有玩家列表
players = getElementsByType ( "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

此例演示在玩家登陆时生成(重生)一个玩家.

spawnTeam = createTeam ("Teamname", 255, 0, 0) -- 创建一个名为"Teamname"的团队.
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) -- 生成(重生)玩家并使玩家皮肤ID数从0到288随机一个数
	fadeCamera (source, true)
	setCameraTarget (source, source)
end
addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin)

See Also