Raised This Month: $ Target: $400
 0% 

nvault problems, need some help.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 11-28-2011 , 05:59   nvault problems, need some help.
Reply With Quote #1

Hi.

I have problems with nvault.
Sometimes my data what i need to save just lost somehow.

Here is the code :

PHP Code:
 
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <nvault>
#define PLUGIN "[ZP] Can Auto Save Ammo"
#define VERSION "0.1.0"
#define AUTHOR "HsK"
new g_saveg_ammo[33], g_ammo_can_save[33]
new 
cvar_save_in
#define MAX_SAVE 5000 // Max ammo packs save
#define MAX_SAVE2 5500 // ViP Max ammo packs save
#define APVIPACCESS ADMIN_LEVEL_H
new currentFrame2[33]
public 
plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_event("DeathMsg","event_deathmsg","a")
 
cvar_save_in register_cvar("zp_ammo_save_in""0"// 0 = name / 1 = ip / 2 = steam id
 
g_save nvault_open("g_ammo_save")
}
public 
client_PreThink(id)
{
 if(
currentFrame2[id] >= 800
 {
  if (
g_ammo_can_save[id])
   
Save_Ammo_date(id)
  
currentFrame2[id] = 0
 
}
 
currentFrame2[id]++
}
// Save Data when client kill ( infect, this is zombie event ) someone
public zp_user_infected_post(idinfector)
{
 if (
g_ammo_can_save[infector])
  
Save_Ammo_date(infector)
 
 if (
g_ammo_can_save[id])
  
Save_Ammo_date(id)
}
// save data if he buy something whit ammo packs ( ammo packs is like money or something like that )
public zp_extra_item_selected(iditemid)
{
 if (
g_ammo_can_save[id])
  
Save_Ammo_date(id)
}
// When someone kill or die save data
public event_deathmsg()
{
 new 
killer read_data(1)
 new 
victim read_data(2)
 if (!
killer && !victim)
  return 
PLUGIN_CONTINUE;
 if (
g_ammo_can_save[killer])
  
Save_Ammo_date(killer)
   
 if (
g_ammo_can_save[victim])
  
Save_Ammo_date(victim)
 return 
PLUGIN_CONTINUE;
}
// when client disconnect , save data
public client_disconnect(id)
{
 if(
g_ammo_can_save[id])
  
Save_Ammo_date(id)
}

// When client connect, load data and set a bool cansave to true.
// I dont know why this plugin need that code :D
// Start
public client_putinserver(id)
 
set_task(2.0"now_can_save"id)
public 
now_can_save(id)
{
 
Load_Ammo_date(id)
 
set_task(0.5"can_save_true"id)
}
public 
can_save_true(id)
 
g_ammo_can_save[id] = true
// End
// I dont know why this plugin need that code :D

// save data code
public Save_Ammo_date(id)
{
 new 
vaultkey[64], vaultdata[256]
 new 
ammo_packs zp_get_user_ammo_packs(id)
 
g_ammo[id] = ammo_packs
 
switch (get_pcvar_num(cvar_save_in))
 {
  case 
0:
  {
   new 
name[33];
   
get_user_name(id,name,32)
   
   
format(vaultkey63"%s-/"name)
  }
  case 
1:
  {
   new 
player_ip[33]
   
get_user_ip(idplayer_ip32);
   
format(vaultkey63"%s-/"player_ip)
  }
  case 
2:
  {
   new 
AuthID[33];
   
get_user_authid(idAuthID32);
   
   
formatex(vaultkey64"%s-/"AuthID);
  }
 }
 
format(vaultdata255"%i#"g_ammo[id])
 
 
nvault_set(g_savevaultkeyvaultdata)
 return 
PLUGIN_CONTINUE;
}
// Load data code
public Load_Ammo_date(id)
{
 new 
vaultkey[64], vaultdata[256]
 switch (
get_pcvar_num(cvar_save_in))
 {
  case 
0:
  {
   new 
name[33];
   
get_user_name(id,name,32)
   
   
format(vaultkey63"%s-/"name)
  }
  case 
1:
  {
   new 
player_ip[33]
   
get_user_ip(idplayer_ip32);
   
format(vaultkey63"%s-/"player_ip)
  }
  case 
2:
  {
   new 
AuthID[33];
   
get_user_authid(idAuthID32);
   
   
formatex(vaultkey64"%s-/"AuthID);
  }
 }
 
format(vaultdata255"%i#"g_ammo[id])
 
 
nvault_get(g_savevaultkeyvaultdata255)
 
replace_all(vaultdata255"#"" ")
 
 new 
playammo[32]
 
parse(vaultdataplayammo31)
 
g_ammo[id] = str_to_num(playammo)
 
 
set_ammo(id)
 
 return 
PLUGIN_CONTINUE;
}
// Now set that data by anyohter plugin native 
public set_ammo(id)
{
 if (
get_user_flags(id) & APVIPACCESS)
 {
  if (
g_ammo[id] > MAX_SAVE2)
  {
   
zp_set_user_ammo_packs(idMAX_SAVE2)
   
g_ammo[id] = MAX_SAVE2
  
}
  else
  
  
zp_set_user_ammo_packs(idg_ammo[id])
  
client_print(idprint_chat"Your Ammo is : %d (8000Max)"g_ammo[id])
 }
 else
 {
  if (
g_ammo[id] > MAX_SAVE)
  {
   
zp_set_user_ammo_packs(idMAX_SAVE)
   
g_ammo[id] = MAX_SAVE
  
}
  else
  
  
zp_set_user_ammo_packs(idg_ammo[id])
  
client_print(idprint_chat"Your Ammo is : %d (7500Max)"g_ammo[id])
 }
}
// When client change his name then load data. ( For this they can not do a multi ammo packs by copyng anyohter players money. )
public client_infochanged(id)
{
 new 
newname[32],oldname[32]
 
get_user_info(id"name"newname,31)
 
get_user_name(id,oldname,31
    
 if(!
equal(newnameoldname))
 {
  
Load_Ammo_date(id)
 }

Sometime data lost or something.
But not the all players data,
Like sometimes one or two players lost ammo packs, i dont know what is wrong.

PS: I dont know that, what gone wrong
Mayby the plugin save player name wrong or something.


I hope you guys can help me.
Thanks!
.Dare Devil. is offline
 


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 08:24.


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