Difference between revisions of "CreatePed"

From Multi Theft Auto: Wiki
(Syntax)
(Added the bSynced argument)
Line 1: Line 1:
 
__NOTOC__  
 
__NOTOC__  
 
{{Server client function}}
 
{{Server client function}}
{{Needs_Checking|CPP has code for a serverside extra argument called bSynced}}  
+
{{Needs_Checking|Please check if I'm right with the bSynced argument. I've been testing two different peds and discovered the effect written below --[[User:OpenIDUser28|Sniper]] 03:12, 4 September 2011 (CEST)}}  
 
Creates a Ped in the GTA world.
 
Creates a Ped in the GTA world.
  
 
==Syntax==  
 
==Syntax==  
<syntaxhighlight lang="lua">ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0 ] )</syntaxhighlight>  
+
<syntaxhighlight lang="lua">ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0, bool bSynced = true ] )</syntaxhighlight>  
  
 
===Required Arguments===  
 
===Required Arguments===  
Line 13: Line 13:
 
*'''z:''' A floating point number representing the Z coordinate on the map.
 
*'''z:''' A floating point number representing the Z coordinate on the map.
 
*'''rot:''' A floating point number representing the rotation in degrees.  
 
*'''rot:''' A floating point number representing the rotation in degrees.  
 +
*'''bSynced:''' A boolean value representing whether or not the ped will be fully synchronized even for players that are not within the syncing range. If disabled a player that is more than 100 units away from the ped won't receive new information about its state and position. This will cause a desync of the ped (useful for frozen/static peds to increase the server perfomance).
  
 
===Returns===
 
===Returns===
Returns the ped element.
+
Returns a ped element if it was successfully created, ''nil'' if an invalid element is passed.
  
 
==Example==  
 
==Example==  

Revision as of 01:12, 4 September 2011

Dialog-information.png This article needs checking.

Reason(s): Please check if I'm right with the bSynced argument. I've been testing two different peds and discovered the effect written below --Sniper 03:12, 4 September 2011 (CEST)

Creates a Ped in the GTA world.

Syntax

ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0, bool bSynced = true ] )

Required Arguments

  • modelid: A whole integer specifying the GTASA skin ID.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.
  • rot: A floating point number representing the rotation in degrees.
  • bSynced: A boolean value representing whether or not the ped will be fully synchronized even for players that are not within the syncing range. If disabled a player that is more than 100 units away from the ped won't receive new information about its state and position. This will cause a desync of the ped (useful for frozen/static peds to increase the server perfomance).

Returns

Returns a ped element if it was successfully created, nil if an invalid element is passed.

Example

Click to collapse [-]
Server

This example creates an ped when the resource starts:

function pedLoad ( name )
   createPed ( 120, 5540.6654, 1020.55122, 1240.545 )
end
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

See Also