Raised This Month: $ Target: $400
 0% 

Won't save info in vault?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JProReTaRD
Member
Join Date: May 2009
Location: Denmark, KBH
Old 05-10-2009 , 09:26   Won't save info in vault?
Reply With Quote #1

Hi I'm currently developing an xp-mod for my server, but it won't save nor load info from vault.


Save & load code:
PHP Code:
public SaveXP(id) {
     new 
authid[32];
     
get_user_authid(id,authid,31);
     new 
vaultkey[64], vaultdata[64];
     
//Save their XP
     
format(vaultkey,63,"Jumper-%s-%i-xp",authid,PlayerClass[id]);
     
format(vaultdata,63,"%d",PlayerXP[id]);
     
set_vaultdata(vaultkey,vaultdata);
     
//Save their level
     
format(vaultkey,63,"Jumper-%s-%i-level",authid,PlayerClass[id]);
     
format(vaultdata,63,"%d",PlayerLevel[id]);
     
set_vaultdata(vaultkey,vaultdata);
}

public 
LoadXP(id)
{
    new 
authid[32]; 
    
get_user_authid(id,authid,31);

    new 
vaultkey[64], vaultdata[64]; 
    
    new 


    
for (0MAXCLASSESi++)
    { 
        
//Load their XP
        
format(vaultkey,63,"Jumper-%s-%i-xp",authid,CLASSES[i]);
        
get_vaultdata(vaultkey,vaultdata,63);
        
PlayerXP[id] = str_to_num(vaultdata);

        
//Load their level
        
format(vaultkey,63,"Jumper-%s-%i-level",authid,CLASSES[i]);
        
get_vaultdata(vaultkey,vaultdata,63);
        
PlayerLevel[id] = str_to_num(vaultdata);
    }

Vault:
Code:
; Don't modify!
server_language    en
Connect & disconnect code:
PHP Code:
public client_connect(id)
{
    
//Only load their XP if our SaveXP cvar is 1.
    
if(get_cvar_num("SaveXP") == 1) {
       
         
LoadXP(id);

         
//Add a message if you want....
         
client_print(idprint_chat"[HNS XP Mod] XP Loaded!");
         
client_print(idprint_chat"[HNS XP Mod] You are a %s with level %s and %s XP"PlayerClass[id], PlayerLevel[id], PlayerXP[id]);
    }
}
 
public 
client_disconnect(id)
{
    
//Only save their XP if our SaveXP cvar is 1.
    
if(get_cvar_num("SaveXP") == 1) {
    
         
SaveXP(id);
    }

Open choose menu:
PHP Code:
public ChooseJumper(id)
{
    if(
PlayerClass[id] == CLASS_NOTHING) {
        
LoadXP(id);
    }else{
         
SaveXP(id);
    }
    
LoadXP(id);
    new 
menu[192];
    
    
//Add keys for how many classes you have + exit key.
    
new keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;

    
    
//Here we write the menu options..
    
format(menu191"HNS XP Mod: Choose a Jumper^n^n1. Jumper^n2. BHopper^n3. CHopper^n4. Noob^n^n0. Exit");
    
    
//We created a menu in plugin_init() and now we make the plugin know that its this menu it has to show.
    
show_menu(idkeysmenu, -1"menu_ChooseJumper");
    
    return 
PLUGIN_CONTINUE;
}
  
public 
DoChooseJumper(idkey)
{
    
// Remeber that the keys starts on 0...
    
if(key == 0) {
       
         
//Lets check if the player allready has Jumper...
         
if(PlayerClass[id] == CLASS_JUMPER) {
         
              
//Make a message here if you want...
              
client_print(idprint_chat"[HNS XP Mod] You are already a Jumper! Choose something else!");
              
              
//Open the menu again...
              
ChooseJumper(id);
              
              
//Exit...
              
return PLUGIN_HANDLED;
         }        

         
//Now, if the player didnt have Jumper allready, we'll set his class to jumper.
         
PlayerClass[id] = CLASS_JUMPER;
         
         
//Make a message if you want...
         
client_print(idprint_chat"[HNS XP Mod] You are now a Jumper!");
    }        
    
    
//Im doing the same on all other buttons...
         
    
if(key == 1) {
         
         if(
PlayerClass[id] == CLASS_BHOPPER) {
              
              
client_print(idprint_chat"[HNS XP Mod] You are already a BHopper! Choose something else!");
              
ChooseJumper(id);
              return 
PLUGIN_HANDLED;
         }
                   
         
PlayerClass[id] = CLASS_BHOPPER
         client_print
(idprint_chat"[HNS XP Mod] You are now a BHopper!");
    }
    
    if(
key == 2) {
         
         if(
PlayerClass[id] == CLASS_CHOPPER) {
              
              
client_print(idprint_chat"[HNS XP Mod] You are already a CHopper! Choose something else!");
              
ChooseJumper(id);
              return 
PLUGIN_HANDLED;
         }
                   
         
PlayerClass[id] = CLASS_CHOPPER;
         
client_print(idprint_chat"[HNS XP Mod] You are now a CHopper!");
    }    

    if(
key == 3) {
         
         if(
PlayerClass[id] == CLASS_NOOB) {
              
              
client_print(idprint_chat"[HNS XP Mod] You are already a Noob! Choose something else!");
              
ChooseJumper(id);
              return 
PLUGIN_HANDLED;
         }
                   
         
PlayerClass[id] = CLASS_NOOB;
         
client_print(idprint_chat"[HNS XP Mod] You are now a Noob!");
    }
      
    
//Show new HUD after picking class.
    //Ill get back to this later...
    
ShowHUD(id);
    
    return 
PLUGIN_HANDLED;

I hope someone can help me
Thank you in advance.

Regards
[JPro] ReTaRD [ToY]
JProReTaRD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-10-2009 , 09:29   Re: Won't save info in vault?
Reply With Quote #2

You can check the vault file @ data\vault.ini to verify if your data is being properly saved.

You should also consider using nVault instead: http://forums.alliedmods.net/showthread.php?t=91503
__________________

Last edited by Bugsy; 05-10-2009 at 09:43.
Bugsy is offline
JProReTaRD
Member
Join Date: May 2009
Location: Denmark, KBH
Old 05-10-2009 , 10:01   Re: Won't save info in vault?
Reply With Quote #3

I checked the vault file and nothing is being saved nor loaded.

Can you please help me with that? - or maybe correct my code to Nvault and guide me through it?


Regards
[JPro] ReTaRD [ToY]
JProReTaRD is offline
JProReTaRD
Member
Join Date: May 2009
Location: Denmark, KBH
Old 05-10-2009 , 11:38   Re: Won't save info in vault?
Reply With Quote #4

I just noticed something - It does save, but its only saving Ju.

Vault.ini

Code:
; Don't modify!
server_language    da
Ju
JProReTaRD is offline
Reply


Thread Tools
Display Modes

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 01:29.


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