LucasBaker Posted May 28, 2013 Posted May 28, 2013 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 )
50p Posted May 28, 2013 Posted May 28, 2013 Because function called by command sends different arguments. player playerSource, string commandName, [string arg1, string arg2, ...]
Moderators IIYAMA Posted May 28, 2013 Moderators Posted May 28, 2013 (edited) 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 May 28, 2013 by Guest
Moderators IIYAMA Posted May 28, 2013 Moderators Posted May 28, 2013 updated, >outputChatBoxen(" ",player)
LucasBaker Posted May 28, 2013 Author Posted May 28, 2013 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 )
LucasBaker Posted May 28, 2013 Author Posted May 28, 2013 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 )
Metall Posted May 29, 2013 Posted May 29, 2013 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 )
Metall Posted May 29, 2013 Posted May 29, 2013 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.
Schlammy Posted May 29, 2013 Posted May 29, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now