CSQC troubles
Moderator: InsideQC Admins
11 posts
• Page 1 of 1
CSQC troubles
Thanks to Spike's advice, i finally got csqc working for me. after about 15 minutes i had some trouble with it.
1- drawing tga that have transparent colors either don't work, or the transparency appears white. i tried messing withe the float alpha thing, with no success
2- i can't get ssqc to interact with csqc. mainly i mean, when a certain float changes in ssqc, how to i initiate a function within csqc?
3- not really a problem here but lets say i want to draw how much armor you have. i made individual number textures, but to code it correctly i did something along the line of (if currenthealth = 97) (drawpic: '9' '7'). this would require a piece of code for every possible value of health. any simpler way?
thanks!
1- drawing tga that have transparent colors either don't work, or the transparency appears white. i tried messing withe the float alpha thing, with no success
2- i can't get ssqc to interact with csqc. mainly i mean, when a certain float changes in ssqc, how to i initiate a function within csqc?
3- not really a problem here but lets say i want to draw how much armor you have. i made individual number textures, but to code it correctly i did something along the line of (if currenthealth = 97) (drawpic: '9' '7'). this would require a piece of code for every possible value of health. any simpler way?
thanks!
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
1: jpgs have no transparency... which image format are you using?
2: if its a stat that you're looking at, you need to poll in the csqc each frame. there's no notification when a stat changes.
3: str = ftos(float); firstnum = str2chr(str, 0) - '0'; firstum = secondnum = str2chr(str, 1) - '0';
alternatively, firstnum=floor(num/10;) secondnum = floor(num) - firstnum*10;
you do need to check string lengths still, and be aware of negatives.
2: if its a stat that you're looking at, you need to poll in the csqc each frame. there's no notification when a stat changes.
3: str = ftos(float); firstnum = str2chr(str, 0) - '0'; firstum = secondnum = str2chr(str, 1) - '0';
alternatively, firstnum=floor(num/10;) secondnum = floor(num) - firstnum*10;
you do need to check string lengths still, and be aware of negatives.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:1: jpgs have no transparency... which image format are you using?
i used all formats i could think of, but not jpgs. i never said jpgs.
Spike wrote:2: if its a stat that you're looking at, you need to poll in the csqc each frame. there's no notification when a stat changes.
hmm. do you mean like adding a 'refresh' code? i don't know how to do that.
3. thanks ill try your code!
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
1: regarding transparencies, if you try setting gl_conback to the name of your transparent image, does it show the transparencies properly?
pngs and tgas can have transparencies in them. lmp considers index 255 to be fully transparent, but can be a pain to create
when drawing, try an alpha value of 0.99 to force transparencyness, though I'm not sure that's entirely needed.
if that still doesn't work, then you may need a shader, but if you do for a 2d image then I'm willing to accept it as an engine bug. been fixing a few of those recently. :s
2: something like:
float health;
void() somefunc
{
float newval = getstat(STAT_HEALTH);
if (health != newval)
{
health = newval;
healthchanged();
}
};
pngs and tgas can have transparencies in them. lmp considers index 255 to be fully transparent, but can be a pain to create
when drawing, try an alpha value of 0.99 to force transparencyness, though I'm not sure that's entirely needed.
if that still doesn't work, then you may need a shader, but if you do for a 2d image then I'm willing to accept it as an engine bug. been fixing a few of those recently. :s
2: something like:
float health;
void() somefunc
{
float newval = getstat(STAT_HEALTH);
if (health != newval)
{
health = newval;
healthchanged();
}
};
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
ok i j ust figured out that my photoshop has problheems saving transparency!! i had to reinstall it and it works fine! sry for the confusion!
ill try that out soon. but can i replace STAT_HEALTH with any float? i want to display floats besides health, aka my added floats. hope it's possible. csqc is a real bugger for me.
Spike wrote:2: something like:
float health;
void() somefunc
{
float newval = getstat(STAT_HEALTH);
if (health != newval)
{
health = newval;
healthchanged();
}
};
ill try that out soon. but can i replace STAT_HEALTH with any float? i want to display floats besides health, aka my added floats. hope it's possible. csqc is a real bugger for me.
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
Stats between 0 and 31 are defined by the engine. Stats between 32 and 127 are for the QC code. Stats between 128 and 255 are probably supported in FTE or DP, but may be stomped on in the future.
use whatever stat numbers you want, so long as it matches what the server sends.
use whatever stat numbers you want, so long as it matches what the server sends.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Ok this is what I did;
AddStat (32, AS_FLOAT_TRUNCATED, self.pistolbullets);
in client.qc
const float STAT_PISTOLBULLETS = 32;
in csqc_contants.qc
void() refreshpistol =
{
float newval = getstati(STAT_PISTOLBULLETS);
if (currentpistolbullets != newval)
{
currentpistolbullets = newval;
bulletschanged();
}
};
in View.qc
Then I tried to print it out in csqc, and it didn't work. Am I missing anything/doing something wrong?
AddStat (32, AS_FLOAT_TRUNCATED, self.pistolbullets);
in client.qc
const float STAT_PISTOLBULLETS = 32;
in csqc_contants.qc
void() refreshpistol =
{
float newval = getstati(STAT_PISTOLBULLETS);
if (currentpistolbullets != newval)
{
currentpistolbullets = newval;
bulletschanged();
}
};
in View.qc
Then I tried to print it out in csqc, and it didn't work. Am I missing anything/doing something wrong?
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
your qcc should have given some sort of error on the addstat line.
there should be no self. on that line.
there should be no self. on that line.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
ok. i removed the self. (SORRY FOR TAKING SO LONG I HAVE NET PROBLEMS)
it finally works. thanks a million.
now, i must ask:
1 - can you rotate pics/flip images in csqc?
2 - the difference between getstati and getstatf is interger and float, right? i added AS_FLOAT to the addstat and tried to get the float using getstatf, but it only returned 0. im guessing i have to change the const float STAT_PISTOLCLIP = 36; to just float?
3- i use your compiler, fteqcc. it didn't give me an error when i used self.
thanks!!!
it finally works. thanks a million.
now, i must ask:
1 - can you rotate pics/flip images in csqc?
2 - the difference between getstati and getstatf is interger and float, right? i added AS_FLOAT to the addstat and tried to get the float using getstatf, but it only returned 0. im guessing i have to change the const float STAT_PISTOLCLIP = 36; to just float?
3- i use your compiler, fteqcc. it didn't give me an error when i used self.
thanks!!!
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
1 - you mimght be able to do something sneaky with subpic. failing that there's only the polygon drawing code, which is more complex to use, if only because its defered.
2 - you're using the 'renamed' constants, which do no match how the engine internally works
think of it this way. every stat has two versions of the stat. a float version and an 'integer' version.
The 'integer' version, or its bitwise identity, is its exact integer value. any getstats etc will return its exact bit value.
The 'AS_FLOAT' constant you have, is actually 'ev_integer'.
Thus you're claiming that a float is an integer, and its 'getstatf' value in csqc is then nonsensical. If you want to use 'AS_FLOAT' for floats, you need to use getstati to read it.
ev_float/AS_FLOAT_TRUNCATED: sends the field using the protocol's native float handling. in FTE, this is a true float. in DP, its truncated.
ev_integer/AS_FLOAT: sends the field (even if its a float) as if its an int, using the protocol's native 32bit stat handling. This always preserves all bits of any non-vector/string field.
ev_string/AS_STRING: field is intepreted as a string. this string is either packed into 4 adjacent stats (DP truncates to 15 chars), or sent using special handling in a separate stat namespace (which is what FTE does).
ev_entity/AS_ENTITY: sends th entity number as if an integer
getstati(330): directly returns the integer part, no conversion (think of it as the stat's identity). make sure you store the return value into the type it originally was. use this to read an ev_integer value.
getstatf(331): converts the stat into a float, makes no sense if it was already a float. use this to read ev_float or ev_entity
getstatbits(331): converts part of the integer stat's bits into a float (required for the self.items stat's default packing with runes due to limited float precision). use this to read stat_items, should otherwise not be used.
getstats(332): returns a tempstring containing either up to 16 chars of the original string from 4 consecutive stats, or up to 1024 chars of a string stat from a separate stat namespace. use this to read an ev_string.
For FTE, you generally want to use ev_float for floats, it'll give you better network usage. For DP, you may find you need to use the ev_integer hack for floats to avoid truncation, but you should only use it if you actually need the floating part. FTE may give more precision with ev_float or ev_string, but the two engines are otherwise compatible, hopefully.
3. yeah, your addstat is probably defined addstat(float,float,...), rather than taking an explicit type.
2 - you're using the 'renamed' constants, which do no match how the engine internally works
think of it this way. every stat has two versions of the stat. a float version and an 'integer' version.
The 'integer' version, or its bitwise identity, is its exact integer value. any getstats etc will return its exact bit value.
The 'AS_FLOAT' constant you have, is actually 'ev_integer'.
Thus you're claiming that a float is an integer, and its 'getstatf' value in csqc is then nonsensical. If you want to use 'AS_FLOAT' for floats, you need to use getstati to read it.
ev_float/AS_FLOAT_TRUNCATED: sends the field using the protocol's native float handling. in FTE, this is a true float. in DP, its truncated.
ev_integer/AS_FLOAT: sends the field (even if its a float) as if its an int, using the protocol's native 32bit stat handling. This always preserves all bits of any non-vector/string field.
ev_string/AS_STRING: field is intepreted as a string. this string is either packed into 4 adjacent stats (DP truncates to 15 chars), or sent using special handling in a separate stat namespace (which is what FTE does).
ev_entity/AS_ENTITY: sends th entity number as if an integer
getstati(330): directly returns the integer part, no conversion (think of it as the stat's identity). make sure you store the return value into the type it originally was. use this to read an ev_integer value.
getstatf(331): converts the stat into a float, makes no sense if it was already a float. use this to read ev_float or ev_entity
getstatbits(331): converts part of the integer stat's bits into a float (required for the self.items stat's default packing with runes due to limited float precision). use this to read stat_items, should otherwise not be used.
getstats(332): returns a tempstring containing either up to 16 chars of the original string from 4 consecutive stats, or up to 1024 chars of a string stat from a separate stat namespace. use this to read an ev_string.
For FTE, you generally want to use ev_float for floats, it'll give you better network usage. For DP, you may find you need to use the ev_integer hack for floats to avoid truncation, but you should only use it if you actually need the floating part. FTE may give more precision with ev_float or ev_string, but the two engines are otherwise compatible, hopefully.
3. yeah, your addstat is probably defined addstat(float,float,...), rather than taking an explicit type.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest