by Spike » Tue May 14, 2013 3:15 pm
csqc:
localcmd("cmd oh look I shot something\n");
ssqc:
void(string foo) SV_ParseClientCommand =
{
float numargs = tokenize(foo);
if (argv(0) == "oh")
{
assert(argv(1) == "look");
assert(argv(2) == "I");
//okay you get the idea
}
else
clientcommand(self, foo); //vital you do this for unrecognised commands, or you'll break random engine features.
};
combine it with strcat, ftos, and ftos, and you can pass multiple custom values from csqc to ssqc, but reliably only and the csqc does all the work regarding when the new message needs to be sent.
of course, precision is limited to the precision of a float, the tokenize command is a major wtf thanks to nexuiz, and user-supplied strings will likely need sanitising carefully or you can confuse the server. Also the user can just freely enter those at the console with some alias or bind or whatever.
the sendevent csqc builtin is more strict, and sends values as they are without string parsing or console interaction, but is limited to 6 args (and a name) due to qcvm limitations.
csqc
sendevent("shellupdate", "f", glob_ammo_shells);
ssqc:
void(float f) Cmd_shellupdate_f =
{
dosomethingwithf(f);
};
Use whichever works for you.
.