• When players are dead they get the owner tag?
    20 replies, posted
[CODE]function ChatTags(ply, Text, Team, PlayerIsDead) if ply:IsPlayer() then local group = ply:GetUserGroup() local nickteamcolor = team.GetColor(ply:Team()) // tag = "" // col = Color(0,0,0,255) if ply:Alive() then if group == "user" then tag = UserTag.." " col = UserColor // if (string.sub(Text, 1, 4) == "/ooc") then // print( "ooc" ) // chat.AddText(UserColor, "[User] (OOC) ", nickteamcolor , ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) // return true // else chat.AddText(UserColor, UserTag.." " , nickteamcolor , ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) return true // end end if group == "vip" || group == "VIP" then chat.AddText(VIPColor, VIPTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = VIPTag.." " col = VIPColor return true end if group == "moderator" || group == "Moderator"then chat.AddText(ModeratorColor, ModeratorTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = ModeratorTag.." " col = ModeratorColor return true end if group == "admin" || group == "Admin"then chat.AddText(AdminColor, AdminTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = AdminTag.." " col = AdminColor return true end if group == "superadmin" || group == "Superadmin" || group == "SuperAdmin" then chat.AddText(SuperAdminColor, SuperAdminTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = SuperAdminTag.." " col = SuperAdminColor return true end if group == "owner" || group == "Owner" then chat.AddText(OwnerColor, OwnerTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = OwnerTag.." " col = OwnerColor return true end if group == "trialadmin" || group == "Trialadmin" then chat.AddText(TrialColor, TrialTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = TrialTag.." " col = TrialColor return true end if group == "coowner" || group == "Coowner" then chat.AddText(CoownerColor, CoownerTag.." " , nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) tag = CoownerTag.." " col = CowonerColor return true end end if !ply:Alive() then chat.AddText(Color(30,30,30,255), "[DEAD] ",col, tag, nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text) return true end end end hook.Add("OnPlayerChat", "DaedricChatTags", ChatTags)[/CODE] Screenshot of the glitch in action: [IMG]http://i.imgur.com/qfVgLiA.png[/IMG] Note that this only happens when people chat while dead, and it always defaults to giving them the owner tag. Can anybody help me on this?
For the love of God, look up what elseif and string.lower is.
[QUOTE=code_gs;45774961]For the love of God, look up what elseif and string.lower is.[/QUOTE] I'm sorry I'm not good at scripting :( I'm not really sure what you mean.
Doing an || statement for each group is pointless when you could just do string.lower and get the lowercase string immediately. Also, you don't have to make a bunch of separate if-statements, but instead, link them with elseif. Google for the specific syntax.
I diddn't code this :( I'm modifying it.
Why the hell are you checking if the player is alive so many times? It makes no sense, this has to be the messiest script I have ever seen. Also hint hint one of your live checks may be fucking it up, but I honestly can't tell because I'm on mobile and so nothing is indented properly.
[QUOTE=kila58;45775032]Why the hell are you checking if the player is alive so many times? It makes no sense, this has to be the messiest script I have ever seen. Also hint hint one of your live checks may be fucking it up, but I honestly can't tell because I'm on mobile and so nothing is indented properly.[/QUOTE] As I stated before I did not code this. I cannot code at all. I could not even begin to make a script like this..
[QUOTE=BlushBerry;45775061]As I stated before I did not code this. I cannot code at all. I could not even begin to make a script like this..[/QUOTE] I feel whoever created this is on the same boat as you, when I get on my PC I'll be able to tell you the problem.
[QUOTE=kila58;45775086]I feel whoever created this is on the same boat as you, when I get on my PC I'll be able to tell you the problem.[/QUOTE] Alright thank you very much :)
Here is my attempt using a lookup table to eliminate all of the if/elseifs. I've tested it on my server using my own colors/tags for testing and it seems to work fine. [CODE] local tags = { user = { Color = UserColor, Tag = UserTag }, vip = { Color = VIPColor, Tag = VIPTag }, moderator = { Color = ModeratorColor, Tag = ModeratorTag }, trialadmin = { Color = TrialColor, Tag = TrialTag }, admin = { Color = AdminColor, Tag = AdminTag }, superadmin = { Color = SuperAdminColor, Tag = SuperAdminTag }, coowner = { Color = CoownerColor, Tag = CoownerTag }, owner = { Color = OwnerColor, Tag = OwnerTag }, } local color_dead = Color( 30, 30, 30 ) function ChatTags( ply, text, isTeam, isDead ) if ( IsValid( ply ) ) then -- ignores console's chat local tagData = tags[ ply:GetUserGroup():lower() ] or tags[ 'user' ] -- default to 'user' if they aren't in a valid usergroup chat.AddText( isDead and color_dead or nil, isDead and "[DEAD] " or nil, tagData.Color, tagData.Tag .. " ", ply, color_white, ": " .. text ) return true end end hook.Add( "OnPlayerChat", "DaedricChatTags", ChatTags ) [/CODE] If you give it a try and have any issues, feel free to post them / PM me and I'll help further.
There is an issue with this [CODE] [ERROR] addons/chattags2/lua/autorun/cl_chat_tags.lua:24: attempt to concatenate field 'Tag' (a nil value) 1. fn - addons/chattags2/lua/autorun/cl_chat_tags.lua:24 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE]
[QUOTE=BlushBerry;45778864]There is an issue with this [CODE] [ERROR] addons/chattags2/lua/autorun/cl_chat_tags.lua:24: attempt to concatenate field 'Tag' (a nil value) 1. fn - addons/chattags2/lua/autorun/cl_chat_tags.lua:24 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE][/QUOTE] That's because you have to change the table values to what you want; UserTag is just a placeholder.
[QUOTE=BlushBerry;45778864]There is an issue with this [CODE] [ERROR] addons/chattags2/lua/autorun/cl_chat_tags.lua:24: attempt to concatenate field 'Tag' (a nil value) 1. fn - addons/chattags2/lua/autorun/cl_chat_tags.lua:24 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE][/QUOTE] I just assumed that you had all of those tags and colors defined already. For example, using them as globals from a different file, or creating them somewhere before the code you pasted. I just based this on the image you posted that shows you [B]do [/B]have the Owner tag defined. Do you mind showing the bit of code where all of the tags and colors are created?
[QUOTE=Dave_Parker;45779758]Based on the line number he probably just copied over the entire file with your code.[/QUOTE] The tags and colors could have been defined in a different file, which is the likely case considering the screenshot BlushBerry provided that shows at least OwnerColor/OwnerTag are defined. [QUOTE][IMG]http://i.imgur.com/qfVgLiA.png[/IMG][/QUOTE]
Client: [CODE]local tags = { user = { Color = UserColor, Tag = UserTag }, vip = { Color = VIPColor, Tag = VIPTag }, moderator = { Color = ModeratorColor, Tag = ModeratorTag }, trialadmin = { Color = TrialColor, Tag = TrialTag }, admin = { Color = AdminColor, Tag = AdminTag }, superadmin = { Color = SuperAdminColor, Tag = SuperAdminTag }, coowner = { Color = CoownerColor, Tag = CoownerTag }, owner = { Color = OwnerColor, Tag = OwnerTag }, } local color_dead = Color( 30, 30, 30 ) function ChatTags( ply, text, isTeam, isDead ) if ( IsValid( ply ) ) then -- ignores console's chat local tagData = tags[ ply:GetUserGroup():lower() ] or tags[ 'user' ] -- default to 'user' if they aren't in a valid usergroup chat.AddText( isDead and color_dead or nil, isDead and "[DEAD] " or nil, tagData.Color, tagData.Tag .. " ", ply, color_white, ": " .. text ) return true end end hook.Add( "OnPlayerChat", "DaedricChatTags", ChatTags )[/CODE] Tags I think: [CODE] UserColor = Color(0,255,0, 255) VIPColor = Color(255,255,0, 255) ModeratorColor = Color(0,0,255, 255) AdminColor = Color(255,128,64, 255) SuperAdminColor = Color(255,0,0, 255) OwnerColor = Color(255,100,150, 255) TrialColor = Color(0,240,240, 255) CoownerColor = Color(146,36,255, 255) UserTag = "[User]" VIPTag = "[VIP]" ModeratorTag = "[Moderator]" AdminTag = "[Admin]" SuperAdminTag = "[SuperAdmin]" OwnerTag = "[Owner]" TrialTag = "[Trial Admin]" CoownerTag = "[Co-Owner]" [/CODE] server: [CODE]AddCSLuaFile( "cl_chat_tags.lua" ) AddCSLuaFile( "customizer.lua" )[/CODE]
Thank you for the information, BlushBerry. I've tested my script with your tag/colors and it appears to work fine for the each of the user groups. [B]My next guess is that you may be loading the cl_chat_tags.lua file prior to the colors and tags being created.[/B] Does your [B]customizer.lua[/B] file contain the colors and tags you posted? If so, try switching the order that you load the scripts, i.e.: [CODE]AddCSLuaFile( "customizer.lua" ) -- load tag/colors first AddCSLuaFile( "cl_chat_tags.lua" ) -- now load the OnPlayerChat hook function to use them [/CODE]
[QUOTE=Mista Tea;45781435]Thank you for the information, BlushBerry. I've tested my script with your tag/colors and it appears to work fine for the each of the user groups. [B]My next guess is that you may be loading the cl_chat_tags.lua file prior to the colors and tags being created.[/B] Does your [B]customizer.lua[/B] file contain the colors and tags you posted? If so, try switching the order that you load the scripts, i.e.: [CODE]AddCSLuaFile( "customizer.lua" ) -- load tag/colors first AddCSLuaFile( "cl_chat_tags.lua" ) -- now load the OnPlayerChat hook function to use them [/CODE][/QUOTE] I will give it a try give me one moment to lock up my server. [editline]24th August 2014[/editline] When I switched those around this came up [CODE] [ERROR] addons/chattags2/lua/autorun/cl_chat_tags.lua:24: attempt to concatenate field 'Tag' (a nil value) 1. fn - addons/chattags2/lua/autorun/cl_chat_tags.lua:24 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE]
My mistake, I didn't even think to ask about the [B]order they are being [I]included [/I]on the client[/B]. Switching the AddCSLuaFile part won't really have any effect. Can you first absolutely confirm that the colors and tags you posted are being created in the [B]customizer.lua[/B] file? If you can, please try to find the spot in the client files (maybe something like [B]cl_init.lua[/B]?) where there is something like this: [CODE]include( "cl_chat_tags.lua" ) include( "customizer.lua" )[/CODE] If it's loading them in that exact order, you'll need to switch them so customizer.lua is [I]included [/I]first. I apologize if I'm barking up the entirely wrong tree. I'm just trying to go off of what I can tell. The whole problem just appears to be the script loading order. If the tags and colors [B]aren't[/B] created before the cl_chat_tags.lua script loads, it'll cause that error you are getting because they didn't exist at that time.
[QUOTE=Mista Tea;45781564]My mistake, I didn't even think to ask about the [B]order they are being [I]included [/I]on the client[/B]. Switching the AddCSLuaFile part won't really have any effect. Can you first absolutely confirm that the colors and tags you posted are being created in the [B]customizer.lua[/B] file? If you can, please try to find the spot in the client files (maybe something like [B]cl_init.lua[/B]?) where there is something like this: [CODE]include( "cl_chat_tags.lua" ) include( "customizer.lua" )[/CODE] If it's loading them in that exact order, you'll need to switch them so customizer.lua is [I]included [/I]first. I apologize if I'm barking up the entirely wrong tree. I'm just trying to go off of what I can tell. The whole problem just appears to be the script loading order. If the tags and colors [B]aren't[/B] created before the cl_chat_tags.lua script loads, it'll cause that error you are getting because they didn't exist at that time.[/QUOTE] Would you mind checking your private messages mista? Eh screw it. Could you just add me on skype? My skype is -Snippity Snip-
Sorry, you need to Log In to post a reply to this thread.