Jump to content

[CODE] getOnlineAdmins()


Recommended Posts

Hey all, i've created a function which gets all online admins.

Source:

function getOnlineAdmins() 
    count = 0 
    online = "" 
    for i, v in ipairs(getElementsByType("player")) do 
        if hasObjectPermissionTo(v,"function.setPlayerMuted",true) then 
            online = getPlayerName(v).."  "..online 
            count = count+1 
        end 
    end 
    return online, count 
end 

Returns:

A string of admins, spaced out.

Example:

function getOnlineAdmins() 
    count = 0 
    online = "" 
    for i, v in ipairs(getElementsByType("player")) do 
        if hasObjectPermissionTo(v,"function.setPlayerMuted",true) then 
            online = getPlayerName(v).."  "..online 
            count = count+1 
        end 
    end 
    return online, count 
end 
  
addCommandHandler("test", 
function() 
local online, count = getOnlineAdmins() 
outputChatBox("ONLINE: ("..count..") "..online) 
end ) 

This will say in chatbox if one admin in online aka me..

ONLINE: 1 csmit195.

I hope you enjoy my source code. Take a look at my new admins resource.

https://community.multitheftauto.com/index.php?p= ... ls&id=3800

Edited by Guest
Link to comment
  • 2 years later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...