I've progressed far enough where creating a custom UI will help in testing character stats, so naturally its time to dig into some CSQC.
I've gotten one AddStat function working, but what's really throwing me is .SendEntity.
I want to use the SendEntity functionality to setup tempory entities as data channels to push updates to the client. So far I can pass info for ents that follow the player around...but I can't send random entities with data I want. If I send the player's "leg" entity, the data gets received, but the ent's origin gets completely messed up :/
SSQC:
Code: Select all
.float(entity viewer) SendEntity;
.float SendFlags;
.float Version;
float MSG_ENTITY = 5;
//one of my 'SendEntity' calls
float() csqc_SendVecComp={
WriteByte(MSG_ENTITY, ENT_ADDVECCOMP);
WriteString(MSG_ENTITY, self.c_name);
WriteByte(MSG_ENTITY, self.max_health);
WriteByte(MSG_ENTITY, self.health);
WriteByte(MSG_ENTITY, self.armorvalue);
WriteByte(MSG_ENTITY, self.max_armor);
return TRUE;
};
Code: Select all
//the temporary entity to send
local entity senda;
senda = spawn();
senda.c_name = self.e_legs.c_name;
senda.health = self.e_legs.health;
senda.max_health = self.e_legs.max_health;
senda.armorvalue = self.e_legs.armorvalue;
senda.max_armor = self.e_legs.max_armor;
senda.SendEntity = csqc_SendVecComp;
senda.Version = senda.Version+1;
Code: Select all
void CSQC_Ent_Update(float bIsNewEntity)
{
local float i;
i = readbyte();
if(i == ENT_ADDVECCOMP){
if(bIsNewEntity){
local string n;
n = readstring();
if(n == M_LEGS){
LEG_HP_MX = readbyte();
LEG_HP_CUR = readbyte();
LEG_ARM_CUR = readbyte();
LEG_ARM_MX = readbyte();
}
}
}
}