Giovany Mito Posted July 5, 2019 Posted July 5, 2019 Hello, I'm a beginner on the Lua, I need help with a script, I want to pull a player to me, example / bring (ID PLAYER) So I would bring a single player to me
DNL291 Posted July 5, 2019 Posted July 5, 2019 addCommandHandler getElementPosition setElementPosition
Giovany Mito Posted July 5, 2019 Author Posted July 5, 2019 I already read about it but can not start the command only from the wrong, would not you have a base to see? 1 hour ago, DNL291 said: addCommandHandler getElementPosition setElementPosition I already read about it but can not start the command only from the wrong, would not you have a base to see?
Dimos7 Posted July 5, 2019 Posted July 5, 2019 We can't give you code we are here to help you learn and imporve your code not make it for you if you want a ready resource here is wrong section
Giovany Mito Posted July 5, 2019 Author Posted July 5, 2019 (edited) I'm very beginner, I tried to make this script more did not work function getPlayer(player, cmd, player2nick) local mx, my, mz = getElementPosition(player) local player2 = getPlayerFromID ( player2nick ) for i,v in ipairs(getElementsByType("player2nick")) do local rand = math.random(1, 5) setElementPosition(v, mx+rand, my+rand, mz) end end addCommandHandler("pux", getPlayer) Edited July 5, 2019 by giovanymito
Giovany Mito Posted July 5, 2019 Author Posted July 5, 2019 14 hours ago, Dimos7 said: We can't give you code we are here to help you learn and imporve your code not make it for you if you want a ready resource here is wrong section
DNL291 Posted July 6, 2019 Posted July 6, 2019 function getPlayer(player, cmd, id) if tonumber(id) then local mx, my, mz = getElementPosition(player) local player2 = getPlayerFromID ( tonumber(id) ) if not player2 or not isElement(player2) then return outputChatBox( "player not found", player ) end local rand = math.random(1, 5) setElementPosition(player2, mx+rand, my+rand, mz + 1) end end addCommandHandler("pux", getPlayer) Try it P.S: You need to have getPlayerFromID function in your code. 1
Giovany Mito Posted July 6, 2019 Author Posted July 6, 2019 (edited) 1 hour ago, DNL291 said: function getPlayer(player, cmd, id) if tonumber(id) then local mx, my, mz = getElementPosition(player) local player2 = getPlayerFromID ( tonumber(id) ) if not player2 or not isElement(player2) then return outputChatBox( "player not found", player ) end local rand = math.random(1, 5) setElementPosition(player2, mx+rand, my+rand, mz + 1) end end addCommandHandler("pux", getPlayer) Try it P.S: You need to have getPlayerFromID function in your code. I will test 1 hour ago, DNL291 said: function getPlayer(player, cmd, id) if tonumber(id) then local mx, my, mz = getElementPosition(player) local player2 = getPlayerFromID ( tonumber(id) ) if not player2 or not isElement(player2) then return outputChatBox( "player not found", player ) end local rand = math.random(1, 5) setElementPosition(player2, mx+rand, my+rand, mz + 1) end end addCommandHandler("pux", getPlayer) Try it P.S: You need to have getPlayerFromID function in your code. [2019-07-06 00:09:22] SCRIPT ERROR: [FW]Comandpux/Server.Lua:12: unexpected symbol near '�' [2019-07-06 00:09:22] ERROR: Loading script failed: [FW]Comandpux/Server.Lua:12: unexpected symbol near '�' Edited July 6, 2019 by giovanymito
DNL291 Posted July 6, 2019 Posted July 6, 2019 Hm, this code looks fine from what I see. Try copying the code from here: https://pastebin.com/c9jyKy5y 1
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