Jump to content

[Ajuda] Grupo ACL


Recommended Posts

Eu estou a tentar atribuir alguma data a jogadores que sejam colocados em um determinando grupo de ACL. Mas sem sucesso, tem alguma coisa errada com este código?

function aclpm (thePlayer)
	accName = getAccountName (getPlayerAccount (thePlayer))
    if isObjectInACLGroup("user."..accName, aclGetGroup ("PM")) and getElementType(thePlayer) == "player" then
		thePlayer:setData("Venda:Police.Job", true);
		thePlayer:getAccount():setData("Venda:Police.Job", thePlayer:getData("Venda:Police.Job"));
	end
end

 

Link to comment

Tente isso.

function aclpm (thePlayer)
	local Account = getPlayerAccount (thePlayer)
	local accName = getAccountName (getPlayerAccount (thePlayer))
    if isObjectInACLGroup("user."..accName, aclGetGroup ("Console")) then
		setAccountData(Account, "Venda:Police.Job", true)
	end
end

 

  • Thanks 1
Link to comment
  • Other Languages Moderators
function aclpm (thePlayer)
	if thePlayer and getElementType (thePlayer) == "player" then
		if isObjectInACLGroup ("user."..getAccountName (getPlayerAccount (thePlayer)), aclGetGroup ("Console")) then
			setElementData (thePlayer, "Venda:Police.Job", true)
			setAccountData (getPlayerAccount (thePlayer), "Venda:Police.Job", true)
		end
	end
end

@GodKraken

Não use OOP se você não tem conhecimento avançado o suficiente.

Edited by Lord Henry
  • Thanks 1
Link to comment
48 minutes ago, Lord Henry said:

function aclpm (thePlayer)
	if thePlayer and getElementType (thePlayer) == "player" then
		if isObjectInACLGroup ("user."..getAccountName (getPlayerAccount (thePlayer)), aclGetGroup ("Console")) then
			setElementData (thePlayer, "Venda:Police.Job", true)
			setAccountData (getPlayerAccount (thePlayer), "Venda:Police.Job", true)
		end
	end
end

@GodKraken

Não use OOP se você não tem conhecimento avançado o suficiente.

Obrigado a ambos, porém não resultou. Este Script está totalmente em OOP não sei se isso pode interferir com essa função.

O que quero que funcione é isto

addEventHandler("onElementDataChange", root,
	function (dataName, oldValue)
		if (source:getType("player") and dataName == "Venda:Police.Job" and source:getData(dataName)) then
			setElementVisibleTo(Boxs["Markers"]["Create"]["Skins"], source, true);
			outputChat(source, "Parabens! Você agora é um Policial, para saber tudo sobre a profissão(como prender, viaturas, muito mais), pressione o botão 'k'", "warning")
			giveWeapon(source, 31, 5000);
			giveWeapon(source, 24, 5000);
			giveWeapon(source, 3);
			triggerClientEvent(source, getThisResource():getName()..": 3DText", root, "Seleção de Skins", Boxs["Markers"]["Create"]["Skins"]);
		elseif (source:getType("player") and dataName == "Venda:Police.Job" and not source:getData(dataName)) then
			takeWeapon(source, 31);
			takeWeapon(source, 24);
			takeWeapon(source, 3);
			setElementVisibleTo(Boxs["Markers"]["Create"]["Skins"], source, false);
		end
	end
)

