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

Nice Tutorial Man

Keeb it Going ^_^

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

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

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

Posted

My opinion is that it should return a table with every group and their group members.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • 2 years later...
Posted

Thank you for this nyc tutorial, i'm learning lua, helped me alot!

Looking for a developer? Feel free to PM me :)

  • Recently Browsing   0 members

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