231 Posted April 6, 2019 Share Posted April 6, 2019 addCommandHandler("easr",function(_, player) players = getElementsByType ( "player" ) for i,v in ipairs(players) do setElementPosition ( source, posX, posY, posZ ) end end) What can be my fault I want to attract all players Link to comment
KaMi Posted April 6, 2019 Share Posted April 6, 2019 (edited) 9 minutes ago, 231 said: addCommandHandler("easr",function(_, player) players = getElementsByType ( "player" ) for i,v in ipairs(players) do setElementPosition ( source, posX, posY, posZ ) end end) What can be my fault I want to attract all players source, posX, posY, posZ are null Edited April 6, 2019 by <~KaMiKaZe~> Link to comment
Sendy Posted April 6, 2019 Share Posted April 6, 2019 (edited) addCommandHandler("easr", function() players = getElementsByType("player") for i,v in ipairs(players) do setElementPosition(v, posX, posY, posZ) end end) Edited April 6, 2019 by Sendy Link to comment
Scripting Moderators ds1-e Posted April 7, 2019 Scripting Moderators Share Posted April 7, 2019 3 hours ago, Sendy said: addCommandHandler("easr", function() players = getElementsByType("player") for i,v in ipairs(players) do setElementPosition(v, posX, posY, posZ) end end) Want to teleport players to you? If so then: addCommandHandler("easr", function(cmd, player) local players = getElementsByType("player") local posX, posY, posZ = getElementPosition(player) for i, v in pairs(players) do setElementPosition(v, posX + math.random(5, 10), posY, posZ) end end) Link to comment
231 Posted April 7, 2019 Author Share Posted April 7, 2019 Thanks everyone 5 hours ago, majqq said: Want to teleport players to you? If so then: addCommandHandler("easr", function(cmd, player) local players = getElementsByType("player") local posX, posY, posZ = getElementPosition(player) for i, v in pairs(players) do setElementPosition(v, posX + math.random(5, 10), posY, posZ) end end) server.lua:3: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'easr'] server.lua:5: attempt to perform arithmetic on local 'posX' (a boolean value) Link to comment
OpenAI Posted April 7, 2019 Share Posted April 7, 2019 (edited) addCommandHandler( "easr", function( thePlayer ) local players = getElementsByType( "player" ) local posX, posY, posZ = getElementPosition( thePlayer ) for i, v in pairs( players ) do setElementPosition(v, posX + math.random(5, 10), posY, posZ) end end ) try this Edited April 7, 2019 by OpenAI Link to comment
Ab-47 Posted April 7, 2019 Share Posted April 7, 2019 Or you could just do this.. addCommandHandler("easr", function() local sx, sy, sz = getElementPosition(source) for i, v in pairs(getElementsByType("player")) do setElementPosition(v, sx + math.random(5, 10), sy, sz) end end ) Link to comment
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