Raised This Month: $51 Target: $400
 12% 

Help, how can I complete it?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
859024723
New Member
Join Date: May 2014
Location: Hong Kong
Old 05-02-2014 , 09:31   Help, how can I complete it?
Reply With Quote #1

PHP Code:
 public client_disconnect(id)
{
SaveData(id)
}
public 
SaveData(id)
{
g_vault nvault_open("basevalue")
 
new 
name[32], vaultkey[64], vaultdata[512]
get_user_name(idname31)
format(vaultkey63"%s-LevelInfo"name)
format(vaultdata511"%i %i"g_GP[id], g_SP[id])
nvault_set(g_vaultvaultkeyvaultdata)
 
nvault_close(g_vault)
return 
PLUGIN_HANDLED
}
public 
client_putinserver(id)
{
LoadData(id)
}
public 
LoadData(id)
{
g_vault nvault_open("BossLevel")
 
new 
name[32], vaultkey[64], vaultdata[512]
get_user_name(idname31)
format(vaultkey63"%s-LevelInfo"name)
 
format(vaultdata511"%i %i"g_GP[id], g_SP[id])
nvault_get(g_vaultvaultkeyvaultdata255)
replace_all(vaultdata255"#"" ")
new 
playergp[32], playersp[32]
parse(vaultdataplayergp31playersp31)
g_GP[id] = str_to_num(playergp)
g_SP[id] = str_to_num(playersp)
nvault_close(g_vault)
 
return 
PLUGIN_HANDLED

When I run this plugin, I can't save the datas.
Sorry for bad English...

Last edited by 859024723; 05-02-2014 at 09:32. Reason: Make it better
859024723 is offline
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-02-2014 , 09:36   Re: Help, how can I complete it?
Reply With Quote #2

1. this should be in plugin_init() :
PHP Code:
    g_vault nvault_open("basevalue"
2. why here is a different vault ? ( also the same problem, wrong place )
PHP Code:
g_vault nvault_open("BossLevel"
3. Please some indendantion
PHP Code:
public client_putinserver(id)
{
    
LoadData(id)
}

public 
client_disconnect(id)
{
    
SaveData(id)
}

public 
SaveData(id)
{

 
    new 
name[32], vaultkey[64], vaultdata[512]
    
get_user_name(idname31)
    
format(vaultkey63"%s-LevelInfo"name)
    
format(vaultdata511"%i %i"g_GP[id], g_SP[id])
    
nvault_set(g_vaultvaultkeyvaultdata)
 
    
nvault_close(g_vault)
    return 
PLUGIN_HANDLED
}

public 
LoadData(id)
{
 
    new 
name[32], vaultkey[64], vaultdata[512]
    
get_user_name(idname31)
    
format(vaultkey63"%s-LevelInfo"name)
 
    
format(vaultdata511"%i %i"g_GP[id], g_SP[id])
    
nvault_get(g_vaultvaultkeyvaultdata255)
    
replace_all(vaultdata255"#"" ")
    new 
playergp[32], playersp[32]
    
parse(vaultdataplayergp31playersp31)
    
g_GP[id] = str_to_num(playergp)
    
g_SP[id] = str_to_num(playersp)
    
nvault_close(g_vault)
 
    return 
PLUGIN_HANDLED

I hope i help you, if not, please post the all source code ..

The variabile you wanna save is this : g_GP[id], g_SP[id] no? , ok i will back with an edit with my save/load data my code .
EDIT:

So here is the code ( dont forgot to create new vault in plugin_init + the global variabile g_vault )

PHP Code:
public client_connect(id)

        
LoadData(id);            
}
public 
client_disconnect(id)

        
SaveData(id);
}

public 
SaveData(id)
{
        new 
PlayerName[35];
        
get_user_name(id,PlayerName,34);
       
        new 
vaultkey[64],vaultdata[256];
        
format(vaultkey,63,"%s",PlayerName);
        
format(vaultdata,255,"%i`i%",g_GP[id], g_SP[id]);
        
nvault_set(g_vault,vaultkey,vaultdata);
        return 
PLUGIN_CONTINUE;
}
public 
LoadData(id)
{
        new 
PlayerName[35];
        
get_user_name(id,PlayerName,34);
       
        new 
vaultkey[64],vaultdata[256];
        
format(vaultkey,63,"%s",PlayerName);
        
format(vaultdata,255,"%i`%i",g_GP[id], g_SP[id]);
        
nvault_get(g_vault,vaultkey,vaultdata,255);
       
        
replace_all(vaultdata255"`"" ");
       
        new 
playerxp[32], playerlevel[32];
       
        
parse(vaultdataplayerxp31playerlevel31);
       
        
g_GP[id] = str_to_num(playerxp);
        
g_SP[id] = str_to_num(playerlevel);
       
        return 
PLUGIN_CONTINUE;


Last edited by swapped; 05-02-2014 at 09:41. Reason: edit.
swapped is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-02-2014 , 09:55   Re: Help, how can I complete it?
Reply With Quote #3

Forum rules require that you use a descriptive topic title. Please change your title to be descriptive of the problem/question that you have. If you fail to do so, you risk your topic being deleted entirely.
__________________
fysiks 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 01:10.


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