How to preserve a player's shirt color on QC?
Moderator: InsideQC Admins
13 posts
• Page 1 of 1
How to preserve a player's shirt color on QC?
I made a clan arena-style mod, and to indicate that a player is dead, it turns white by stuffcmd(). You can change your shirt color at any time, but you can't change your pants color.
I know that pants color is detected by using (self.team - 1), what about shirt color?
.colormap won't work, it just puts the colors of a specified client number into another entity.
For example, I enter the game on blue team with color 11(green shirt) and 13(blue pants).
As I don't know hot to preserve the shirt color, if you die and after some time the round ends, you'll return all blue using stuffcmd().
As I said above, if you die you'll go white.
I know that pants color is detected by using (self.team - 1), what about shirt color?
.colormap won't work, it just puts the colors of a specified client number into another entity.
For example, I enter the game on blue team with color 11(green shirt) and 13(blue pants).
As I don't know hot to preserve the shirt color, if you die and after some time the round ends, you'll return all blue using stuffcmd().
As I said above, if you die you'll go white.
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
have you tried like self.shirt = x i think i did something like that once lemme see if i can find how i did it.
edit: i think the "shirt" comment was for dp only... but i looked through defs.qc and i see that you said "team" changes your pants color... have you tried using "colormap" ?
because right above team i see this :
.float colormap;
.float team;
edit: i think the "shirt" comment was for dp only... but i looked through defs.qc and i see that you said "team" changes your pants color... have you tried using "colormap" ?
because right above team i see this :
.float colormap;
.float team;
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
No.
In fact, colormap stores you client number (1-16).
For example, you spawn a clone that kills enemies for you, and if you want him to use the same colors as you, you'd give it (clone.colormap = self.colormap;).
It doesn't work on glquake for non-client entities (except darkplaces), but works on gl quakeworld.
In fact, colormap stores you client number (1-16).
For example, you spawn a clone that kills enemies for you, and if you want him to use the same colors as you, you'd give it (clone.colormap = self.colormap;).
It doesn't work on glquake for non-client entities (except darkplaces), but works on gl quakeworld.
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.
in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.
In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.
In unmodified quake, you only know the lower colour from the .team field.
in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.
In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.
in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.
In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.
but, hes asking about the top color.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
Spike wrote:colormap is an index into a table. the only way to change the colours with it is to stuffcmd... not nice.
In unmodified quake, you only know the lower colour from the .team field.
in darkplaces, you can use .playercolors. its a bitfield (two parts, both 4 bits) that states the colours the player wants to use. just reset the lower colour to the correct team.
Course, that only works in darkplaces/FTE.
In Quakeworld you can stuffcmd a setinfo command to change their bottomcolor back to what it should have been.
You mean .clientcolors
There is also the DP_SV_SETCOLOR extension which intercepts color change attempts and lets the qc do whatever it wants (such as preserving shirt color but forcing team color), it was added specifically for this purpose several years ago (I used to maintain a clanring ctf mod for my clan, and always wished it had this feature).
But in the Clan Arena mod I recall you chose team in the ingame menu, and then chose shirt color, it simply stuffed the command and waited for you to change (this actually held up the game if anyone was suffering heavy packet loss).
- LordHavoc
- Posts: 322
- Joined: Fri Nov 05, 2004 3:12 am
- Location: western Oregon, USA
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
DR, i think its implied for the scoreboard output?
- Code: Select all
void(entity ent, float clientshirt, float clientpants) setcolor =
{
local float client;
client = (ent.colormap - 1);
msg_entity = ent;
WriteByte (MSG_ALL, SVC_UPDATECOLORS);
WriteByte (MSG_ALL, client);
WriteByte (MSG_ALL, ((clientshirt * 16) + clientpants));
};
//JPG's HACK! REQUIRES ENGINE OFFSETS
//ie float CL_COLORS = %2032;
float () get_top_color =
{
local float tc;
tc = floor((self.cl[CL_COLORS] / %1) / 16);
return tc;
};
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
r00k wrote:
- Code: Select all
//JPG's HACK! REQUIRES ENGINE OFFSETS
I don't think it's wise to even bring up the idea of engine hacks.
The DP_SV_SETCOLOR extension was created entirely for this purpose, and has been around for many years (2000 or 2001).
If you need a feature and an engine does not have it, complain to the author of that engine, or add it yourself.
- LordHavoc
- Posts: 322
- Joined: Fri Nov 05, 2004 3:12 am
- Location: western Oregon, USA
So should it be ?
I'll have to look at the extension...
- Code: Select all
shirt = floor((self.clientcolors / %1) / 16);
I'll have to look at the extension...
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
r00k wrote:So should it be ?
- Code: Select all
shirt = floor((self.clientcolors / %1) / 16);
I'll have to look at the extension...
No, that's part of the DP_SV_BOTCLIENT extension (which lets you spawn bots in client slots and make use of player physics, and display properly on the scoreboard of course), it's a much later extension, both are good though
- LordHavoc
- Posts: 322
- Joined: Fri Nov 05, 2004 3:12 am
- Location: western Oregon, USA
LordHavoc wrote:r00k wrote:So should it be ?
- Code: Select all
shirt = floor((self.clientcolors / %1) / 16);
I'll have to look at the extension...
No, that's part of the DP_SV_BOTCLIENT extension (which lets you spawn bots in client slots and make use of player physics, and display properly on the scoreboard of course), it's a much later extension, both are good though
actually that should work. it worked for me, i assigned the shirt color through a menu, although the clientcolors are for the pants, you can if you just set pants it just changes the colors on the scoreboard. (maybe the same with the shirt) but like someone said earlier he could still set the score board color to the one he wants then make the change permanent with a skin =)
and actually i think i did this.
shirt = 1; i think and it seemed to work. i dont remember though.
//DP_SV_CLIENTCOLORS
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//field definitions:
.float clientcolors; // colors of the client (format: pants + shirt * 16)
//description:
//allows qc to read and modify the client colors associated with a client entity (not particularly useful on other entities), and automatically sends out any appropriate network updates if changed
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
13 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest