CreatePed: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		 
		
	
| No edit summary |  (missing oop) | ||
| (21 intermediate revisions by 15 users not shown) | |||
| Line 1: | Line 1: | ||
| __NOTOC__   | __NOTOC__   | ||
| {{Server client function}} | {{Server client function}} | ||
| 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 )</syntaxhighlight>   | <section name="Server" class="server" show="true">  | ||
| <syntaxhighlight lang="lua">ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0, bool synced = true ] )</syntaxhighlight>   | |||
| ===Required Arguments===   | ===Required Arguments===   | ||
| Line 12: | Line 12: | ||
| *'''y:''' A floating point number representing the Y 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. | *'''z:''' A floating point number representing the Z coordinate on the map. | ||
| ==Optional Arguments== | |||
| {{OptionalArg}} | |||
| *'''rot:''' A floating point number representing the rotation in degrees.  | |||
| *'''synced:''' A boolean value representing whether or not the ped will be synced. Disabling the sync might be useful for frozen or static peds to increase the server performance. | |||
| </section> | |||
| <section name="Client" class="client" show="true"> | |||
| <syntaxhighlight lang="lua">ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0 ] )</syntaxhighlight>  | |||
| ===Required Arguments===  | |||
| *'''modelid:''' A whole integer specifying the [[Character_Skins|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. | |||
| ==Optional Arguments== | |||
| {{OptionalArg}} | |||
| *'''rot:''' A floating point number representing the rotation in degrees.   | *'''rot:''' A floating point number representing the rotation in degrees.   | ||
| </section> | |||
| {{OOP||[[Ped]]||}} | |||
| ===Returns=== | ===Returns=== | ||
| Returns  | Returns a ped element if it was successfully created. | ||
| ==Example==   | ==Example==   | ||
| Line 25: | Line 45: | ||
|     createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) |     createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) | ||
| end | end | ||
| addEventHandler ( "onResourceStart",  | addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) | ||
| </syntaxhighlight> | |||
| </section> | |||
| <section name="Client" class="client" show="true"> | |||
| This example creates a ped, and makes it damage proof: | |||
| <syntaxhighlight lang="lua"> | |||
| thePed = createPed(120, 5540.6654, 1020.55122, 1240.545) -- Creates a ped | |||
| function cancelPedDamage() | |||
| 	cancelEvent() -- Cancels the onClientPedDamage event | |||
| end | |||
| addEventHandler("onClientPedDamage", thePed, cancelPedDamage) -- When thePed is damaged, cancelPedDamage is called | |||
| </syntaxhighlight> | </syntaxhighlight> | ||
| </section> | </section> | ||
| ==Issues== | |||
| {{Issues| | |||
| {{Issue|375|Sync distance of unoccupied vehicles and peds should match stream distance}} | |||
| {{Issue|605|Ped fireing Projectiles doesn't work}} | |||
| {{Issue|492|Peds shooting incorrectly}} | |||
| }} | |||
| ==See Also== | ==See Also== | ||
| {{Ped functions}} | {{Ped functions}} | ||
| [[hu:createPed]] | |||
| [[pl:createPed]] | |||
| [[ru:createPed]] | |||
Latest revision as of 05:59, 5 November 2023
Creates a Ped in the GTA world.
Syntax
Click to collapse [-]
Serverped createPed ( int modelid, float x, float y, float z [, float rot = 0.0, bool synced = 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.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- rot: A floating point number representing the rotation in degrees.
- synced: A boolean value representing whether or not the ped will be synced. Disabling the sync might be useful for frozen or static peds to increase the server performance.
Click to collapse [-]
Clientped createPed ( int modelid, float x, float y, float z [, float rot = 0.0 ] )
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.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- rot: A floating point number representing the rotation in degrees.
OOP Syntax Help! I don't understand this!
- Method: Ped(...)
Returns
Returns a ped element if it was successfully created.
Example
Click to collapse [-]
ServerThis example creates an ped when the resource starts:
function pedLoad ( name ) createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) end addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad )
Click to collapse [-]
ClientThis example creates a ped, and makes it damage proof:
thePed = createPed(120, 5540.6654, 1020.55122, 1240.545) -- Creates a ped
function cancelPedDamage()
	cancelEvent() -- Cancels the onClientPedDamage event
end
addEventHandler("onClientPedDamage", thePed, cancelPedDamage) -- When thePed is damaged, cancelPedDamage is called
Issues
| Issue ID | Description | 
|---|---|
| #375 | Sync distance of unoccupied vehicles and peds should match stream distance | 
| #605 | Ped fireing Projectiles doesn't work | 
| #492 | Peds shooting incorrectly | 
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnGround
- isPedReloadingWeapon
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle