Jump to content

Ajuda isPlayerInACL???


Recommended Posts

Posted
addCommandHandler("a",
function(playerSource)
	if hasObjectPermissionTo(playerSource,"command.run",true) then
		for i, v in ipairs(getElementsByType("player")) do
			if not isPedInVehicle(v) then
				if getElementData(v,"frozenped") == "false" or not getElementData(v,"frozenped") then
					setElementFrozen(v,true)
					toggleAllControls(v,false)
					setElementData(v,"frozenped","true")
					outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴊᴏɢᴀᴅᴏʀᴇs ғᴏʀᴀᴍ ᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,255,0,0,true)
				else
					setElementFrozen(v,false)
					toggleAllControls(v,true)
					setElementData(v,"frozenped","false")
					outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴘʟᴀʏᴇʀs ғᴏʀᴀᴍ ᴅᴇsᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,0,255,0,true)
				end
			else
				if getElementData(v,"frozenveh") == "false" or not getElementData(v,"frozenveh") then
					setElementFrozen(getPedOccupiedVehicle(v),true)
					setElementData(v,"frozenveh","true")
					outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴊᴏɢᴀᴅᴏʀᴇs ғᴏʀᴀᴍ ᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,255,0,0,true)
				elseif getElementData(v,"frozenveh") == "true" then
					setElementFrozen(getPedOccupiedVehicle(v),false)
					setElementData(v,"frozenveh","false")
					outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴘʟᴀʏᴇʀs ғᴏʀᴀᴍ ᴅᴇsᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,0,255,0,true)
				end
			end
		end
	elseif hasObjectPermissionTo(playerSource,"command.run",false) then
		outputChatBox("[WARNING]: #FFFFFFDesculpe,você não tem permisssão para congelar todos os jogadores!",playerSource,255,0,0,true)
	end
end 
)

Olá,

Este recurso congela todos jogadores do server...

Queria que NÃO congelasse os que estão em determinadas acl's: Admin, RPC, Console, etc...

Então usaria?

isPlayerInACL

 

Posted

Sim, porém essa função não faz parte do MTA e você precisa copiar ela dentro do seu script.

Tente:


local acls = { "Admin", "RPC", "Console"  }

addCommandHandler("a",
function(playerSource)
	if hasObjectPermissionTo(playerSource,"command.run",true) then
		for i, v in ipairs(getElementsByType("player")) do
			if canFreezePlayer( v ) then
				setFrozen( v, playerSource )
			end
		end
	elseif hasObjectPermissionTo(playerSource,"command.run",false) then
		outputChatBox("[WARNING]: #FFFFFFDesculpe,você não tem permisssão para congelar todos os jogadores!",playerSource,255,0,0,true)
	end
end
)

function setFrozen( v, playerSource )
	if not isPedInVehicle(v) then
		if getElementData(v,"frozenped") == "false" or not getElementData(v,"frozenped") then
			setElementFrozen(v,true)
			toggleAllControls(v,false)
			setElementData(v,"frozenped","true")
			outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴊᴏɢᴀᴅᴏʀᴇs ғᴏʀᴀᴍ ᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,255,0,0,true)
		else
			setElementFrozen(v,false)
			toggleAllControls(v,true)
			setElementData(v,"frozenped","false")
			outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴘʟᴀʏᴇʀs ғᴏʀᴀᴍ ᴅᴇsᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,0,255,0,true)
		end
	else
		if getElementData(v,"frozenveh") == "false" or not getElementData(v,"frozenveh") then
			setElementFrozen(getPedOccupiedVehicle(v),true)
			setElementData(v,"frozenveh","true")
			outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴊᴏɢᴀᴅᴏʀᴇs ғᴏʀᴀᴍ ᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,255,0,0,true)
		elseif getElementData(v,"frozenveh") == "true" then
			setElementFrozen(getPedOccupiedVehicle(v),false)
			setElementData(v,"frozenveh","false")
			outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴘʟᴀʏᴇʀs ғᴏʀᴀᴍ ᴅᴇsᴄᴏɴɢᴇʟᴀᴅᴏs ᴘᴏʀ: "..getPlayerName(playerSource).."!",v,0,255,0,true)
		end
	end
