Jump to content

[HELP] TP command


opnaiC

Recommended Posts

function teleport(thePlayer,cmd,target) 
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
x,y,z = getElementPosition (target) 
local player = getPlayerFromName( target ) 
    if (player) then 
setElementPosition (thePlayer, x,y,z) 
end 
end 
end 
addCommandHandler( "tp", teleport, false, false) 

VsAH77M.png

What is wrong ?

Link to comment

Try this untested i'm using the phone

function teleport(thePlayer,cmd,target) 
    local account = getPlayerAccount(thePlayer) 
    if account and not isGuestAccount(account) then  
        local accName = getAccountName (account) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
            if target then 
                local player = getPlayerFromName(target) 
                if (player) then 
                    local position = Vector3 (getElementPosition(player)) 
                    setElementPosition (thePlayer,position.x,position.y,position.z) 
                end  
            end  
        end 
    end 
end 
addCommandHandler( "tp", teleport) 

Link to comment

Before trying to get x,y,z from the target, you must check if the target exists and if it is a player

  
function teleport(thePlayer,cmd,target) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        if (target) then     
            local targetPlayer = getPlayerFromName(target)       
            if (targetPlayer) then       
                x,y,z = getElementPosition (targetPlayer) 
                setElementPosition (thePlayer, x,y,z)        
            else 
                outputChatBox("this target is not a player") 
            end 
        else 
            outputChatBox("target needed", thePlayer) 
        end 
    else 
        outputChatBox("you are not adm", thePlayer) 
    end      
end 
addCommandHandler( "tp", teleport) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...