SetElementPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__
==HACKED BY DARK JJ==
{{Shared function}}
==My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )==
This function sets the position of an element to the specified coordinates.
{{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 !==  
==HACKED BY DARK JJ !==  
Line 8: Line 6:
==IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)==
==IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)==


==Example==
==HACKED BY DARK JJ==
<section name="Server" class="server" show="true">
==IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)==
This example lets admins teleport 5 random players to themselves
<syntaxhighlight lang="lua">
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
</syntaxhighlight>
</section>
 
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 [https://forum.mtasa.com/topic/132891-important-helprespawn-vehicle/?do=findComment&comment=1003198 this MTA forums post] for steps in the right direction.
 
==Issues==
{{Issues|
{{Issue|539|Changing player position when he/she has a jetpack will remove the jetpack and bug when skin is changed}}
{{Issue|529|Player falls from his bike when its teleported by setElementPosition}}
}}


==See Also==
==HACKED BY DARK JJ==
{{Element functions}}
==My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )==


[[hu:setElementPosition]]
==HACKED BY DARK JJ==
[[ru:setElementPosition]]
==My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )==

Revision as of 18:07, 11 July 2024

HACKED BY DARK JJ

My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )

HACKED BY DARK JJ !

IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)

HACKED BY DARK JJ

IF YOU CAN BAN ME ! (CAB4917F25ACE777B11B718DB0A7C084)

HACKED BY DARK JJ

My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )

HACKED BY DARK JJ

My Serial : CAB4917F25ACE777B11B718DB0A7C084 ( IF YOU CAN BAN ME MTA XDD )