r1ch.net forums
* Home Help Search Login Register
r1ch.net  |  General  |  General Discussion  |  Topic: Configstrings are confusing...
Pages: [1]
Print
Author Topic: Configstrings are confusing...  (Read 5595 times)
Paril
Guest
« on: July 31, 2007, 12:18:07 pm »

Hey guys. Question mostly geared to R1CH.

I'm having trouble with configstrings. I need to store a string in a configstring because my HUD system uses stat_string, but for some reason I can't get more than one string in here. I tried this first:

   
Code:
{
char *pistolammostring = gi.TagMalloc (sizeof(char *), TAG_GAME);
char *shammostring = gi.TagMalloc (sizeof(char *), TAG_GAME);
pistolammostring = va(" %i/200",ent->client->pers.inventory[ITEM_INDEX(FindItem("Pistol Ammo"))]);
shammostring = va(" %i/50",ent->client->pers.inventory[ITEM_INDEX(FindItem("Shells"))]);
gi.configstring (CS_GENERAL+playernum, pistolammostring);
ent->client->ps.stats[STAT_DUKE_PISTOLAMMO] = CS_GENERAL+playernum;
gi.configstring ((CS_GENERAL+playernum)+sizeof(pistolammostring), shammostring);
ent->client->ps.stats[STAT_DUKE_SHOTGUNAMMO] = (CS_GENERAL+playernum)+sizeof(pistolammostring);
}

Failed horribly. Tried this:

   
Code:
{
char *pistolammostring = gi.TagMalloc (sizeof(char *), TAG_GAME);
char *shammostring = gi.TagMalloc (sizeof(char *), TAG_GAME);
pistolammostring = va(" %i/200",ent->client->pers.inventory[ITEM_INDEX(FindItem("Pistol Ammo"))]);
shammostring = va(" %i/50",ent->client->pers.inventory[ITEM_INDEX(FindItem("Shells"))]);
gi.configstring (CS_GENERAL+playernum, pistolammostring);
ent->client->ps.stats[STAT_DUKE_PISTOLAMMO] = CS_GENERAL+playernum;
gi.configstring ((CS_GENERAL+playernum)+1, shammostring);
ent->client->ps.stats[STAT_DUKE_SHOTGUNAMMO] = (CS_GENERAL+playernum)+1;
}

but it just override other people if they joined.

Any ideas or other type of HUD token I could use?

-Paril
Logged
Paril
Guest
« Reply #1 on: July 31, 2007, 12:29:21 pm »

Oh, just to let you know, I'm not sure exactly how configstrings work, I thought maybe it was a string of 512 chars or something...

-Paril
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #2 on: August 04, 2007, 03:29:09 pm »

No offense, but I think you need to learn C programming first, there are numerous fundamental errors with your code. Configstrings are global, they are sent to all clients. You want to mess with the CS_STATUSBAR configstring to plaqy with the hud.
Logged
Pages: [1]
Print
r1ch.net  |  General  |  General Discussion  |  Topic: Configstrings are confusing...
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines