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:
Kind regards,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)
t0kenz
Solved In need of some help with "my plugin"
Discussion in 'Rust Development' started by t0kenz, Feb 7, 2016.
-
Wulf Community Admin
Code:rust.SendChatMessage(player, "<color=#c58016>Admins online:</color> t0kenz, t0kenz1, t0kenz2\nt0kenz3,t0kenz4...")
-
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 -
Wulf Community Admin
-
Or, is it as easy as you told me it'd be, or is that simply one part of the whole command function? -
Wulf Community Admin
-
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
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 -
Wulf Community Admin
Sorry, I was away at a movie screening. Glad you got it worked out though!