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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.