end

function canFreezePlayer( player )
	for i, group in ipairs(acls) do
		if isPlayerInACL(player, group) then
			return false
		end
	end
	return true
end

function isPlayerInACL(player, acl)
	if isElement(player) and getElementType(player) == "player" and aclGetGroup(acl or "") and not isGuestAccount(getPlayerAccount(player)) then
		local account = getPlayerAccount(player)
		
		return isObjectInACLGroup( "user.".. getAccountName(account), aclGetGroup(acl) )
	end
	return false
end

 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
local acls = { "Admin", "RPC", "Console"  }

Quem está dentro destas acl não conseguem usar o comando, mas quem tá fora sim. não mostra aviso no debugscript

O que há de errado?

Posted

Tente isto:


local acls = { "Admin", "RPC", "Console" }
local allFrozen = false

addCommandHandler("a",
function(player)
	if isPlayerInACL(player, "Admin") or isPlayerInACL(player, "SuperModerator") or isPlayerInACL(player, "Moderator") then
		for i, v in ipairs(getElementsByType("player")) do
			if canFreezePlayer( v ) then
				setFrozen( v )
			end
		end

		allFrozen = not allFrozen
		outputChatBox("[WARNING]: #FFFFFFTᴏᴅᴏs ᴏs ᴊᴏɢᴀᴅᴏʀᴇs ғᴏʀᴀᴍ ".. (allFrozen and "ᴄᴏɴɢᴇʟᴀᴅᴏs" or "ᴅᴇsᴄᴏɴɢᴇʟᴀᴅᴏs") .." ᴘᴏʀ: "..getPlayerName(player).."!",root,255,0,0,true)
	else
		outputChatBox("[WARNING]: #FFFFFFDesculpe,você não tem permisssão para congelar todos os jogadores!",player,255,0,0,true)
	end
end
)

function setFrozen( v )
	if not isPedInVehicle(v) then
		if getElementData(v,"frozenped") == "false" or not getElementData(v,"frozenped") then
			setElementFrozen(v,true)
			toggleAllControls(v,false)
			setElementData(v,"frozenped","true")
		else
			setElementFrozen(v,false)
			toggleAllControls(v,true)
			setElementData(v,"frozenped","false")
		end
	else
		if getElementData(v,"frozenveh") == "false" or not getElementData(v,"frozenveh") then
			setElementFrozen(getPedOccupiedVehicle(v),true)
			setElementData(v,"frozenveh","true")
		elseif getElementData(v,"frozenveh") == "true" then
			setElementFrozen(getPedOccupiedVehicle(v),false)
			setElementData(v,"frozenveh","false")
		end
	end
end

addEventHandler( "onResourceStop", resourceRoot, function()
	for i, v in ipairs(getElementsByType("player")) do

		if getElementData(v,"frozenped") == "true" then
			setElementFrozen(v,false)
			toggleAllControls(v,true)
			setElementData(v,"frozenped","false")
		end
		
		if getElementData(v,"frozenveh") == "true" then
			setElementFrozen(getPedOccupiedVehicle(v),false)
			setElementData(v,"frozenveh","false")
		end
	end
end )

function canFreezePlayer( player )
	for i, group in ipairs(acls) do
		if isPlayerInACL(player, group) then
			return false
		end
	end
	return true
end

function isPlayerInACL(player, acl)
	if isElement(player) and getElementType(player) == "player" and aclGetGroup(acl or "") and not isGuestAccount(getPlayerAccount(player)) then
		local account = getPlayerAccount(player)
		
		return isObjectInACLGroup( "user.".. getAccountName(account), aclGetGroup(acl) )
	end
	return false
end

 

Please do not PM me with scripting related question nor support, use the forums instead.

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