CSQC - display extra player stuff?
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
CSQC - display extra player stuff?
Hi, I'm making a mod where you buy weapons, earn money by hitting the enemies, and it's teamplay only. When a player dies, it becomes white, visible, but non-solid and can't shoot. A round ends if all players of a team is dead, then it resets, 3 seconds of cease-fire, and a new round starts. Or, a round may end if 3 minutes pass. The team with more players alive wins. If both teams have the same number of players alive, then the round ends tied and no point is given to any team.
Ok, let's go to the important thing. I want to make my cash, cease-fire time, buy time and round time display at the bottom of my screen, right near the hud, without overriding centerprint (because I use centerprint for the menu to buy weapons).
I'm not good on csqc, but I really want that. It would be sweet. =)
Also, I have the csqc source code here.
And, if needed, here are the vars I use which I want to display with csqc:
Thanks.
Ok, let's go to the important thing. I want to make my cash, cease-fire time, buy time and round time display at the bottom of my screen, right near the hud, without overriding centerprint (because I use centerprint for the menu to buy weapons).
I'm not good on csqc, but I really want that. It would be sweet. =)
Also, I have the csqc source code here.
And, if needed, here are the vars I use which I want to display with csqc:
- Code: Select all
.float money;
float ceasefire, buy_time, round_time;
Thanks.
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
You can use csqc for the menu's aswell and it will look even better
.
Why not calculate the ceasefire time, buy time and round time, using the time variable in csqc? its no different than ssqc.
Other than that you could use addstat (EXT_CSQC) to add float var's for the player and update them every second. But it seems unnessary.
.float money on the other hand should be done with addstat.
Here's how to use it:
First the builtin needs to be added to dpextensions.qc:
I added this to the bottom of dpextensions.qc:
The index is the player stat index that will be used to get this variable from the client.
1-32 are reserved, if I recall correctly.
You only need to call this function once so place in worldspawn (ssqc)
add:
this will make the money fieldfloat variable on the server's ssqc be sent to csqc using the index "33".
now in csqc when ever you want to get the money, call:
Why not calculate the ceasefire time, buy time and round time, using the time variable in csqc? its no different than ssqc.
Other than that you could use addstat (EXT_CSQC) to add float var's for the player and update them every second. But it seems unnessary.
.float money on the other hand should be done with addstat.
Here's how to use it:
First the builtin needs to be added to dpextensions.qc:
I added this to the bottom of dpextensions.qc:
- Code: Select all
// EXT_CSQC
// AddStat
void(float index, float type, ...) AddStat = #232; // third parameter is an entity field
float AS_STRING = 1;
float AS_FLOAT_TRUNCATED = 2; // int value
float AS_FLOAT = 8;
The index is the player stat index that will be used to get this variable from the client.
1-32 are reserved, if I recall correctly.
You only need to call this function once so place in worldspawn (ssqc)
add:
- Code: Select all
AddStat(33,AS_FLOAT_TRUNCATED, money);
this will make the money fieldfloat variable on the server's ssqc be sent to csqc using the index "33".
now in csqc when ever you want to get the money, call:
- Code: Select all
money = getstati(33);
Last edited by GiffE on Thu Oct 16, 2008 11:43 pm, edited 1 time in total.
- GiffE
- Posts: 170
- Joined: Sun Oct 08, 2006 3:39 pm
- Location: USA, CT
CSQC isn't so object oriented as ssqc. There would be too many different sorts of object that its not quite so feasable.
Regarding reading stats, typically you only need them that frame, and they're by nature a single value per frame. Thus I don't really recommend storing stats in entity fields for the most part.
If you're drawing it on the hud, chances are its only ever needed in a single function.
Regarding reading stats, typically you only need them that frame, and they're by nature a single value per frame. Thus I don't really recommend storing stats in entity fields for the most part.
If you're drawing it on the hud, chances are its only ever needed in a single function.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Look:
I got the status bar csqc source and I put these lines, a fith small golden number appeared beside the cells number, but it's always zero, and you always start with 250 money...
- Code: Select all
// cash
cash = getstati(33);
str3 = ftos(cash);
len = strlen(str3);
if (len < 1)
str4 = "000";
else if (len < 2)
str4 = strcat(" ", str3);
else if (len < 3)
str4 = strcat(" ", str3);
else
str4 = str3;
str4 = strconv(CONV_SAME, CONV_SAME, CONV_REDSPECIAL, str4);
Sbar_DrawString(240, -24, str4, sbar_alpha_fg);
I got the status bar csqc source and I put these lines, a fith small golden number appeared beside the cells number, but it's always zero, and you always start with 250 money...
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
then you didn't do the AddStat bit properly.
Seeing as its a special stat, you have to tell the server to actually send it in the ssqc, which can be retrieved with the getstat function. Which you are doing. The fact that it is always 0 means that it probably isn't getting sent by the server, which means your AddStat call in the ssqc isn't working right for some reason.
Seeing as its a special stat, you have to tell the server to actually send it in the ssqc, which can be retrieved with the getstat function. Which you are doing. The fact that it is always 0 means that it probably isn't getting sent by the server, which means your AddStat call in the ssqc isn't working right for some reason.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
I did just like Giffe said, I put that AddStat() line at the vwry top of worldspawn(), just after InitBodyQue():
Shall I put it in another place of worldspawn()?
Thanks!
- Code: Select all
AddStat (33, AS_FLOAT_TRUNCATED, money);
Shall I put it in another place of worldspawn()?
Thanks!
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
Orion wrote:I did just like Giffe said, I put that AddStat() line at the vwry top of worldspawn(), just after InitBodyQue():
- Code: Select all
AddStat (33, AS_FLOAT_TRUNCATED, money);
Shall I put it in another place of worldspawn()?
Thanks!
Weird. It worked for me in worldspawn, I used it for ammo but the process is the same for money.
print out
- Code: Select all
print("cash: ",ftos(cash), "\n");
See if the value of cash is sent.
- GiffE
- Posts: 170
- Joined: Sun Oct 08, 2006 3:39 pm
- Location: USA, CT
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest