GetElementModel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
===Returns=== | ===Returns=== | ||
Returns the model ID if successful, ''false'' otherwise. | Returns the model ID if successful, ''false'' otherwise. | ||
===Example=== | |||
<section class="server" name="Example 1 (Server)" show="true"> | |||
This example destroys a haystack when a player targets it. | |||
<syntaxhighlight lang="lua"> | |||
function onPlayerTargeted ( targetElem ) | |||
if ( getElementType ( targetElem ) == "object" ) and ( getElementModel ( targetElem ) == 3374 ) then | |||
destroyElement ( targetElem ) | |||
end | |||
end | |||
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted ) | |||
</syntaxhighlight> | |||
</section> | |||
<section class="server" name="Example 2 (Server)" show="true"> | |||
This example prints out a message when a Shamal or AT-400 is entered by a player. | |||
<syntaxhighlight lang="lua"> | |||
function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle | |||
local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle | |||
if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400 | |||
local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle | |||
outputChatBox ( "Someone stole a " .. vehicleName .. "!" ) -- announce that someone stole the plane | |||
end | |||
end | |||
-- add the event handler to the event | |||
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), planeEnter ) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Element functions}} | {{Element functions}} |
Revision as of 17:09, 4 April 2009
Returns the model ID of a given element. This can be a player/ped skin, a pickup model, an object model or a vehicle model.
Syntax
int getElementModel ( element theElement )
Required Arguments
- theElement: the element to retrieve the model ID of.
Returns
Returns the model ID if successful, false otherwise.
Example
Click to collapse [-]
Example 1 (Server)This example destroys a haystack when a player targets it.
function onPlayerTargeted ( targetElem ) if ( getElementType ( targetElem ) == "object" ) and ( getElementModel ( targetElem ) == 3374 ) then destroyElement ( targetElem ) end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
Click to collapse [-]
Example 2 (Server)This example prints out a message when a Shamal or AT-400 is entered by a player.
function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400 local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle outputChatBox ( "Someone stole a " .. vehicleName .. "!" ) -- announce that someone stole the plane end end -- add the event handler to the event addEventHandler ( "onPlayerVehicleEnter", getRootElement(), planeEnter )
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