Poll

Was this module useful, and helpful?

Yes :)
274 (87.5%)
No :(
39 (12.5%)

Total Members Voted: 0

  • Print

Author Topic: Player Chat Tags [2.58v]  (Read 620597 times)

0 Members and 1 Guest are viewing this topic.

Offline yonsje

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #45 on: October 22, 2013, 01:52:30 pm »
Just checking my email today, and found that I have 6 new emails from ULX forums (uncommon), and are all from the same thread (really uncommon).

Anyways, I'm not sure why you're getting an error, which is strange. I've checked for any Garry's mod updates (which never happen anyways), and nothing happened. So, I'm not sure what the issue is. Looks fine for me. Though, it might be a usererror on ulx's side.

Are you sure you have all the groups correctly named?

Had the same problem, it happens when the console says something, a simple ply:IsValid() fixes this:
Code: Lua
  1. hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
  2.         if ply:IsValid() then
  3.                 for k,v in pairs(Tags) do
  4.                         if ply:IsUserGroup(v[1]) then
  5.                                 if Team then
  6.                                                 if ply:Alive() then
  7.                                                         chat.AddText(Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  8.                                                 else
  9.                                                         chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  10.                                                 end
  11.                                                 return true
  12.                                 end
  13.                                 if ply:IsPlayer() then
  14.                                         if ply:Alive() then
  15.                                                 chat.AddText(Color(255, 0, 0, 255), "", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  16.                                                 return true
  17.                                         elseif !ply:Alive() then
  18.                                                 chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  19.                                                 return true
  20.                                         end
  21.                                 end
  22.                         end
  23.                 end
  24.         end
  25. end)
« Last Edit: October 22, 2013, 01:56:21 pm by yonsje »

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Chat Tags 2.5
« Reply #46 on: October 22, 2013, 03:06:08 pm »
Had the same problem, it happens when the console says something, a simple ply:IsValid() fixes this:
Code: Lua
  1. hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
  2.         if ply:IsValid() then
  3.                 for k,v in pairs(Tags) do
  4.                         if ply:IsUserGroup(v[1]) then
  5.                                 if Team then
  6.                                                 if ply:Alive() then
  7.                                                         chat.AddText(Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  8.                                                 else
  9.                                                         chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  10.                                                 end
  11.                                                 return true
  12.                                 end
  13.                                 if ply:IsPlayer() then
  14.                                         if ply:Alive() then
  15.                                                 chat.AddText(Color(255, 0, 0, 255), "", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  16.                                                 return true
  17.                                         elseif !ply:Alive() then
  18.                                                 chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
  19.                                                 return true
  20.                                         end
  21.                                 end
  22.                         end
  23.                 end
  24.         end
  25. end)

Not sure, wait for one of the ulx experts to assist you further. I'm too busy to assist anyone at this moment.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player Chat Tags 2.5
« Reply #47 on: October 22, 2013, 07:21:47 pm »
Chaos, pretty sure yonsje fixed the issue, and his code is how he did it.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline yonsje

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #48 on: October 23, 2013, 11:30:35 am »
Not sure, wait for one of the ulx experts to assist you further. I'm too busy to assist anyone at this moment.

Chaos, pretty sure yonsje fixed the issue, and his code is how he did it.

Exactly, ply:IsUserGroup doesn't work on something like the console, so when something is said through the console you get "attempt to call method 'IsUserGroup' (a nil value)".
I fixed it by checking if the "thing" that said something was actually a player, using ply:IsValid().

Offline fopje

  • Newbie
  • *
  • Posts: 10
  • Karma: 2
Re: Player Chat Tags 2.5
« Reply #49 on: October 27, 2013, 07:16:55 pm »
EDIT - JamminR - Needless quote of entire release first post...if you wish to quote a certain part of it, remove everything else.

Could you make the darkrp version compatible with current chat prefixes?

atm there is OOC, Advert, PM and Broadcast
these dissapear while using the tag system
« Last Edit: October 27, 2013, 08:23:29 pm by JamminR »

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Chat Tags 2.5
« Reply #50 on: October 27, 2013, 10:16:34 pm »
Exactly, ply:IsUserGroup doesn't work on something like the console, so when something is said through the console you get "attempt to call method 'IsUserGroup' (a nil value)".
I fixed it by checking if the "thing" that said something was actually a player, using ply:IsValid().

Well I'm somewhat back into lua atm. So if you still need help, I may be able to assist you.



Could you make the darkrp version compatible with current chat prefixes?

atm there is OOC, Advert, PM and Broadcast
these dissapear while using the tag system

Yeah it is possible, and I've already done it. You'll just need to use the Manager Version of my script.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline fopje

  • Newbie
  • *
  • Posts: 10
  • Karma: 2
Re: Player Chat Tags 2.5
« Reply #51 on: October 28, 2013, 07:59:54 am »
Yeah it is possible, and I've already done it. You'll just need to use the Manager Version of my script.

Thanks for you fast reply, but I just tried it (again) and those prefixes are not included. You did add the *DEAD* prefix, but whenever I use /ooc or /advert it wont show me how it should be

What I say: /ooc test
What it shows: S. Admin | Fopje: test
what it should: (OOC) S. Admin | Fopje: test

This is a important function of gmod, if the OOC chat isn't visible people don't know is it's someone talking who are next to them, or when it's someone talking in the "global chat"
same as advert texts are always yellow and broadcasts are red
« Last Edit: October 28, 2013, 08:01:49 am by fopje »

Offline Mates

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #52 on: October 28, 2013, 12:32:34 pm »
Very good job, except I noticed it sadly doesn't work right for Cinema gamemode - it "breaks" the regular chat and team chat (which is actually a global chat) so they are both global, since the Cinema functions probably don't get processed anymore. Any chance this could be fixed in the future?

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Chat Tags 2.5
« Reply #53 on: October 28, 2013, 03:37:31 pm »
Thanks for you fast reply, but I just tried it (again) and those prefixes are not included. You did add the *DEAD* prefix, but whenever I use /ooc or /advert it wont show me how it should be

What I say: /ooc test
What it shows: S. Admin | Fopje: test
what it should: (OOC) S. Admin | Fopje: test

This is a important function of gmod, if the OOC chat isn't visible people don't know is it's someone talking who are next to them, or when it's someone talking in the "global chat"
same as advert texts are always yellow and broadcasts are red

I wouldn't really know how to fix that, as I'm not too much into looking at the OOC chat part for darkrp. Someone who is familiar with Dark RP systems can maybe assist you, or such.


Very good job, except I noticed it sadly doesn't work right for Cinema gamemode - it "breaks" the regular chat and team chat (which is actually a global chat) so they are both global, since the Cinema functions probably don't get processed anymore. Any chance this could be fixed in the future?

I'm sorry, I have never heard of this gamemode. So I would not be able to assist you with this at all, or maybe if you could describe or screenshot the issues, I could give a better opinion
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Mates

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #54 on: October 28, 2013, 04:47:48 pm »
I'm sorry, I have never heard of this gamemode. So I would not be able to assist you with this at all, or maybe if you could describe or screenshot the issues, I could give a better opinion
In the end I managed to solve it by writing similar function clientside, using the OnPlayerChat hook.  But I can still use this with other gamemodes, so thanks!

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Chat Tags 2.5
« Reply #55 on: October 28, 2013, 07:07:58 pm »
In the end I managed to solve it by writing similar function clientside, using the OnPlayerChat hook.  But I can still use this with other gamemodes, so thanks!

I'm glad you found yourself help. I may also use your advice, for future released of this and or other addons I make.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Mates

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #56 on: October 29, 2013, 01:12:30 am »
In the end I managed to solve it by writing similar function clientside, using the OnPlayerChat hook.  But I can still use this with other gamemodes, so thanks!
I just realised your solution works exactly the same way I described mine, which is weird since it didn't work. I guess I will try it once more when I get a moment.

Offline rainbow Dash

  • Newbie
  • *
  • Posts: 35
  • Karma: -2
  • Owner of Friendship is Gaming Servers
    • Friendship is Gaming
Re: Player Chat Tags 2.5
« Reply #57 on: November 03, 2013, 01:02:48 am »
I wouldn't really know how to fix that, as I'm not too much into looking at the OOC chat part for darkrp. Someone who is familiar with Dark RP systems can maybe assist you, or such.

Well its simple, I'll give you a few tips to detect DarkRP and act accordingly.

To detect DarkRP, and this probably isn't the best way, but its how I do it, but to detect it (clientside) look for LocalPlayer().DarkRPVars.money

As for the tags... I think this file (darkrp/gamemode/modules/chat/sv_chatcommands.lua) might be of some help to you to add DarkRP support, be mindful that the chat command prefix is defined at GAMEMODE.Config.chatCommandPrefix.

Code: [Select]
/*---------------------------------------------------------
Talking
 ---------------------------------------------------------*/
local function PM(ply, args)
local namepos = string.find(args, " ")
if not namepos then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local name = string.sub(args, 1, namepos - 1)
local msg = string.sub(args, namepos + 1)

if msg == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
target = DarkRP.findPlayer(name)

if target then
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(target, col, "(PM) "..ply:Nick(), Color(255,255,255,255), msg, ply)
DarkRP.talkToPerson(ply, col, "(PM) "..ply:Nick(), Color(255,255,255,255), msg, ply)
else
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("could_not_find", tostring(name)))
end

return ""
end
DarkRP.defineChatCommand("pm", PM, 1.5)

local function Whisper(ply, args)
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
DarkRP.talkToRange(ply, "(".. DarkRP.getPhrase("whisper") .. ") " .. ply:Nick(), text, 90)
end
return args, DoSay
end
DarkRP.defineChatCommand("w", Whisper, 1.5)

local function Yell(ply, args)
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
DarkRP.talkToRange(ply, "(".. DarkRP.getPhrase("yell") .. ") " .. ply:Nick(), text, 550)
end
return args, DoSay
end
DarkRP.defineChatCommand("y", Yell, 1.5)

local function Me(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if GAMEMODE.Config.alltalk then
for _, target in pairs(player.GetAll()) do
DarkRP.talkToPerson(target, team.GetColor(ply:Team()), ply:Nick() .. " " .. text)
end
else
DarkRP.talkToRange(ply, ply:Nick() .. " " .. text, "", 250)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("me", Me, 1.5)

local function OOC(ply, args)
if not GAMEMODE.Config.ooc then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", DarkRP.getPhrase("ooc"), ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local col = team.GetColor(ply:Team())
local col2 = Color(255,255,255,255)
if not ply:Alive() then
col2 = Color(255,200,200,255)
col = col2
end
for k,v in pairs(player.GetAll()) do
DarkRP.talkToPerson(v, col, "("..DarkRP.getPhrase("ooc")..") "..ply:Name(), col2, text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("/", OOC, true, 1.5)
DarkRP.defineChatCommand("a", OOC, true, 1.5)
DarkRP.defineChatCommand("ooc", OOC, true, 1.5)

local function PlayerAdvertise(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(v, col, DarkRP.getPhrase("advert") .." "..ply:Nick(), Color(255,255,0,255), text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("advert", PlayerAdvertise, 1.5)

local function MayorBroadcast(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if not RPExtraTeams[ply:Team()] or not RPExtraTeams[ply:Team()].mayor then DarkRP.notify(ply, 1, 4, "You have to be mayor") return "" end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(v, col, DarkRP.getPhrase("broadcast") .. " " ..ply:Nick(), Color(170, 0, 0,255), text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("broadcast", MayorBroadcast, 1.5)

local function SetRadioChannel(ply,args)
if tonumber(args) == nil or tonumber(args) < 0 or tonumber(args) > 100 then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", "0<channel<100"))
return ""
end
DarkRP.notify(ply, 2, 4, DarkRP.getPhrase("channel_set_to_x", args))
ply.RadioChannel = tonumber(args)
return ""
end
DarkRP.defineChatCommand("channel", SetRadioChannel)

local function SayThroughRadio(ply,args)
if not ply.RadioChannel then ply.RadioChannel = 1 end
if not args or args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
if v.RadioChannel == ply.RadioChannel then
DarkRP.talkToPerson(v, Color(180,180,180,255), DarkRP.getPhrase("radio_x", ply.RadioChannel), Color(180,180,180,255), text, ply)
end
end
end
return args, DoSay
end
DarkRP.defineChatCommand("radio", SayThroughRadio, 1.5)

local function GroupMsg(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end

local t = ply:Team()
local col = team.GetColor(ply:Team())

local hasReceived = {}
for _, func in pairs(GAMEMODE.DarkRPGroupChats) do
-- not the group of the player
if not func(ply) then continue end

for _, target in pairs(player.GetAll()) do
if func(target) and not hasReceived[target] then
hasReceived[target] = true
DarkRP.talkToPerson(target, col, DarkRP.getPhrase("group") .. " " .. ply:Nick(), Color(255,255,255,255), text, ply)
end
end
end
if next(hasReceived) == nil then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unable", "/g", ""))
end
end
return args, DoSay
end
DarkRP.defineChatCommand("g", GroupMsg, 1.5)

-- here's the new easter egg. Easier to find, more subtle, doesn't only credit FPtje and unib5
-- WARNING: DO NOT EDIT THIS
-- You can edit DarkRP but you HAVE to credit the original authors!
-- You even have to credit all the previous authors when you rename the gamemode.
local CreditsWait = true
local function GetDarkRPAuthors(ply, args)
local target = DarkRP.findPlayer(args); -- Only send to one player. Prevents spamming
if not IsValid(target) then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("player_doesnt_exist"))
return ""
end

if not CreditsWait then DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("wait_with_that")) return "" end
CreditsWait = false
timer.Simple(60, function() CreditsWait = true end)--so people don't spam it

local rf = RecipientFilter()
rf:AddPlayer(target)
if ply ~= target then
rf:AddPlayer(ply)
end

umsg.Start("DarkRP_Credits", rf)
umsg.End()

return ""
end
DarkRP.defineChatCommand("credits", GetDarkRPAuthors, 50)

EDIT: But uh, just in case, I'm suggesting to FPtje to add a hook to his chat commands so that people can do all this.
« Last Edit: November 03, 2013, 01:12:22 am by rainbow Dash »
Uhm, whats a signature?

Offline npd1124

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Player Chat Tags 2.5
« Reply #58 on: November 10, 2013, 12:57:51 pm »
for some reason it works and says the message when somone leaves but not when they join do you know how to fix this

this is the code
Code: [Select]
// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)
« Last Edit: November 10, 2013, 01:00:49 pm by npd1124 »

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Chat Tags 2.5
« Reply #59 on: November 11, 2013, 02:52:21 am »
for some reason it works and says the message when somone leaves but not when they join do you know how to fix this

this is the code
Code: [Select]
// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)

Bro wrong thread topic. Please go here and paste your issues there:
/index.php/topic,6036.0.html

Though to put this out here. It looks like a serer side error, because I see not difference in the CLIENT side code.
« Last Edit: November 11, 2013, 03:01:38 am by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

  • Print