Update entity data from CSQC for the server?

Discuss CSQC related programming.
Post Reply
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Update entity data from CSQC for the server?

Post by Mexicouger »

I currently send data from the server to the client via csqc, but Im wondering if its possible to update a players stat through CSQC and register it in the server?

For instance.. Send a players ammo count to the client in QC, and use that data in CSQC to display HUD things. Well how about when I take control of input in CSQC, can I edit the ammo in CSQC and update it on the server so it's not a lost cause?

If this is hard to understand, I can expand upon my question to make it more clear to understand.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Update entity data from CSQC for the server?

Post by frag.machine »

In other words, you want/need a P2P architecture instead ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Update entity data from CSQC for the server?

Post by Spike »

there's a sendevent builtin in csqc that will result in function calls with arguments, other than that you'll have to depend upon client commands+krimzon_sv_parseclientcommand.
the only automatic replication of things from csqc to ssqc is the input_* state (like impulses), which is retransmitted each netframe, but they're basically fixed behaviour.
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Re: Update entity data from CSQC for the server?

Post by Mexicouger »

Can you further expand upon what you mean by client commands and krimzon_sv_parseclientcommand spike?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Update entity data from CSQC for the server?

Post by Spike »

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.
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Re: Update entity data from CSQC for the server?

Post by Mexicouger »

Thanks for expanding upon that Spike! It makes much more sense now. I will now utilize this new knowledge :)
Post Reply