OK, now I studied!
![Big Grin :D](./images/smilies/icon_biggrin.gif)
This concept literally drives me crazy. Let's just use an example to demonstrate if I'm stupid or if this is a limit of CSQC.
DISCLAIMER: I use FTE. Dunno if this procedure is replicable on DP. Last time I took a look, CSQC_ParseEvent wasn't present in dpextensions.qc
Let's imagine we want to play a fire animation in CSQC (no, you don't want it, YOU MUST DO IT in CSQC, because, server side, you cannot split skeleton for upper / lower part)
I first used something like this
SERVER SIDE - weapons
Code: Select all
void MyWeaponFireFunc()
{
if(time < self.weaponRefireTime){
SendCsShotOn();
return;
}
else{
SendCsShotOff();
}
}
SERVER SIDE - send stuff
Code: Select all
void SendCsShotOn()
{
msg_entity = self;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, PE_WEAPONSHOT);
WriteByte(MSG_MULTICAST, 1);
multicast(self.origin, MULTICAST_ALL);
}
void SendCsShotOff()
{
msg_entity = self;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, PE_WEAPONSHOT);
WriteByte(MSG_MULTICAST, 0);
multicast(self.origin, MULTICAST_ALL);
}
CLIENT SIDE - main
Code: Select all
noref void() CSQC_Parse_Event =
{
local float rb = readbyte();
if(rb == PE_WEAPONSHOT){
weaponShot = readbyte();
}
}
CLIENT SIDE - player
Code: Select all
void PlayerAnimFire()
{
if(weaponShot == 1){
self.frame = animFireShotgun;
}
else{
self.frame = animFireShotgunIdle;
}
}
If I start only a client, I can see my shadow changing animation so it works. BUT.. if I connect two clients to my local server, I position the two clients, facing each other, when I press fire only the other player in my own screen will change animation, but, in the other screen, the player I see (that is the one who pressed fire) remains still.
I also used .shot field instead of a float, both in SSQC and CSQC - I also tried MULTICAST_ONE instead of MULTICAST_ALL - same results.
********WORKING METHOD
INSTEAD, if I use .shot field in ssqc and, instead of using CSQC_ParseEvent I use SendEntity in PutClientServer and sending all the fields I need to update (.origin,.angles,.velocity,etc) and I add self.shot at the list,
Code: Select all
float SendPlayerData (entity playerent, float changedflags)
{
//entity
WriteByte(MSG_ENTITY, ENT_PLAYER);
//movements
WriteCoord(MSG_ENTITY, self.origin_x);
WriteCoord(MSG_ENTITY, self.blabla
//frame
WriteByte(MSG_ENTITY, self.frame);
//
WriteByte(MSG_ENTITY, self.shot);
return TRUE;
}
and in CSQC_EntUpdate I add
Code: Select all
void CSQC_Ent_Update (float isnew)
{
local float i = readbyte();
if (i == ENT_PLAYER){
//read here all send values from client.c in ssqc
//movements
self.origin_x = readcoord();
self.blabla
//frame
self.frame = readbyte();
//
self.shot = readbyte();
//all the remaining stuff
}
}
Then in the client side animation
Code: Select all
void PlayerAnimFire()
{
if(self.shot == 1){
self.frame = animFireShotgun;
self.frame1time += frametime;
}
else{
self.frame = animFireShotgunIdle;
self.frame1time += frametime;
}
skel_build(self.skeletonindex, self, self.modelindex, 0, bSpine2, bHolsterL, 1);
}
If I connect 2 clients, now I can see the other client in THE OTHER screen play fire animaion when I, in my own screen, press mouse button. Perfect,
now IT WORKS.
This is
exactly same issue I posted here. But, back then, I wasn't so sure of the mechanism.And, even back then, the solution was to use CSQC_EntUpdate instead of CSQC_ParseEvent. Now I could say I'm becoming more confident with CSQC so I now there's nothing I made wrong in the testing part. So, there are 2 possibilities:
- This is not the right method to parse an event for a specific client
- CSQC_ParseEvent is not made for sending client-specific data
Please CSQC Gurus, help me! So I can update fteskel project soon! There are a lot of updates to bake! ![Big Grin :D](./images/smilies/icon_biggrin.gif)