Hey all - would love to see some sort of prefixes we can set to identify admins when on duty etc inc maybe VIP/custom set ones - as well as this if anyone is wanting to hook into a website with their plugin - willing to offer my services as a php dev to help with the other side of things
Solved Chat prefixes
Discussion in 'Plugin Requests' started by Hirsty, Jan 23, 2015.
-
Wulf Community Admin
This would cover admin: http://oxidemod.org/resources/chat-handler.707/. I'd suggest making a request under that plugin's Discussion thread to handle moderators as well.
-
Not wanting chat name replaced wanting tag added such as [Owner] Hirsty
[DOUBLEPOST=1422085905][/DOUBLEPOST]could probably make it myself but don't know lua tempted to go into plugin development though -
Wulf Community Admin
-
Yeah love the idea, I just started working on something similar for our ViPs on my server but can't quite get it working yet... (just too new to LUA and Rust plugins...)
I wanted to create a plugin that changes the user name on join from original Name to Name ->ViP<- or something like that. With a config file that would contain all the SteamId's of the VIPs etc.
The same for admins.
Thanks,
- TheDoc
[DOUBLEPOST=1422375519,1422312341][/DOUBLEPOST]Ok so I got this working in a way.... but it only works with the actual player name, I want to use the SteamID but I can't figure out how to do that.
function PLUGIN:OnPlayerConnected(player)
if not player then return end
if not player.connection then return end
local steamID = rust.UserIDFromConnection(player.connection)
print(" connected SteamID1 (" .. steamID .. ")") -- DOES NOT WORK
local playerID = rust.UserIDFromPlayer( player ) -- DOES NOT WORK
print(" connected SteamID2 (" .. playerID .. ")")
if (playerID == 76561197983994692) then
local userDispName = ( "[Admin]" .. player.connection.username )
player.connection.username = userDispName
print(" connected (" .. userDispName .. ")")
end
-- IF I do just this, it works...
if(player.connection.username == "TheDoc") then
local userDispName = ( player.connection.username .. " >ViP< ")
player.connection.username = userDispName
print(" connected (" .. userDispName .. ")")
end
end
Please advise...
Thanks!
-TheDoc -
My original legacy Chat Handler plugin had an option to specify groups and set name prefixes for each group.
If there would be some kind of permission system like the old flags plugin i could eventually port that feature to the experimental version of Chat Handler. -
I think when you put " " around a variable, it turns that variable name into a string. So you are essentially passing the word ".. steamID .." in instead of passing the variable (.. steamID ..). If this hasn't been answered by the time I get home from work, I'll see what I can figure out as I cant debug rust till then.
-
I tested again and the following actually works:
Code:local steamID = rust.UserIDFromConnection(player.connection) print(" connected SteamID1 (" .. steamID .. ")")
Testing now with that and will see how it works out... now I need to learn how to load SteamID's from a config file...Last edited by a moderator: Jan 27, 2015 -
playerID needs to be player.connection.username
-----------------------
local steamID = rust.UserIDFromConnection(player.connection)
print(" connected SteamID1 (" .. steamID .. ")")
local playerID = player.connection.username
print(" connected SteamID2 (" .. playerID .. ")")
------------------------
My console output was:
connected SteamID1 (steam id number)
connected SteamID2 (Criticalmass)
[DOUBLEPOST=1422392805][/DOUBLEPOST]PLUGIN.Title = "cm-Test"
PLUGIN.Version = V(0, 0, 1)
PLUGIN.Description = "Test"
PLUGIN.Author = "Criticalmass"
PLUGIN.Url = ""
PLUGIN.HasConfig = false
function PLUGIN:Init()
end
function PLUGIN:OnPlayerConnected(player)
if not player then return end
if not player.connection then return end
local steamID = rust.UserIDFromConnection(player.connection)
print(" connected SteamID1 (" .. steamID .. ")")
local playerID = player.connection.username
print(" connected SteamID2 (" .. steamID .. " : " .. playerID .. ")")
end
[DOUBLEPOST=1422393240][/DOUBLEPOST]Something to keep in mind is the actual Oxide hook is "OnPlayerConnected(Facepunch/Network.Message packet)". To me using (player) gives a false impression you are trying to use "Assembly-CSharp/BasePlayer player" rather than "Facepunch/Network.Message packet". I'm a total noob so maybe this is only confusing to me.Last edited by a moderator: Jan 27, 2015 -
Dude, I be honest... I don't know what I'm doing here... just experimenting and stealing code from other plugins to make this one work.
Ok so I got it working with the following:
Code:local steamID = rust.UserIDFromConnection(player.connection) if (steamID == "76561197283992692") then local userDispName = ( "[Admin]" .. player.connection.username ) player.connection.username = userDispName print(" connected (" .. userDispName .. ")") end
Code:local steamID = rust.UserIDFromConnection(player.connection) local thedocId = "76561197283924692" if (steamID ==thedocId ) then local userDispName = ( "[Admin]" .. player.connection.username ) player.connection.username = userDispName print(" connected (" .. userDispName .. ")") end
Also it works with I type a chat message with the new prefix but ppl can't see it until I TP to them... any ideas how to force that to show up right away?
Thanks,
-TheDoc -
any developers care to take me under there wing :3 pretty sure shouldnt be too hard with myself having experience in jaca, C++, VB, Delphi and PHP as well as a few others then maybe i could help :3
-
-
Cant atm im at work >.>
-
Ok so I need some assistance from some Sr. Plugin Developers here please.
Here my final function:
Code:function PLUGIN:OnPlayerConnected(player) if not player then return end if not player.connection then return end local steamID = rust.UserIDFromConnection(player.connection) -- local name = player.connection.username -- print(" connected SteamID (" .. steamID .. ")") -- print(" connected name (" .. name .. ")")-- Hate this IF but can't get anything else working yet if (steamID == "9999999999999991" or steamID == "9999999999999992" or steamID == "9999999999999993" or steamID == "9999999999999994" or steamID == "9999999999999995" or steamID == "9999999999999996" or steamID == "9999999999999997" or steamID == "9999999999999998" or steamID == "9999999999999999" or steamID == "9999999999999990" or steamID == "9999999999999911" or steamID == "9999999999999912" ) then local userDispName = ( player.connection.username .. " ->ViP<-") player.connection.username = userDispName --print(" connected (" .. userDispName .. ")") end end
2. How do I load them into a table and then replace this crazy IF statement with a small function call that would iterate over the table and check if the ID connected exists in that list.
3. Also it works with I type a chat message with the new prefix but ppl can't see it until I TP to them... any ideas how to force that to show up right away?
4. I also wanted to do this for Admins on server (and I got it working the same crazy IF statement, but I'm unable to use the player.IsAdmin() call to validate the Admin ID... why?
I also tried using this function for it, and it does not work either: (guessing the player object is not the same as I'm getting in my OnPlayerConnected(player) )
Code:local function IsAdmin(player) return player:GetComponent("BaseNetworkable").net.connection.authLevel >= admin.Auth_LVL end
-TheDoc -
1 - You can find examples for this in almost every plugin.
2 - To iterate through a table and check for matches one possibility would be:
Code:for key, value in pairs(table) do if table[key].steamID == steamID then -- do something end end
3 - Maybe something to do with the global/local chat
4 - This function isnt working for you because "player" in your OnPlayerConnected() hook isnt a BasePlayer type. The IsAdmin() function you posted requires a BasePlayer. -
Cool thx. Working on it now...
4. How do I get BasePlayer?
[DOUBLEPOST=1422568098,1422469274][/DOUBLEPOST]Ok so I got the config file thing working...
function PLUGIN:LoadDefaultConfig()
Code:function PLUGIN:LoadDefaultConfig() self.Config.Settings = self.Config.Settings or {} self.Config.Settings.VipTag = self.Config.Settings.VipTag or " ->ViP<-" self.Config.Settings.AdminTag = self.Config.Settings.AdminTag or "[Admin] " self.Config.Settings.AddVipTag = self.Config.Settings.AddVipTag or "true" self.Config.Settings.AddAdminTag = self.Config.Settings.AddAdminTag or "true" self.Config.Vips = self.Config.Vips or { "9999999999999991", "9999999999999992", "9999999999999993", "9999999999999994" } self.Config.Admins = self.Config.Admins or { "1999999999999991", "1999999999999992", "1999999999999993", "1999999999999994" } self:SaveConfig() end
What am I doing wrog???
Here the IsAdmin() function (same function for VIPs)
Code:local function IsAdmin(steamID) for _, value in pairs(self.Config.Admins) do print("*** Value = " .. value .. " SteamId= " .. steamID ) if steamID == value then return true end end end
Code:if self.Config.Settings.AddAdminTag == "true" then if IsAdmin(steamID) then ) then local userDispName = ( self.Config.Settings.AdminTag .. packet.connection.username ) packet.connection.username = userDispName end end
Thanks,
-TheDocLast edited by a moderator: May 17, 2015 -
You cant use the self.Config variables in a local function.
Maybe you should post your whole plugin code so we can see what you're doing and help you with ideas how to realise it.
I could post you the code but you would learn more if we just give you some hints and you get to it yourself. -
Wulf Community Admin
-
Sure, please teach me! Here you go...
It's all working w/o using the config file and if you un-comment the if or statement and remove the of IsVip(steamId)
-TheDocAttached Files:
-
-
[DOUBLEPOST=1422619550][/DOUBLEPOST]
For example: local function IsVIP(steamID, self) and call it like IsVIP(steamID, self)