Jump to content

[HELP] isObjectInACLGroup Client.Lua


DigDim

Recommended Posts

Hello guys, I'm new to the moon, I come from another plant and I'm used to programming in pawn, moon is very new to me.

I would like some help, I am not able to use the "isObjectInACLGroup" function on the client.Lua side, I should use it on server.Lua but I have no idea how to use it.

Can anybody help me ?
Thanks in advance.

 

Client.Lua

 

function FomeRepeat()

	if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Staff")) then -- This check does not work
	
		if getElementData ( localPlayer, "afkdate" ) == true then return end

		if getElementData ( localPlayer, "Fome:Logado" ) == true then

			Fome = getElementData ( localPlayer, "AirNew:Fome" ) -1
			SetarFome = setElementData ( localPlayer, "AirNew:Fome", Fome )

			if Fome <= 0 then
				setElementData ( localPlayer, "AirNew:Fome", 10 )
				setElementHealth ( localPlayer, 0 )
				outputChatBox ( "[ Fome ] - Você Morreu de Fome", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer Novamente", 255, 255, 255, true )
			end
			
			if Fome == 5 then
				outputChatBox ( "[ Fome ] - Você Esta com Fome e Precisa Comer", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer de Fome", 255, 255, 255, true )
				playSoundFrontEnd ( 45 )
			end

		end
	end	
end
setTimer(FomeRepeat,FomeTempo,0)

 

Edited by DigDim
Link to comment

if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Staff")) then
all that need sever side ;p not client side you can use
https://wiki.multitheftauto.com/wiki/TriggerClientEvent

to trigger your function if if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("Staff")) then   all that == true

--ServerSide

function ServerFomeRepeat()
    if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(client)), aclGetGroup ("Staff")) then
    	    triggerClientEvent ( client, "FomeRepeat", client)
    end
  
end
setTimer(ServerFomeRepeat,1000,1)

--clientSide
function FomeRepeat()    
  if getElementData ( localPlayer, "afkdate" ) == true then return end

  if getElementData ( localPlayer, "Fome:Logado" ) == true then

    Fome = getElementData ( localPlayer, "AirNew:Fome" ) -1
    SetarFome = setElementData ( localPlayer, "AirNew:Fome", Fome )

    if Fome <= 0 then
      setElementData ( localPlayer, "AirNew:Fome", 10 )
      setElementHealth ( localPlayer, 0 )
      outputChatBox ( "[ Fome ] - Você Morreu de Fome", 255, 255, 255, true )
      outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer Novamente", 255, 255, 255, true )
    end

    if Fome == 5 then
      outputChatBox ( "[ Fome ] - Você Esta com Fome e Precisa Comer", 255, 255, 255, true )
      outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer de Fome", 255, 255, 255, true )
      playSoundFrontEnd ( 45 )
    end

  end
end
addEvent("FomeRepeat",true)
addEventHandler("FomeRepeat",root,FomeRepeat)

somthing like that

Link to comment

Dear DigDim,

if you restart the resource each time you update the ACL then you can just send the ACL info from server to client.

server.Lua

addEvent("onPlayerReady", true);
addEventHandler("onPlayerReady", resourceRoot,
  function()
    local has_staff = isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(client)), aclGetGroup ("Staff"));
    
    triggerClientEvent(client, "onClientReceivePermissions", resourceRoot, has_staff);
  end, false
);

client.Lua

local has_got_perms = false;
local is_staff = false;

function FomeRepeat()

	if is_staff then
	
		if getElementData ( localPlayer, "afkdate" ) == true then return end

		if getElementData ( localPlayer, "Fome:Logado" ) == true then

			Fome = getElementData ( localPlayer, "AirNew:Fome" ) -1
			SetarFome = setElementData ( localPlayer, "AirNew:Fome", Fome )

			if Fome <= 0 then
				setElementData ( localPlayer, "AirNew:Fome", 10 )
				setElementHealth ( localPlayer, 0 )
				outputChatBox ( "[ Fome ] - Você Morreu de Fome", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer Novamente", 255, 255, 255, true )
			end
			
			if Fome == 5 then
				outputChatBox ( "[ Fome ] - Você Esta com Fome e Precisa Comer", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer de Fome", 255, 255, 255, true )
				playSoundFrontEnd ( 45 )
			end

		end
	end	
end

addEvent("onClientReceivePermissions", true);
addEventHandler("onClientReceivePermissions", resourceRoot, function(_is_staff)
    has_got_perms = true;
    is_staff = _is_staff;
    
    outputDebugString( "received client permissions (is_staff: " .. tostring(_is_staff) .. ")" );
    
    setTimer(FomeRepeat,FomeTempo,0)
  end, false
);

triggerServerEvent("onPlayerReady", resourceRoot);

 

Edited by The_GTA
  • Like 1
Link to comment
On 3/22/2020 at 5:37 PM, The_GTA said:

Dear DigDim,

if you restart the resource each time you update the ACL then you can just send the ACL info from server to client.

server.Lua


addEvent("onPlayerReady", true);
addEventHandler("onPlayerReady", resourceRoot,
  function()
    local has_staff = isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(client)), aclGetGroup ("Staff"));
    
    triggerClientEvent(client, "onClientReceivePermissions", resourceRoot, has_staff);
  end, false
);

client.Lua


local has_got_perms = false;
local is_staff = false;

function FomeRepeat()

	if is_staff then
	
		if getElementData ( localPlayer, "afkdate" ) == true then return end

		if getElementData ( localPlayer, "Fome:Logado" ) == true then

			Fome = getElementData ( localPlayer, "AirNew:Fome" ) -1
			SetarFome = setElementData ( localPlayer, "AirNew:Fome", Fome )

			if Fome <= 0 then
				setElementData ( localPlayer, "AirNew:Fome", 10 )
				setElementHealth ( localPlayer, 0 )
				outputChatBox ( "[ Fome ] - Você Morreu de Fome", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer Novamente", 255, 255, 255, true )
			end
			
			if Fome == 5 then
				outputChatBox ( "[ Fome ] - Você Esta com Fome e Precisa Comer", 255, 255, 255, true )
				outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer de Fome", 255, 255, 255, true )
				playSoundFrontEnd ( 45 )
			end

		end
	end	
end

addEvent("onClientReceivePermissions", true);
addEventHandler("onClientReceivePermissions", resourceRoot, function(_is_staff)
    has_got_perms = true;
    is_staff = _is_staff;
    
    outputDebugString( "received client permissions (is_staff: " .. tostring(_is_staff) .. ")" );
    
    setTimer(FomeRepeat,FomeTempo,0)
  end, false
);

triggerServerEvent("onPlayerReady", resourceRoot);

 

 

 

Hello The_GTA, yours worked perfectly, but this is a system of hunger and thirst, and I would like to invert this verification, the way that just being staff loses hunger and thirst, as I do to invert and put for staff not to lose hunger and thirst.

Link to comment
8 hours ago, DigDim said:

Hello The_GTA, yours worked perfectly, but this is a system of hunger and thirst, and I would like to invert this verification, the way that just being staff loses hunger and thirst, as I do to invert and put for staff not to lose hunger and thirst.

In client.Lua replace line 7 with

	if not is_staff then

This way FomeRepeat does never execute for staff members, under the same condition as mentioned in my previous post.

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