Jump to content

[CODE] getOnlineAdmins()


Recommended Posts

Posted (edited)

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
Posted

If you want the online ADMINS, I would suggest to check for the "command.ban" permission.

Because this code applies to mods, smods and admins.

Posted

Cool.

@Castillo. How do I create a new wiki page... I've looked and looked... I would love this in the useful functions. First ill add more features.

@Ben, my script was meant to be returning all admins/mods/smods.

Posted
@Ben, my script was meant to be returning all admins/mods/smods.

In that case, getOnlineStaffMembers() would make more sense.

Posted

Just type in search the new page title and click search, if it exists it will show you the page's link, if it doesn't, it will show you "Create this page".

  • 2 years later...
  • Recently Browsing   0 members

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