Ou seja, isso vai buscar a dataname = Venda.Police.Job para que funcione e também queria fazê-lo por ACL mas não está a setar essa data. :( 

Link to comment
2 hours ago, Lord Henry said:

Sim. Vai interferir.

function aclpm (theElem)
	if (theElem:getType("player")) then
		if aclgroup:doesContainObject ("user."..theElem:getName (theElem:getAccount ()),  ACLGroup.get ("PM")) then
			theElem:setData("Venda:Police.Job", true)
			theElem:getAccount():setData("Venda:Police.Job", theElem:getData("Venda:Police.Job", true))
		end
	end
end

Coloquei a função da ACL em programação OOF, mas não funcionou. Ainda não seta a data :( 

Obrigado pela ajuda até agora ❤️ 

Link to comment

Você habilitou o OOP no meta.xml ?

<oop>true</oop>
3 hours ago, GodKraken said:

Este Script está totalmente em OOP não sei se isso pode interferir com essa função.

Não interfere (no seu caso), mas não recomendo ficar misturando trechos procedural com oop, opte por um e siga até o fim.

Tente:

function aclpm (thePlayer)
	if (thePlayer.type == "player") then
		local acc = thePlayer.account;
		if acc and not acc.guest then
			if ACLGroup.get("PM"):doesContainObject("user."..acc.name) then 
				thePlayer:setData("Venda:Police.Job", true);
				acc:setData("Venda:Police.Job", true);
			end
		end
	end
end

addEventHandler("onElementDataChange", root,
	function (dataName, oldValue)
		if (source.type == "player" and dataName == "Venda:Police.Job") then
			if (source:getData(dataName)) then
				Boxs["Markers"]["Create"]["Skins"]:setVisibleTo(source, true);
				source:outputChat("Parabens! Você agora é um Policial, para saber tudo sobre a profissão(como prender, viaturas, muito mais), pressione o botão 'k'");
				giveWeapon(source, 31, 5000);
				giveWeapon(source, 24, 5000);
				giveWeapon(source, 3);
				source:triggerEvent(getThisResource():getName()..": 3DText", root, "Seleção de Skins", Boxs["Markers"]["Create"]["Skins"]);
			else
				takeWeapon(source, 31);
				takeWeapon(source, 24);
				takeWeapon(source, 3);
				Boxs["Markers"]["Create"]["Skins"]:setVisibleTo(source, false);
			end
		end
	end
)

 

  • Thanks 1
Link to comment
1 hour ago, MaligNos said:

Você habilitou o OOP no meta.xml ?


<oop>true</oop>

Não interfere (no seu caso), mas não recomendo ficar misturando trechos procedural com oop, opte por um e siga até o fim.

Tente:


function aclpm (thePlayer)
	if (thePlayer.type == "player") then
		local acc = thePlayer.account;
		if acc and not acc.guest then
			if ACLGroup.get("PM"):doesContainObject("user."..acc.name) then 
				thePlayer:setData("Venda:Police.Job", true);
				acc:setData("Venda:Police.Job", true);
			end
		end
	end
end

addEventHandler("onElementDataChange", root,
	function (dataName, oldValue)
		if (source.type == "player" and dataName == "Venda:Police.Job") then
			if (source:getData(dataName)) then
				Boxs["Markers"]["Create"]["Skins"]:setVisibleTo(source, true);
				source:outputChat("Parabens! Você agora é um Policial, para saber tudo sobre a profissão(como prender, viaturas, muito mais), pressione o botão 'k'");
				giveWeapon(source, 31, 5000);
				giveWeapon(source, 24, 5000);
				giveWeapon(source, 3);
				source:triggerEvent(getThisResource():getName()..": 3DText", root, "Seleção de Skins", Boxs["Markers"]["Create"]["Skins"]);
			else
				takeWeapon(source, 31);
				takeWeapon(source, 24);
				takeWeapon(source, 3);
				Boxs["Markers"]["Create"]["Skins"]:setVisibleTo(source, false);
			end
		end
	end
)

 

Obrigado pela ajuda, mas a data ainda não é setada ao jogador infelizmente. 

Link to comment
  • Moderators

Não há nenhuma restrição em usar função não-oop com oop ativada. Tente trocando por setAccountData ou mostre aonde você está chamando a função aclpm como já foi dito.

Também te recomendo a depurar seu código pra ver a execução e valores do script com output's.

  • Like 1
Link to comment
----------- ACL
function aclpm (thePlayer)
	if (thePlayer.type == "player") then
		local acc = thePlayer.account;
		if acc and not acc.guest then
			if ACLGroup.get("PM"):doesContainObject("user."..acc.name) then
				thePlayer:setData("Venda:Police.Job", true);
				acc:setData("Venda:Police.Job", true);
				thePlayer:getAccount():setData("Venda:Police.Job", thePlayer:getData("Venda:Police.Job"));
			end
		end
	end
end
--addEventHandler("onClientResourceStart", resourceRoot, aclpm)

addEventHandler("onClientResourceStart", resourceRoot,
	function (source)
		aclpm(source);
	end
)

Estou chamando quando o recurso inicia e também já tentei quando o player faz o login. Mas sem sucesso.

Obrigado pela ajuda até agora ❤️

Link to comment

Aí está o erro, você está tentando utilizar um evento cliente: onClientResourceStart em um script do servidor.

Troque por este trecho:

addEventHandler("onResourceStart", resourceRoot,
	function()
		for _, player in ipairs(getElementsByType("player")) do
			aclpm(player)
		end
	end
)

addEventHandler("onPlayerLogin", root,
	function()
		aclpm(source)
	end
)

Aconselho dar uma olhada:
https://wiki.multitheftauto.com/wiki/Scripting_Introduction#Clientside_and_Serverside_scripts
https://wiki.multitheftauto.com/wiki/Depuração

  • Thanks 1
Link to comment
2 hours ago, MaligNos said:

Aí está o erro, você está tentando utilizar um evento cliente: onClientResourceStart em um script do servidor.

Troque por este trecho:


addEventHandler("onResourceStart", resourceRoot,
	function()
		for _, player in ipairs(getElementsByType("player")) do
			aclpm(player)
		end
	end
)

addEventHandler("onPlayerLogin", root,
	function()
		aclpm(source)
	end
)

Aconselho dar uma olhada:
https://wiki.multitheftauto.com/wiki/Scripting_Introduction#Clientside_and_Serverside_scripts
https://wiki.multitheftauto.com/wiki/Depuração

Muito obrigado!! Daria 1000 Thanks mas não dá. Funcionou perfeitamente, muito muito obrigado ❤️ 

  • Like 1
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...