Raised This Month: $ Target: $400
 0% 

Need Help with Save XP and Load XP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-21-2007 , 12:40   Re: Need Help with Save XP and Load XP
Reply With Quote #1

well my plugin uses SQL methodology that I stole from War3FT so if you want SQL look there. For Vault saving I am using nVault, but it is my first time, so I am not sure if I got the syntax right...

I am asking here: http://forums.alliedmods.net/showthread.php?t=58220

but if I am right something like this:

These are the vault XP saving/loading functions from my AvP Mod.

Code:
public vSaveXP(id) {     #if defined DEBUG         debug_log("Begining: vSaveXP(id), id=%i", id);     #endif     if(pdata[id][PCLASS] == CLASS_NOTHING || is_user_bot(id)     || !get_pcvar_num(pcvar[SAVEXP]) || pdata[id][PXP] == 0)         return PLUGIN_CONTINUE;             //make sure player has steam ID     new playerID[32];     get_user_authid(id, playerID, 31);         if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID     && equal(playerID, "STEAM_ID_PENDING"))         return PLUGIN_CONTINUE;         new playerIP[20], name[33];     get_user_name(id, name, 32);     get_user_ip(id, playerIP, 19);         new szKey[128], szData[512];             //actual data to be saved.     format(szData, 511, "%d %d %d %d %s", classxp[id][CLASS_PREDATOR],  classxp[id][CLASS_ALIEN], classxp[id][CLASS_MARINE], get_systime(), name);         //the key to the vault data.     if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID)         format(szKey, 127, "%s", playerID);     else if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_IP)         format(szKey, 127, "%s", playerIP);     else         format(szKey, 127, "%s", name);         new vault = nvault_open(PLUGIN_VAULT);         if(vault == INVALID_HANDLE) {         avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);         return PLUGIN_CONTINUED;     }         //saves     nvault_set(vault, szKey, szData);         nvault_close(vault);         vSaveSkill(id);         return PLUGIN_CONTINUE; } public vLoadXP(id) {     #if defined DEBUG         debug_log("Begining: vLoadXP(id), id=%i", id);     #endif     if(!get_pcvar_num(pcvar[SAVEXP]) || !id)         return PLUGIN_CONTINUE;     //check SteamID     new playerID[32], name[33];     get_user_authid(id, playerID, 31);     get_user_name(id, name, 32);         if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID && equal(playerID, "STEAM_ID_PENDING")) {         client_print(id, print_chat, "%L", LANG_PLAYER, "STEAM_ID_PENDING_LOADING_ERROR", MOD);         avp_log("ERROR: player's(%i) exp could not be loaded. SteamID was: %s", id, playerID);                 return PLUGIN_CONTINUE;     }         new playerIP[20];     get_user_ip(id, playerIP, 19);         new szKey[128], szData[256], data;     //vault key, must unlock it :)     if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID)         format(szKey, 127, "%s", playerID);     else if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_IP)         format(szKey, 127, "%s", playerIP);     else         format(szKey, 127, "%s", name);     new vault = nvault_open(PLUGIN_VAULT);         if(vault == INVALID_HANDLE) {         avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);         return PLUGIN_CONTINUED;     }     data = nvault_get(vault, szKey, szData, 255);             nvault_close(vault);             //ok there is something in vault lets check it out.     if(data) {         new datPredXP[8],  datAlienXP[8],  datMarinXP[8];         //break it up baby, break it up!!         parse(szData, datPredXP, 7, datAlienXP, 7, datMarinXP, 7);         //now I guess I can take this stored data from vault,         //store it in the a temporary storage bin, then store the         //data in that temporary storage bin into another storage bin         //that is a global storage bin and the stored data has been         //stored now in the bigger storage bin and everything is STORED!!         classxp[id][CLASS_PREDATOR]     = str_to_num(datPredXP);         classxp[id][CLASS_ALIEN]    = str_to_num(datAlienXP);         classxp[id][CLASS_MARINE]   = str_to_num(datMarinXP);     } else { //nothing there, so just restart them.         classxp[id][CLASS_PREDATOR]     = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];         classxp[id][CLASS_ALIEN]    = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];         classxp[id][CLASS_MARINE]   = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];     }     ShowHUD(id);         pdata[id][PXP]      = (pdata[id][PCLASS] == CLASS_NOTHING) ? 0 : classxp[id][pdata[id][PCLASS]];     pdata[id][PLEVEL]   = Calc_Player_Level(id);         return PLUGIN_CONTINUE; }
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 07-21-2007 at 12:47.
Rolnaaba is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode