XP Saving


(raffles) #1

Hi,
Does anyone know how to make an xp saving function like in shrubmod and et pro where if you get disconnected or kicked, you still have your xp when you re-enter?
Less importantly do you know how to make is so your xp is never reset also like in shrubmod?

Any help appreciated :slight_smile: :slight_smile: :slight_smile:


(the_hat) #2

yeah, i was wondering this myself, wouldnt be to hard to make it not clear on new campaign, but to keep your xp as a “stat” and have it keep it when you re-enter the server would be hard i would guess.


(Helk) #3

easy…
make a structure thats like
typedef struct{
char * playername;
int xp;
float disconnecttime;
}xpdata_t;
make some array in level_locals_t

when a player disconnects, make an entry in this array of his playername, and his xp
when a player connects, index his name with one in the array, if a result is found, copy the data to the player…
as for it simply not resetting… look how campaign mapchanges work


(raffles) #4

Hi,
I just found something that looks a bit like an xp saving thing in g_svcmds.c from line 263 onwards, do you think I could use that (I think it looks promising)?

Edit:
Yes, they do work, the only reason that xp is not usually restored is because the functions and fuction calls (in g_client.c) are in ifdefs.