Jump to content

[Help]WarpAllPlayers


PyTrO

Recommended Posts

Posted

hello, i want to warp all players so i made this but it didnt work 

with account allowed

local Access = {
["None"] = true,
["*-*"] = true,
}

function warpall()
for  players in ipairs(getElementsByType("player")) do
local paccount = getPlayerAccount(source)
	if paccount and not isGuestAccount(paccount) and Access[getAccountName(paccount)] then
local x3,y3,z3 = getElementPosition(source)
setElementPosition ( players, x3, y3, z3 )
end 
end
end
addCommandHandler("warpall", warpall)

 

Posted

I have re-written the code and cleaned it up a bit for you, not tested though but should work:

local Access = {
    ["None"] = true,
    ["*-*"] = true,
}
	
function warpall(playerSource)
    if (Access[getAccountName(getPlayerAccount(playerSource))]) then
        local x, y, z = getElementPosition(playerSource)
        for i, player in ipairs(getElementsByType("player")) do
            setElementPosition(player, x, y, z)
        end
    end
end
addCommandHandler("warpall", warpall)

Posted
local Access = {
	["None"] = true,
	["*-*"] = true,
}

function warpAll(player)
	local account = getPlayerAccount(player)
	if not account or isGuestAccount(account) then return false end 
	if not (Access[getAccountName(account)]) then return false end --You can output an error here as well, as long as you use return to stop the function.
	
	for i, player in ipairs(getElementsByType("player")) do
		local x,y,z = getElementPosition(player)
		setElementPosition(player,x+math.random(-3,3),y+math.random(-3,3),z)
	end
end
addCommandHandler("warpall",warpAll)

Here yah go, enjoy.

  • Like 2

Founder of Kutmode - http://kutmode.com | https://discord.gg/P3FXVnF

(Retired) Leading Developer of Grand Theft International

(Retired) Leading Developer of Full Theft Auto.

(Retired) Owner of SourceMod.

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