Hey :)
[url]http://wiki.garrysmod.com/page/GM/PlayerSay[/url]
[url]http://wiki.garrysmod.com/page/GM/Think[/url]
I'm trying to make a script that changes the players color rapidly when you send a message with a certain string in chat , using the PlayerSay and Think hooks (Linked Above)
I want to make one function call another function if a certain condition is met , in this case i want the color of all players to be changed if someone includes "!ColorChange" in chat.
[CODE]function colorchange(ply , ent)
for k ,v in pairs(player.GetAll()) do
local r = math.random(1,255)
local g = math.random(1,255)
local b = math.random(1,255)
v:SetColor(Color(r,g,b))
end
end
function chatcommand(ply , text , team)
if text == "!ColorChange" then
end
end
hook.Add("Think" , "ColorChange" , colorchange)
hook.Add("PlayerSay" , "ChatCommand" , chatcommand)[/CODE]
If anyone knows how i could call the function "colorchange" in the function "chatcommand" i would be greatful.
Thanks In Advance.
I don't quite understand what you mean, why not just use
[code]
--straight outta gmod wiki
hook.Add( "PlayerSay", "PlayerSayExample", function( ply, text, team )
local command = "!colorchange"
if ( string.lower(text) == command ) then
colorchange()
return ""
end
end )
[/code]
That function has ply and ent and both are never used...
EDIT: formatting broke a bit :(
I got the thing to work , pretty simple i am just dumb , created a function that has a if text == (Command) then it runs the function by simply using
run = funtion
Thanks for trying to help me :)
Sorry, you need to Log In to post a reply to this thread.