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, ...] - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted May 28, 2013 Moderators Posted May 28, 2013 updated, >outputChatBoxen(" ",player) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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 )
manawydan Posted May 28, 2013 Posted May 28, 2013 player and thePlayer? "Querer não é poder, mas tentar é avançar"!
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 )
manawydan Posted May 28, 2013 Posted May 28, 2013 use /debugscript 3 ( i think one "end") "Querer não é poder, mas tentar é avançar"!
DNL291 Posted May 29, 2013 Posted May 29, 2013 Is missing 'end' in your code. Please do not PM me with scripting related question nor support, use the forums instead.
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 Known Languages: [LUA][VB.NET][ASP.NET][C#][JAVA][C++] [sqlite][MSSQL][salesForce][bATCH][/center]
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