Jump to content

help setElementPosition


Recommended Posts

Well I would like to know why this script is not teleporting to the player the goal is simple typing / goto name player and teleport to the player

function teleportarPlayer ( source, posX, posY, posZ ) 
    getPlayerFromName ( source )  
    getElementPosition ( source ) 
    setElementPosition ( source, posX, posY, posZ ) 
end 
addCommandHandler ( "goto", teleportarPlayer  ) 

Link to comment
  • Moderators
function teleportarPlayer (player, CMD, targetName ) 
        if not targetName then -- check if the player wrote down his target 
            outputChatBox("pls fill in the player name.",player) 
        else 
            local target = getPlayerFromName (targetName ) -- the name is there, now get the player from the name.  
            if not target then -- check if the name is valit 
                outputChatBox("pls fill in the correct player name.",player) 
            else 
                local x,y,z = getElementPosition ( target ) 
                setElementPosition ( player,x,y,z+1) 
                --setElementPosition ( player, getElementPosition ( target )) -- you probably got stuck in him...  
            end 
        end 
    end 
    addCommandHandler ( "goto", teleportarPlayer  ) 

Edited by Guest
Link to comment

It could also help me with something? I am not able to release the function only for administrator

function teleportarPlayer (player, CMD, targetName, thePlayer) 
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then    
        if not targetName then 
            outputChatBox("Uso Correto: /goto nick") 
        else 
            local target = getPlayerFromName (targetName ) 
            if not target then -- check if the name is valit 
                outputChatBox("ERRO: Jogador não encontra-se online!") 
            else 
                local x,y,z = getElementPosition ( target ) 
                setElementPosition ( player,x,y,z+1) 
                --setElementPosition ( player, getElementPosition ( target )) 
            end 
        end 
    end 
    addCommandHandler ( "goto", teleportarPlayer  ) 

Link to comment
player and thePlayer?

sorry had not seen it I will test now

@edit

came to nothing

code:

function teleportarPlayer (player, CMD, targetName) 
local accName = getAccountName ( getPlayerAccount ( player ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then   
        if not targetName then 
            outputChatBox("Uso Correto: /goto nick") 
        else 
            local target = getPlayerFromName (targetName ) 
            if not target then -- check if the name is valit 
                outputChatBox("ERRO: Jogador não encontra-se online!") 
            else 
                local x,y,z = getElementPosition ( target ) 
                setElementPosition ( player,x,y,z+1) 
                --setElementPosition ( player, getElementPosition ( target )) 
            end 
        end 
    end 
    addCommandHandler ( "goto", teleportarPlayer  ) 

Link to comment
function teleportarPlayer (player, CMD, targetName) 
local accName = getAccountName ( getPlayerAccount ( player ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then   
        if not targetName then 
            outputChatBox("Uso Correto: /goto nick") 
        else 
            local target = getPlayerFromName (targetName ) 
            if not target then -- check if the name is valit 
                outputChatBox("ERRO: Jogador não encontra-se online!") 
            else 
                local x,y,z = getElementPosition ( target ) 
                setElementPosition ( player,x,y,z+1) 
                --setElementPosition ( player, getElementPosition ( target )) 
            end 
        end 
    end 
end 
addCommandHandler ( "goto", teleportarPlayer  ) 

Link to comment
function teleportarPlayer (player, CMD, targetName) 
    local accountName = getAccountName(getPlayerAccount(player)) 
    if isObjectInACLGroup("user."..accountName , aclGetGroup("Admin")) then 
        if not targetName then 
            outputChatBox("Uso Correto: /goto nick") 
        else 
            local target = getPlayerFromName (targetName ) 
            if not target then -- check if the name is valit 
                outputChatBox("ERRO: Jogador não encontra-se online!") 
            else 
                local x,y,z = getElementPosition ( target ) 
                setElementPosition ( player,x,y,z+1) 
                --setElementPosition ( player, getElementPosition ( target )) 
            end 
        end 
    end 
end 
addCommandHandler ( "goto", teleportarPlayer  ) 
  

Tested and works!

NOTE: Must be serverside.

Link to comment

And for your script:

  
function teleportarPlayer ( source, posX, posY, posZ ) 
        getPlayerFromName ( source ) 
        getElementPosition ( source ) 
        setElementPosition ( source, posX, posY, posZ ) 
    end 
    addCommandHandler ( "goto", teleportarPlayer  ) 
  

source is not able to use it as paramater. change source -> theplayer or else.

player (element) = getPlayerFromName(thePlayer or else) you get a player you can use but thePlayer or else is already a player which use the command.

x,y,z = getElementPosition(thePlayer or else) you`ll get the position of the player but not needed here.

setElementPosition(thePlayer or else, tonumber(posX), tonumber(posY), tonumber(posZ)) tonumber() becouse you give a string ( a text ) and text is not a Integer ;)

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...