Jump to content

Warp player to


231

Recommended Posts

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
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 by <~KaMiKaZe~>
Link to comment
  • Scripting Moderators
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
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
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 by OpenAI
Link to comment

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

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