Need help with clientside junk

Okay, so I want to be able to send messages to clients which will then store the messages in a table to use in HUD effects, think like “double kill” notifications.

My thought was to put a table in cl_init.lua and use HUD hooks to draw them but I have no clue how to call those from the server when whatever event happens.

Help :I


Here’s an example. :smile:

[lua]local function PlayerDeath(ply)


hook.Add(“PlayerDeath”, “DeathMessage”, PlayerDeath);[/lua]

[lua]local function ReceivePlayerDeath(um)
local ply = um:ReadEntity();

 //do stuff with this player     

usermessage.Hook(“PlayerDied”, ReceivePlayerDeath);[/lua]

Sick, that’s just what I needed thanks

OKAY on a related note, I need to figure out how to make the client tell the server that it wants to do something like buy a gun. I can’t do that clientside because the give methods etc. are all serverside, so would I need to use a usermessage from the client to the server to make the request? Or is there a better way to do this?

Yup, setup a console command on the server that the clients can use. You can run the console command on them when they click a button for instance. When doing that sort of things keep in mind that clients can call a console command at any given time so you should do all of your checks (such as money, or team) serverside to decide if you want to allow or disallow an action.


Okay so if it’s the client running the console command, how do I link that to a serverside function?

You use concommand.Add serverside and RunConsoleCommand clientside. :smile: Both using the same command name of course.

**EXEMPLE : **

function IReallyHateMyLife(ply,cmd,args)

concommand.Add(“ihatemylife”,“TestCommand”, IReallyHateMyLife)


concommand.Add only takes two arguments. Your example would error because the second arg should be a function, not a string.

Oops, you’re right. Got mixed up with hook.Add somehow.:smile: