SetElementModel: Difference between revisions
Jump to navigation
Jump to search
m (→Syntax: OOP) |
m (fix oop syntax) |
||
Line 8: | Line 8: | ||
bool setElementModel ( element theElement, int model ) | bool setElementModel ( element theElement, int model ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP| | {{OOP||[[element]]:setModel|model|}} | ||
===Required Arguments=== | ===Required Arguments=== |
Revision as of 18:36, 1 January 2015
Sets the model of a given element. This allows you to change the model of a player (or ped), a vehicle or an object.
Syntax
bool setElementModel ( element theElement, int model )
OOP Syntax Help! I don't understand this!
- Method: element:setModel(...)
- Variable: .model
Required Arguments
- theElement: the element you want to change.
- model: the model ID to set.
- For players/peds: A GTASA player model (skin) ID. See Character Skins.
- For vehicles: The vehicle ID of the vehicle being changed.
- For objects/projectiles/weapons: An int specifying the model id.
Returns
Returns true if successful, false otherwise.
Example
Click to collapse [-]
Example 1 (Server)addCommandHandler ( "changeveh", function ( thePlayer, command, newModel ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) -- get the vehicle the player is in newModel = tonumber ( newModel ) -- try to convert the string argument to a number if theVehicle and newModel then -- make sure the player is in a vehicle and specified a number setElementModel ( theVehicle, newModel ) end end )
After the above code is executed, a player can get in any vehicle and execute e.g. the command "/changeveh 520" to change it into a hydra.
Click to collapse [-]
Example 2 (Server)This will continually change an object model every 2.5 seconds at the location -1084.52, -1634.81, 76.36 (Truth's farm).
myobject = createObject ( 5822, -1084.52, -1634.81, 76.36 ) -- We create an initial object element. I choose object model 5822 to begin with. function objectRandomization () local randomobjectnumber = math.random(1, 18000) -- Choose a random number between 1 and 18000 as a whole integer and assign it to -- the variable 'randomobjectnumber' setElementModel ( myobject, randomobjectnumber ) -- Change our object appearance by applying a new model ID end setTimer ( objectRandomization, 2500, 0 ) -- Every 2.5 seconds, the function 'objectRandomization' is called by this timer. -- Each time the function runs, it changes the object model by applying a new whole- -- integer random object ID. This timer is called an infinite amount of times since -- its repeat value is set to 0.
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement