Post by remusdogg on Jul 21, 2015 23:09:40 GMT
Dude you remember this plugin you give'd me on Alienmods and told me to try it and see if it works? it does not work...
For example if x y z got "14k , 26k and 54k" ammo after a crush , restart , change map (after the round is ended and starts another one) there are 90% to lose all the progress and they can have "0 , 0 , 0" or "1k , 768 , 4k" or any other number/value , but in fact the lose their current ammo.....
This is the plugin you givem me , modify by you :
#include <amxmodx>
#include <nvault>
native zp_get_user_ammo_packs(id)
native zp_set_user_ammo_packs(id, amount)
//Your vault name
#define VAULT_NAME "apstore"
//Max player's ammopack that can be save in vault.
#define MAX_AMMOPACK 700000
//Max day player's ammopack can be stay in vault, set 0 = permanent.
#define DAY_PRUNE 0
new hVaultHandle, g_iName[33][32]
public plugin_init()
{
register_plugin("ZP AP Store", "0.0.1", "wbyokomo")
}
public plugin_cfg()
{
hVaultHandle = nvault_open(VAULT_NAME)
if(hVaultHandle == INVALID_HANDLE)
{
new szText[128]
formatex(szText, 127, "Error opening '%s' nVault.", VAULT_NAME)
set_fail_state(szText)
}
new day = DAY_PRUNE
if(day > 0) nvault_prune(hVaultHandle, 0, get_systime() - (DAY_PRUNE * 86400));
}
public plugin_end()
{
nvault_close(hVaultHandle)
}
public client_authorized(id)
{
get_user_name(id, g_iName[id], charsmax(g_iName))
}
public client_putinserver(id)
{
if(is_user_connected(id))
{
LoadData(id)
}
}
public client_disconnect(id)
{
SaveData(id)
}
LoadData(id)
{
new szKey[40]
formatex(szKey, 39, "%sZPAP", g_iName[id])
new iAmmo = nvault_get(hVaultHandle, szKey)
zp_set_user_ammo_packs(id, iAmmo)
}
SaveData(id)
{
new szAmmo[12], szKey[40]
formatex(szKey, 39, "%sZPAP", g_iName[id])
formatex(szAmmo, 11, "%d", zp_get_user_ammo_packs(id))
nvault_set(hVaultHandle, szKey, szAmmo)
}
So what can we do ? is there any solution to remake , edit , fix this problem? Also ill give you my current plugin that doesn't work (random people lose their ammo , doesn't matter when but it goes from 250k to 0 when you don't expect , but not after restart,change map,crush, this is the good point , you know the problem )
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 const g_szServerIP[] = "89.44.246.41:27015";
new g_save, g_ammo[33], g_ammo_can_save[33]
new cvar_save_in
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg","event_deathmsg","a")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
cvar_save_in = register_cvar("zp_ammo_save_in", "0") // 0 = name / 1 = ip / 2 = steam id
g_save = nvault_open("g_ammo_save")
new szIP[20];
get_user_ip(0, szIP, charsmax(szIP), false);
if( !equal(szIP, g_szServerIP) )
{
set_fail_state("This plugin is private !");
}
}
// Save Ammo
public zp_user_infected_post(id, infector)
{
if (g_ammo_can_save[infector])
Save_Ammo_date(infector)
if (g_ammo_can_save[id])
Save_Ammo_date(id)
}
public zp_extra_item_selected(id, itemid)
{
if (g_ammo_can_save[id])
Save_Ammo_date(id)
}
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;
}
public fw_PlayerPreThink(id)
{
if (g_ammo_can_save[id])
{
new ammo_packs = zp_get_user_ammo_packs(id)
g_ammo[id] = ammo_packs
}
return FMRES_IGNORED;
}
public client_disconnect(id)
{
if(g_ammo_can_save[id])
Save_Ammo_date(id)
}
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
public Save_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(vaultkey, 63, "%s-/", name)
}
case 1:
{
new player_ip[33]
get_user_ip(id, player_ip, 32);
format(vaultkey, 63, "%s-/", player_ip)
}
case 2:
{
new AuthID[33];
get_user_authid(id, AuthID, 32);
formatex(vaultkey, 64, "%s-/", AuthID);
}
}
format(vaultdata, 255, "%i#", g_ammo[id])
nvault_set(g_save, vaultkey, vaultdata)
return PLUGIN_CONTINUE;
}
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(vaultkey, 63, "%s-/", name)
}
case 1:
{
new player_ip[33]
get_user_ip(id, player_ip, 32);
format(vaultkey, 63, "%s-/", player_ip)
}
case 2:
{
new AuthID[33];
get_user_authid(id, AuthID, 32);
formatex(vaultkey, 64, "%s-/", AuthID);
}
}
format(vaultdata, 255, "%i#", g_ammo[id])
nvault_get(g_save, vaultkey, vaultdata, 255)
replace_all(vaultdata, 255, "#", " ")
new playammo[32]
parse(vaultdata, playammo, 31)
g_ammo[id] = str_to_num(playammo)
set_ammo(id)
return PLUGIN_CONTINUE;
}
public set_ammo(id)
{
zp_set_user_ammo_packs(id, g_ammo[id])
client_print(id, print_chat, "Pachetele tale de munitie sunt: %d .", g_ammo[id])
}
Maybe this code can help you to remake the old one , or maybe you guys can fix the second one ... The main reason is that i want the plugin work on Nick name save ammo not on SteamId or Id, its a 2 years old server i think , and i cant change this type of ammo save.
So?
For example if x y z got "14k , 26k and 54k" ammo after a crush , restart , change map (after the round is ended and starts another one) there are 90% to lose all the progress and they can have "0 , 0 , 0" or "1k , 768 , 4k" or any other number/value , but in fact the lose their current ammo.....
This is the plugin you givem me , modify by you :
#include <amxmodx>
#include <nvault>
native zp_get_user_ammo_packs(id)
native zp_set_user_ammo_packs(id, amount)
//Your vault name
#define VAULT_NAME "apstore"
//Max player's ammopack that can be save in vault.
#define MAX_AMMOPACK 700000
//Max day player's ammopack can be stay in vault, set 0 = permanent.
#define DAY_PRUNE 0
new hVaultHandle, g_iName[33][32]
public plugin_init()
{
register_plugin("ZP AP Store", "0.0.1", "wbyokomo")
}
public plugin_cfg()
{
hVaultHandle = nvault_open(VAULT_NAME)
if(hVaultHandle == INVALID_HANDLE)
{
new szText[128]
formatex(szText, 127, "Error opening '%s' nVault.", VAULT_NAME)
set_fail_state(szText)
}
new day = DAY_PRUNE
if(day > 0) nvault_prune(hVaultHandle, 0, get_systime() - (DAY_PRUNE * 86400));
}
public plugin_end()
{
nvault_close(hVaultHandle)
}
public client_authorized(id)
{
get_user_name(id, g_iName[id], charsmax(g_iName))
}
public client_putinserver(id)
{
if(is_user_connected(id))
{
LoadData(id)
}
}
public client_disconnect(id)
{
SaveData(id)
}
LoadData(id)
{
new szKey[40]
formatex(szKey, 39, "%sZPAP", g_iName[id])
new iAmmo = nvault_get(hVaultHandle, szKey)
zp_set_user_ammo_packs(id, iAmmo)
}
SaveData(id)
{
new szAmmo[12], szKey[40]
formatex(szKey, 39, "%sZPAP", g_iName[id])
formatex(szAmmo, 11, "%d", zp_get_user_ammo_packs(id))
nvault_set(hVaultHandle, szKey, szAmmo)
}
So what can we do ? is there any solution to remake , edit , fix this problem? Also ill give you my current plugin that doesn't work (random people lose their ammo , doesn't matter when but it goes from 250k to 0 when you don't expect , but not after restart,change map,crush, this is the good point , you know the problem )
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 const g_szServerIP[] = "89.44.246.41:27015";
new g_save, g_ammo[33], g_ammo_can_save[33]
new cvar_save_in
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg","event_deathmsg","a")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
cvar_save_in = register_cvar("zp_ammo_save_in", "0") // 0 = name / 1 = ip / 2 = steam id
g_save = nvault_open("g_ammo_save")
new szIP[20];
get_user_ip(0, szIP, charsmax(szIP), false);
if( !equal(szIP, g_szServerIP) )
{
set_fail_state("This plugin is private !");
}
}
// Save Ammo
public zp_user_infected_post(id, infector)
{
if (g_ammo_can_save[infector])
Save_Ammo_date(infector)
if (g_ammo_can_save[id])
Save_Ammo_date(id)
}
public zp_extra_item_selected(id, itemid)
{
if (g_ammo_can_save[id])
Save_Ammo_date(id)
}
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;
}
public fw_PlayerPreThink(id)
{
if (g_ammo_can_save[id])
{
new ammo_packs = zp_get_user_ammo_packs(id)
g_ammo[id] = ammo_packs
}
return FMRES_IGNORED;
}
public client_disconnect(id)
{
if(g_ammo_can_save[id])
Save_Ammo_date(id)
}
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
public Save_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(vaultkey, 63, "%s-/", name)
}
case 1:
{
new player_ip[33]
get_user_ip(id, player_ip, 32);
format(vaultkey, 63, "%s-/", player_ip)
}
case 2:
{
new AuthID[33];
get_user_authid(id, AuthID, 32);
formatex(vaultkey, 64, "%s-/", AuthID);
}
}
format(vaultdata, 255, "%i#", g_ammo[id])
nvault_set(g_save, vaultkey, vaultdata)
return PLUGIN_CONTINUE;
}
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(vaultkey, 63, "%s-/", name)
}
case 1:
{
new player_ip[33]
get_user_ip(id, player_ip, 32);
format(vaultkey, 63, "%s-/", player_ip)
}
case 2:
{
new AuthID[33];
get_user_authid(id, AuthID, 32);
formatex(vaultkey, 64, "%s-/", AuthID);
}
}
format(vaultdata, 255, "%i#", g_ammo[id])
nvault_get(g_save, vaultkey, vaultdata, 255)
replace_all(vaultdata, 255, "#", " ")
new playammo[32]
parse(vaultdata, playammo, 31)
g_ammo[id] = str_to_num(playammo)
set_ammo(id)
return PLUGIN_CONTINUE;
}
public set_ammo(id)
{
zp_set_user_ammo_packs(id, g_ammo[id])
client_print(id, print_chat, "Pachetele tale de munitie sunt: %d .", g_ammo[id])
}
Maybe this code can help you to remake the old one , or maybe you guys can fix the second one ... The main reason is that i want the plugin work on Nick name save ammo not on SteamId or Id, its a 2 years old server i think , and i cant change this type of ammo save.
So?