Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

CSQC - display extra player stuff?

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Thu Oct 16, 2008 3:26 am Post subject: 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:

Code:
.float money; float ceasefire, buy_time, round_time;

Thanks.
_________________
There's no signature here. Stop looking for one.

Back to top |

GiffE Joined: 08 Oct 2006 Posts: 141 Location: USA, CT |

Posted: Thu Oct 16, 2008 8:54 pm Post subject: |

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:

Code:
// 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:
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:
money = getstati(33);

_________________
http://www.giffe-bin.net/
Last edited by GiffE on Thu Oct 16, 2008 11:43 pm; edited 1 time in total

Back to top |

Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Thu Oct 16, 2008 10:07 pm Post subject: |

Ok I got it. But in what csqc function should I call this exactly? Because I tried it in CSQC_UpdateView() (view.qc) and Iotandassignment to world entity error. God damn keyboard! _________________
There's no signature here. Stop looking for one.

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Thu Oct 16, 2008 10:52 pm Post subject: |

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.
_________________
What's a signature?

Back to top |

Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Fri Oct 17, 2008 12:28 am Post subject: |

Look:

Code:
// 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...
_________________
There's no signature here. Stop looking for one.

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Fri Oct 17, 2008 3:05 am Post subject: |

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.
_________________
What's a signature?

Back to top |

Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Fri Oct 17, 2008 2:26 pm Post subject: |

I did just like Giffe said, I put that AddStat() line at the vwry top of worldspawn(), just after InitBodyQue():

Code:
AddStat (33, AS_FLOAT_TRUNCATED, money);

Shall I put it in another place of worldspawn()?
Thanks!
_________________
There's no signature here. Stop looking for one.

Back to top |

GiffE Joined: 08 Oct 2006 Posts: 141 Location: USA, CT |

Posted: Fri Oct 17, 2008 6:28 pm Post subject: |

Orion wrote:
I did just like Giffe said, I put that AddStat() line at the vwry top of worldspawn(), just after InitBodyQue():

Code:
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:
print("cash: ",ftos(cash), "\n");

See if the value of cash is sent.
_________________
http://www.giffe-bin.net/

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group