Recommended Posts

Posted (edited)

Postou no local indevido.

Na wiki tinha um exemplo basicamente pronto era só adaptar do seu gosto.

Faça assim:

local timerGetAdmins = 10

addEventHandler ("onResourceStart", resourceRoot, function ()
	timerAdmins = setTimer (function ()
		admins = ""
		for _, v in ipairs (getElementsByType ("player")) do
			local accountname = ""
			if (isGuestAccount(getPlayerAccount(v)) == false) then
				if isObjectInACLGroup ("user."..getAccountName (getPlayerAccount(v)), aclGetGroup ("Admin")) then
					if (admins == "") then
						admins = getPlayerName(v)
					else
						admins = admins .. ", " .. getPlayerName(v)
					end
				end
			end
		end
		outputChatBox ("Admins Online: #FFFFFF"..tostring(admins), root, 0, 233, 0, true)
	end, 60000 * timerGetAdmins, 0)
end)

@adrian enigma

Edited by Jonas^
  • Confused 1

Share this post


Link to post

Tente isto (não testei) :


local onlineStaff_minutes = 10

addEventHandler ("onResourceStart", resourceRoot, function ()
	setTimer (function ()
	
		local admins = {}
		for _, v in ipairs (getElementsByType ("player")) do
			if isPlayerStaff(v) then
				table.insert( admins, getPlayerName(v):gsub("#%x%x%x%x%x%x", "") )
			end
		end
		
		outputChatBox ("Admins Online: #FFFFFF"..tostring(table.concat(admins, ", ")), root, 0, 233, 0, true)
		
	end, 60000 * onlineStaff_minutes, 0)
end)

-- https://wiki.multitheftauto.com/wiki/IsPlayerStaff
local staffACLs =
{
    aclGetGroup("Admin"),
    aclGetGroup("Moderator"),
    aclGetGroup("SuperModerator"),
}

function isPlayerStaff(p)
    local acc = getPlayerAccount(p)

    if not acc then return false end
    if isGuestAccount(acc) then return false end

    local object = getAccountName(acc)

    for _,group in ipairs(staffACLs) do
        if isObjectInACLGroup("user."..object,group) then
            return true
        end
    end
    return false
end

 

Share this post


Link to post
1 hour ago, adrian enigma said:

não pego no caso

Eu testei como não pegou? lembre-se são 10 minutos não 1 minuto, foi como você pediu.

Share this post


Link to post
3 hours ago, adrian enigma said:

Gente acho que estou fazendo algo de errado estou fazendo de tudo para pegar

Você está colocando em server-side ?

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.