Hey, not sure where I should post this so I thought this board was the best idea. Basically I'm stuck on something and I could use some help from people who know more on this stuff than I do. Sorry if this post shouldn't be here though.
Anyways, I'm working on making an addon that uses custom made chat commands. I know that PlayerSay hooks exist yet I can't seem to get them working with parameters/arguments. Seems to elude me. I've found some code snippets that would define chat commands but they would screw with the base function which isn't what I want. Here I'll provide an example.
concommand.Add("rainbow", function(ply, _, args)
if not ply:IsSuperAdmin() then
ply:ChatPrint("No Access!")
return
end
local target = ply
target = GetPlayer(args[1])
if not target:IsValid() then
ply:ChatPrint("Invalid Target!")
return
end
timer.Create("RainbowGuy", 0.2, 0, function() rainbow(target) end)
target:ChatPrint("Rainbow Effect Enabled!")
end)
Here is a simple script that just, in theory, makes a user's model color and physgun color rapidly change in a rainbow effect. What's provided above may not work on the first try because I changed it ever so slightly to allow it to make more sense here. The changes don't affect my dilemma though.
So, anyways, as you can see I have created a console command named "rainbow" and it has room for targeting players and all of that fun stuff. My question is, is there a way to do this in a chat command as well? Have both a chat and console command that take from the same function? Everything I've tried won't work because concommand.Add() needs to have that cmd parameter and that screws with the methods I've tried. I'd really rather have to not essentially duplicate the function to get the same effect so I'm hoping that someone here could help.
Any help is greatly appreciated.
If you need to see the function behind rainbow() then I can provide that, I just didn't see it necessary for my issue.