well I made a menu for knifes according to certain conditions, and it works but I would like to be able to save the chosen models in nvault so I don't have to be choosing them every new map.
and I was testing how to use nvault, at the moment I understood something reading examples of some variables, but I don't understand how to save models
i try this But it does not work:
PHP Code:
//Include the nvault file
#include <nvault>
new knife_model[33], vModel[56]
new g_MenuCallback; //Create a global variable to hold our callback
new g_iVaultID
new gMemoryTableNames[64][32] // Stores players name for a key
new g_iData[33]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
register_plugin("plugin KnifeMenuSH", "1.0", "Lucas Cab Arje")
register_clcmd("say /knife", "KnifeMenu") // Para llamar al menu de fakas
//Create our callback and save it to our variable
g_MenuCallback = menu_makecallback("menuitem_callback"); //The first parameter is the public function to be called when a menu item is being shown.
// Eventos
register_event("CurWeapon","CurWeapon","be","1=1") // Para cambiar las fakas models
}
public plugin_end( )
{
nvault_close( g_iVaultID )
}
public plugin_cfg( )
{
g_iVaultID = nvault_open( "knife_vault" )
if( g_iVaultID == INVALID_HANDLE )
{
set_fail_state( "Error opening Knife Nvault" )
}
}
public client_putinserver( Player )
{
get_user_name(Player, gMemoryTableNames[Player], charsmax(gMemoryTableNames[]) )
Load_Stuff( Player )
}
public SetKnife(id, Knife)
{
if (!sh_is_active() || !is_user_alive(id) ) return; // PLUGIN_HANDLED
knife_model[id] = Knife
new szSelection[4]
switch(Knife) {
// Estas Fakas van a partir de la primera Pagina
//----------- Ace Of Katanas
case 0: {
if ( gHasAceOfKatanas[id] ) {
gHasPower[id] = true
format(vModel,55,"models/shmod/ace_v_knife.mdl")
switch_model(id)
g_iData[ id ] = str_to_num(szSelection)
}
else {
gHasPower[id] = false
}
}
//----------- Batman
case 1: {
if ( gHasBatman[id] ) {
gHasPower[id] = true
format(vModel,55,"models/shmod/batmanknife_v.mdl")
switch_model(id)
g_iData[ id ] = str_to_num(szSelection)
}
else {
gHasPower[id] = false
}
}
//----------- Chucky
case 2: {
if ( HasChucky[id] ) {
gHasPower[id] = true
format(vModel,55,"models/shmod/chucky_knife.mdl")
switch_model(id)
g_iData[ id ] = str_to_num(szSelection)
}
else {
gHasPower[id] = false
}
}
//----------- Darth Maul
case 3: {
if ( gHasDarthMaulPowers[id] ) {
gHasPower[id] = true
format(vModel,55,"models/shmod/darthmaul_knife.mdl")
switch_model(id)
g_iData[ id ] = str_to_num(szSelection)
}
else {
gHasPower[id] = false
}
}
}
new gMemoryTableNames2[ 34 ]
formatex( gMemoryTableNames2, charsmax( gMemoryTableNames2 ), "%sTEST", gMemoryTableNames[ id ] )
formatex( szSelection, charsmax( szSelection ), "%sTEST", g_iData[ id ] )
nvault_set( g_iVaultID, gMemoryTableNames2, szSelection )
}
Load_Stuff( Player )
{
new gMemoryTableNames2[ 34 ]
formatex( gMemoryTableNames2, charsmax( gMemoryTableNames2 ), "%sTEST", gMemoryTableNames[ Player ] )
nvault_get( g_iVaultID, gMemoryTableNames2 )
}
public CurWeapon(id)
{
if ( !gHasPower[id] ) return
// Set Knife Model
SetKnife(id, knife_model[id])
switch_model(id)
}
switch_model(id)
{
if (!sh_is_active() || !is_user_alive(id) ) return
if (get_user_weapon(id) == CSW_KNIFE) {
set_pev(id, pev_viewmodel2, vModel)
}
}