• Garry's Mod chat commands bug!
    6 replies, posted
Ok, so I was working on a chat command and its nice works, but only works when im dead. I am running a murder server, and I have realised murder uses something like this: [CODE] Names = { "Jill", "Bob", "Joseph", "Jackson", "etc" } hook.Add( "OnPlayerChat", "Names", function( ply, text, team ) if ply:Spawn() then for k, v in pairs(player.GetAll()) do chat.AddText( Color( 100, 100, 255 ), Names[ math.random( #Names ) ], Color( 255, 255, 255 ), string.sub( text, 1 ) ) end end)[/CODE] And that gives every player a random name! So I tried making a chat command that reads onplayerchat but it dont work because when a player spawns it renames them! [CODE]hook.Add( "PlayerSay", "AllSay", function( ply, text, team ) if ( string.sub( text, 1, 4 ) == "/all" ) then -- if the first four characters of the string are /all return "[Global] " .. string.sub( text, 5 ) -- add [Global] in front of the players text then display end end )[/CODE] So is there a way I can test a players steam ID instead of testing for a players chat message? Thanks, Jacob. [editline]16th July 2016[/editline] Edit, it uses this aswell I think: [CODE]Color = { "etc.", "Color(100,200,255)" }[/CODE]
:snip: I'm stupid, didn't read
[QUOTE=MPan1;50720446][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/PLAYER/Spawn]PLAYER:Spawn[/url] doesn't return a variable, it's a function which respawns the player-Also, it's a serverside command and so using it clientside by checking [CODE] if ply:Spawn() then [/CODE] Obviously won't work. Maybe that's the problem. [editline]16th July 2016[/editline] Also, this: [CODE] Color = { "etc.", "Color(100,200,255)" } [/CODE] Is an INCREDIBLY bad idea since it overrides the Color function, which almost every addon uses to set colors.[/QUOTE] No, im just making a point what it uses, the true question is. How do I make a chat command that tests for someones STEAM ID so it dosent conflict with the murder setup!
:snip: I misread again Sorry, I keep missing stuff in the original post- thanks for calling me a fucking asshole, really nice attitude you have even though I've snipped all the posts so you don't need to read them Also, I have no clue why you want to check the steamid of a player, from what I can tell from your original post you simply want to check if the chat text has /all at the start of it, but the Murder gamemode adds the player's nickname to the start so you can't read it. If this is the case, why not just get their nickname and string.sub that away from the chat text, and then check if it has /all? :snip: Misunderstanding
[QUOTE=MPan1;50720458]:snip: stupid post again, don't reply to me[/QUOTE] Ok then dont reply here fucking asshole. [editline]16th July 2016[/editline] All im wondering is if I would be able to use STEAMIDs to test chat! [editline]16th July 2016[/editline] [QUOTE=MPan1;50720458]:snip: stupid post again Sorry, I keep missing stuff in the original post- thanks for calling me a fucking asshole, really nice attitude you have even though I've snipped all the posts so you don't need to read them Also, I have no clue why you want to check the steamid of a player, from what I can tell from your original post you simply want to check if the chat text has /all at the start of it, but the Murder gamemode adds the player's nickname to the start so you can't read it. If this is the case, why not just get their nickname and string.sub that away from the chat text, and then check if it has /all?[/QUOTE] How may I do this? [editline]16th July 2016[/editline] [QUOTE=MPan1;50720458]:snip: stupid post again Sorry, I keep missing stuff in the original post- thanks for calling me a fucking asshole, really nice attitude you have even though I've snipped all the posts so you don't need to read them Also, I have no clue why you want to check the steamid of a player, from what I can tell from your original post you simply want to check if the chat text has /all at the start of it, but the Murder gamemode adds the player's nickname to the start so you can't read it. If this is the case, why not just get their nickname and string.sub that away from the chat text, and then check if it has /all? Side note- don't go around on forums like this one expecting people to help you if you're going to call them a fucking asshole for making mistakes, I actually found a solution to your problem but I'm not going to post it here. Sorry, I'm sure I'm too much of an asshole to help you.[/QUOTE] Well thanks for trying, I only called u an Asshole for what you said. :goodjob: You said: Stupid post again, don't reply to me. Like, come on! You were a dick, and I am just look for some answers, all I was asking is what I was doing wrong, not a message saying how dumb this is!
[QUOTE=jacobcooper18;50720462]You said: Stupid post again, don't reply to me[/QUOTE] Yeah, cause I posted a dumb answer without properly reading your original post and I didn't want you to reply to it because what I posted was wrong. I wasn't talking about any of your original posts :v: Sorry if you thought I was [editline]16th July 2016[/editline] Anyway, I may as well post the solution I found before, but now I need to go find it again, hold on... (sorry for derailing the thread before, I just didn't have a clue why you were calling me an asshole) [editline]16th July 2016[/editline] Okay, hopefully this will work: [CODE] hook.Add( "PlayerSay", "AllSay", function( ply, text, team ) local name = ply:GetBystanderName() -- This may be ply:Nick(), I'm not quite sure text = string.sub( text, #name+0 ) -- Change 0 to be a bigger number until it subs out the rest if ( string.sub( text, 1, 4 ) == "/all" ) then return "[Global] " .. string.sub( text, 5 ) end end ) [/CODE] I haven't tested it in the actual Murder gamemode yet, but hopefully this will string.sub out their name so you can check what they said... if not, try using ply:Nick() or try adding 1 to the 0 until it gets rid of anything like brackets or colons around the name Also, sorry for being confusing, I wasn't calling you dumb, I was calling myself dumb
[QUOTE=MPan1;50720535]Yeah, cause I posted a dumb answer without properly reading your original post and I didn't want you to reply to it because what I posted was wrong. I wasn't talking about any of your original posts :v: Sorry if you thought I was [editline]16th July 2016[/editline] Anyway, I may as well post the solution I found before, but now I need to go find it again, hold on... (sorry for derailing the thread before, I just didn't have a clue why you were calling me an asshole) [editline]16th July 2016[/editline] Okay, hopefully this will work: [CODE] hook.Add( "PlayerSay", "AllSay", function( ply, text, team ) local name = ply:GetBystanderName() -- This may be ply:Nick(), I'm not quite sure text = string.sub( text, #name+0 ) -- Change 0 to be a bigger number until it subs out the rest if ( string.sub( text, 1, 4 ) == "/all" ) then return "[Global] " .. string.sub( text, 5 ) end end ) [/CODE] I haven't tested it in the actual Murder gamemode yet, but hopefully this will string.sub out their name so you can check what they said... if not, try using ply:Nick() or try adding 1 to the 0 until it gets rid of anything like brackets or colons around the name Also, sorry for being confusing, I wasn't calling you dumb, I was calling myself dumb[/QUOTE] Oh ok, thanks MPan1 :D
Sorry, you need to Log In to post a reply to this thread.