1. Hiho,

    I've recently started getting more and more interested in oxide plugins, and therefore decided to make me one myself as a learning opportunity. I've written some lua before, but in a different game with different functions etc.

    I have some problems understanding what exactly I should write to execute my idea. I want it to print in colors e.g <color=#5F8D4D>[AdminsOnline]</color> <color=#c58016>Admins online:</color> t0kenz, t0kenz1, t0kenz2\nt0kenz3,t0kenz4...

    What i've written so far:
    Code:
    PLUGIN.Title        = "Admin list"
    PLUGIN.Description  = "Shows online admins"
    PLUGIN.Author       = "t0kenz"
    PLUGIN.Version      = V(0, 0, 1)function PLUGIN:Init()
        command.AddChatCommand("admins", self.Object, "cmdAdmins")
        permission.RegisterPermission("permission.online.admins", self.Plugin)
    endlocal function IsAdmin(player)
        return player:GetComponent("BaseNetworkable").net.connection.authLevel > 1
    endlocal function HasPermission(steamId, perm)
        if permission.UserHasPermission(steamId, perm) then return true end
        return false
    endfunction PLUGIN:cmdAdmins(player)
    Kind regards,

    t0kenz
     
    Last edited by a moderator: Feb 7, 2016
  2. Wulf

    Wulf Community Admin

    Code:
    rust.SendChatMessage(player, "<color=#c58016>Admins online:</color> t0kenz, t0kenz1, t0kenz2\nt0kenz3,t0kenz4...")
     
  3. Not sure if you understood what I meant, and i'm sorry for being too unprecise.

    I'm aware I need to send that to the player, but I want it to happen once you execute the command /admins, then it prints that message.
    I know i'm supposed to use function PLUGIN:cmdAdmins(player)
    but after that, i'm a bit stuck.

    Hope you can assist me better with that said!

    Kind regards,

    t0kenz
     
  4. Wulf

    Wulf Community Admin

    What I gave you goes inside your command function, so when they use the command, it will show the message.
     
  5. I'd like it to list all admins online, not the exact message. When I meant t0kenz, t0kenz1, t0kenz2 I was talking about it listing 3 admins per "row". e.g /admins = [AdminsOnline] Admins online: FirstOnlineAdmin, SecondOnlineAdmin ...

    Or, is it as easy as you told me it'd be, or is that simply one part of the whole command function?
     
  6. Wulf

    Wulf Community Admin

    I'd recommend taking a look at the existing Player List for Rust plugin for an idea of how it works. What I gave you was just the chat sending portion.
     
  7. I contacted @Domestos about my issue. He responded with possible "solutions" that he claimed to be outdated.
    Code:
    PLUGIN.Title = "Admin list"
    PLUGIN.Description = "Shows online admins"
    PLUGIN.Author = "t0kenz"
    PLUGIN.Version = V(0, 0, 1)function PLUGIN:Init()
    command.AddChatCommand("admins", self.Object, "cmdAdmins")
    permission.RegisterPermission("permission.online.admins", self.Plugin)
    endlocal function IsAdmin(player)
    return player:GetComponent("BaseNetworkable").net.connection.authLevel > 1
    endlocal function HasPermission(steamId, perm)
    if permission.UserHasPermission(steamId, perm) then return true end
    return false
    endfunction PLUGIN:cmdAdmins(player)
    if not player then return end
    local playerList = player.activePlayerList
    local enum = playerList:GetEnumerator()
    local playerCount, adminCount, allCount = 0, 0, 0
    local playerString, adminString = "", ""
    local playerStringTbl, adminStringTbl = {}, {}
    local i = 0
    local maxPlayersPerLine = 3
    while enum:MoveNext() do
    if IsAdmin(enum.Current) then
    adminCount = adminCount + 1
    allCount = allCount + 1
    adminString = adminString..enum.Current.displayName..", "
    if adminCount == maxPlayersPerLine then
    adminStringTbl[i + 1] = adminString
    adminString = ""
    i = i + 1
    end
    else
    playerCount = playerCount + 1
    allCount = allCount + 1
    playerString = playerString..enum.Current.displayName..", "
    if playerCount == maxPlayersPerLine then
    playerStringTbl[i + 1] = playerString
    playerString = ""
    i = i + 1
    end
    end
    end
    if allCount == 1 then
    rust.SendChatMessage(player, " You are the only one online")
    return
    end
    -- remove comma at the end
    if string.sub(playerString, -2, -2) == "," then
    playerString = string.sub(playerString, 1, -3)
    end
    if string.sub(adminString, -2, -2) == "," then
    adminString = string.sub(adminString, 1, -3)
    end
    -- Build admin message
    if adminCount == 0 then
    rust.SendChatMessage(player, "No Admins Online")
    else
    local msg = string.gsub("{count} admins online: ", "{count}", tostring(adminCount))
    rust.SendChatMessage(player, msg)if #adminStringTbl >= 1 then
    local msg = string.gsub("{count} admins online: ", "{count}", tostring(adminCount))
    rust.SendChatMessage(player, msg)
    for i = 1, #adminStringTbl, 1 do
    rust.SendChatMessage(player, adminStringTbl)
    end
    rust.SendChatMessage(player, adminString)
    else
    local msg = string.gsub("{count} admins online: ", "{count}", tostring(adminCount))
    rust.SendChatMessage(player, msg..adminString)
    end
    end
    end
    It's meant to check only Admins online, but it doesn't care neither for permission nor if you're an admin or not.
    Any ideas? @Wulf

    kind regards,

    t0kenz
    [DOUBLEPOST=1455068664][/DOUBLEPOST]Nevermind, figured out a solution. Thanks anyhow!
    [DOUBLEPOST=1455068686][/DOUBLEPOST]Feel free to close this thread.
     
    Last edited by a moderator: Feb 10, 2016
  8. Wulf

    Wulf Community Admin

    Sorry, I was away at a movie screening. Glad you got it worked out though!