AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
|
11-27-2016
, 23:28
Re: How to save in nvault?
|
#38
|
Quote:
Originally Posted by Gasior
It's me, it's me your G A S I O R.
So I have two plugins one the one you helped me with and second one is a knife menu, which is pretty much the same just knife menu has 4 skins for all players and 2 premium. Regardless, data from those two plugins mixes up. I set up for instance /noze and skin 6 then I go on and set up /modele skin 3. When I reconnect both /modele and /noze have skin 3 as a choice.
Now the vaults should be entirely different but when I go to data/vault I have just g_Model.vault .
I couldn't get that figured so I copied the whole vault code from /modele and changed only particular bits to adress the /noze but it still mixes up data. How do I go about it?
SMA of /noze
Does it actually saves data? And why does it read from /modele? Also here's sma for /modele if you need it
|
In one of my previous posts I mentioned that I was assuming no other data was being saved within the same vault under the steam id. Since this actually is the case, you have to make the key unique for each data item being saved. For knives, I added a _knife suffix to the key. I also fixed/redid some of your code.
Untested
Spoiler
PHP Code:
#include <amxmodx>
#include <engine>
#include <nvault>
#define MAX_PLAYERS 32
#define MENUITEM_DISABLED (1<<26)
#define PLUGIN "Menu Nozy"
#define VERSION "1.0"
#define AUTHOR "Gasior"
#define TASK_INTERVAL 4.0
enum Knives
{
NoKnifeSet = -1,
Utwardzony,
FazaDopplera,
Wypalony,
Zabarwiony,
MarmurowyZanik,
GammaDoppler,
Standardowy
}
enum KnifeModels
{
ModelName[ 32 ],
PlayerModel[ 32 ],
ViewModel[ 32 ]
}
new const g_ModelData[ Knives ][ KnifeModels ] =
{
{ "Utwardzony" , "models/p_utwardzony.mdl" , "models/v_utwardzony.mdl" },
{ "Faza Dopplera" , "models/p_faza.mdl" , "models/v_faza.mdl" },
{ "Wypalony" , "models/p_wypalony.mdl" , "models/v_wypalony.mdl" },
{ "Zabarwiony" , "models/p_zabarwiony.mdl" , "models/v_zabarwiony.mdl" },
{ "Marmurowy Zanik" , "models/p_marmurowy.mdl" , "models/v_marmurowy.mdl" },
{ "Gamma Doppler" , "models/p_gamma.mdl" , "models/v_gamma.mdl" },
{ "Standardowy" , "models/p_knife.mdl" , "models/v_knife.mdl" }
};
new g_Menu;
new Knives:knife_model[ MAX_PLAYERS + 1 ];
new g_szAuthID[ MAX_PLAYERS + 1 ][ 34 ];
new zapis_vault;
public plugin_init() {
register_plugin( PLUGIN , VERSION , AUTHOR );
register_event( "CurWeapon" , "CurWeapon" , "be" , "1=1" );
g_Menu = register_menuid( "Knife Mod" );
register_menucmd( g_Menu , 1023 , "knifemenu" );
register_clcmd( "say /noze" , "display_knife" );
register_clcmd( "say /n" , "display_knife" );
zapis_vault = nvault_open( "g_Model" );
if( zapis_vault == INVALID_HANDLE )
set_fail_state( "Nie moge otworzyc pliku :/" );
}
public plugin_precache()
{
for ( new Knives:i = Utwardzony ; i < Knives ; i++ )
{
precache_model( g_ModelData[ i ][ PlayerModel ] );
precache_model( g_ModelData[ i ][ ViewModel ] );
}
}
public client_authorized( id )
{
get_user_authid( id , g_szAuthID[ id ] , charsmax( g_szAuthID[] ) );
LoadData( id );
}
public display_knife(id)
{
new menuBody[ 512 ];
add(menuBody, charsmax( menuBody ) , "\rMenu Nozy\w^n^n" );
add(menuBody, charsmax( menuBody ), "\y1. \wUtwardzony\w^n" );
add(menuBody, charsmax( menuBody ), "\y2. \wFaza Dopplera 4\w^n" );
add(menuBody, charsmax( menuBody ), "\y3. \wWypalony\w^n" );
add(menuBody, charsmax( menuBody ), "\y4. \wZabarwiony\w^n" );
add(menuBody, charsmax( menuBody ), "\y5. \wMarmurowy Zanik\r(VIP)^n" );
add(menuBody, charsmax( menuBody ), "\y6. \wGamma Doppler\r(VIP)^n^n" );
add(menuBody, charsmax( menuBody ), "\y7. \wStandardowy\w^n^n" );
add(menuBody, charsmax( menuBody ), "Odwiedz nas na \rProjektSpark.pl^n" , 0 );
add(menuBody, charsmax( menuBody ), "\r0. Exit^n" );
new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<9 );
show_menu( id , keys , menuBody , -1 , "Knife Mod" );
}
public knifemenu( id , key )
{
if ( 0 <= key <= 6 )
{
SetKnife( id , Knives:key );
SaveData( id );
}
return PLUGIN_HANDLED;
}
public SetKnife(id , Knives:Knife)
{
new Knives:iModelIndex = NoKnifeSet;
if ( get_user_weapon( id ) != CSW_KNIFE )
return PLUGIN_HANDLED
if ( MarmurowyZanik <= Knife <= GammaDoppler )
{
iModelIndex = !( get_user_flags( id ) & ADMIN_LEVEL_H ) ? Standardowy : Knife;
}
else
{
iModelIndex = Knife;
}
knife_model[ id ] = iModelIndex
entity_set_string( id , EV_SZ_viewmodel , g_ModelData[ iModelIndex ][ ViewModel ] );
entity_set_string( id , EV_SZ_weaponmodel , g_ModelData[ iModelIndex ][ PlayerModel ] );
return PLUGIN_HANDLED;
}
public CurWeapon(id)
{
SetKnife(id, knife_model[id])
return PLUGIN_HANDLED
}
public SaveData(id)
{
new szKey[ 40 ] , szData[ 3 ];
formatex( szKey , charsmax( szKey ) , "%s_knife" , g_szAuthID[ id ] );
num_to_str( _:knife_model[ id ] , szData , charsmax( szData ) );
nvault_set( zapis_vault , szKey , szData );
}
public LoadData(id)
{
new szKey[ 40 ] , szData[ 3 ] , iTS;
formatex( szKey , charsmax( szKey ) , "%s_knife" , g_szAuthID[ id ] );
if ( nvault_lookup( zapis_vault , szKey , szData , charsmax( szData ) , iTS ) )
{
knife_model[ id ] = Knives:str_to_num( szData );
}
}
__________________
|
|