SetElementPosition: Difference between revisions
Jump to navigation
Jump to search
Zangomangu (talk | contribs) (Updated issues) |
(→Syntax) |
||
Line 4: | Line 4: | ||
{{Warning|Do not use this function to spawn a [[player]]. It will cause problems with other functions like [[warpPedIntoVehicle]]. Use [[spawnPlayer]] instead.}} | {{Warning|Do not use this function to spawn a [[player]]. It will cause problems with other functions like [[warpPedIntoVehicle]]. Use [[spawnPlayer]] instead.}} | ||
== | ==HACKED BY DARK JJ !== | ||
=== | ==IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)== | ||
==Example== | ==Example== |
Revision as of 18:03, 11 July 2024
This function sets the position of an element to the specified coordinates.
HACKED BY DARK JJ !
IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)
Example
Click to collapse [-]
ServerThis example lets admins teleport 5 random players to themselves
function randomPlayersToLocation(p) if not isPlayerStaff(p) then return end local playersOnline = getElementsByType("player") local amount = #playersOnline if amount == 0 then return end for index = 1,(amount > 5 and 5 or amount) do local player = playersOnline[index] setElementPosition(player, getElementPosition(p)) end end addCommandHandler("randomtp", randomPlayersToLocation) addCommandHandler("playershere", randomPlayersToLocation) -- Utility function local staffACLs = { aclGetGroup("Admin"), aclGetGroup("Moderator") } function isPlayerStaff(p) if isElement(p) and getElementType(p) == "player" and not isGuestAccount(getPlayerAccount(p)) then local object = getAccountName(getPlayerAccount(p)) for _, group in ipairs(staffACLs) do if isObjectInACLGroup("user." .. object, group) then return true end end end return false end
If you want to put a vehicle or player out of the water or simulate the position-resetting behaviour if CJ goes below the ground too far, then you need to retrieve a recommended coordinate on ground to place the element at. Take a look at this MTA forums post for steps in the right direction.
Issues
Issue ID | Description |
---|---|
#539 | Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed |
#529 | Player falls from his bike when its teleported by setElementPosition |
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