So i'm trying to change a color using a "DColorMixer" in a different file, can someone guide me through where i would start and recieve the user/net messages and which one would be better to use. I have some knowledge of lua so you dont need to hold my hand along the way. So basically i'll explain 1 of the file is ofcourse an addon, and the addon opens a DFrame once a chat command is typed, which i can do, and i need the color of a DColorMixer to be sent to a weapon file.
I have the code of the Mixer done, and the code of the entity done, i just need to send the mixer code the the :SetColor() in the shared.lua of the weapon. Thanks in advance :)
[editline]9th January 2014[/editline]
ok so instead of making an addon that does this ive decided to just add it into the shared.lua of the entity, but i have 1 question. if i do a PlayerSay hook from the server how would i either 1. open a client sided derma without a umsg or 2. in the client side how could i use a umsg hook to use a function like
[CODE]usermessage.Hook("hookname", function()
local Mixer = vgui.Create( "DColorMixer", Frame )
Mixer:Dock( FILL )
Mixer:SetPalette( true )
Mixer:SetAlphaBar( true )
Mixer:SetWangs( true )
Mixer:SetColor( Color( 0, 0, 0 ) )
end[/CODE]
to be read inside another function, like
[CODE] function myfunc()
if C then
C:SetColor(Mixer:GetColor())
[/CODE]
Can't think of any other ways then to send the DColorMixer's r, g, and b values to a text file, then to read the file and explode the string in the init.lua file of the SWEP and network that to the SetColor() function of the shared.lua. This wouldn't be an optimal way to do it, however I'm not sure if you can just network straight to a weapon.
EDIT: As far as I know, you can't directly hook into the PlayerSay and OnPlayerChat hooks from a SWEP.. correct me if I'm wrong.
is there a client sided way to see if someone types something into chat, to use it as a client sided chat command?
[editline]9th January 2014[/editline]
Or can you make a usermessage hook client sided and start it in a function client sided? basically sending the umsg back to yourself but in a new function
The OnPlayerChat hook can be used clientside.
EDIT: Usermessages only go from the server -> client; not vise versa. I suggest looking into the [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]Net Library[/URL] for server -> client and client -> server.
I would suggest reading into the net library, its much better than using usermessages and would be more suited for your requirements. If you add me on Steam I can give you a hand if you like.
I wrote a tutorial awhile back:
[url]http://facepunch.com/showthread.php?t=1326119&p=42900961&highlight=#post42900961[/url]
Sorry, you need to Log In to post a reply to this thread.