after reading and trying to understand some codes, I can get this that works for me at the moment,
but I realized that I would have to create a variable "g_PlayerBuyItem" for each item, do I have to continue like this or is there another way to do it?
and I know you told me to use nVault Array, but I really don't understand it and I didn't find any example of it more explained or similar to understand how to apply it in this case
At the moment this is the code that works for me:
PHP Code:
new g_PlayerBuyThanos[ MAX_PLAYERS + 1 ];
public menu_handler( id , menu , item )
{
if ( item == MENU_EXIT ) {
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new item_access, item_callback;
menu_item_getinfo( menu, item, item_access, szData, charsmax(szData), szName,charsmax(szName), item_callback );
g_Model[id] = item;
switch(item) {
// This Skins is from First Page of the Menu
//----------- Blackwidow
case 0: {
resetModel( id );
sh_chat_message(id, -1, "Seleccionaste la Skin de Blackwidow .");
}
//----------- Broly
case 1: {
resetModel( id );
sh_chat_message(id, -1, "Seleccionaste la Skin de Broly.");
}
//----------- Neo
case 2: {
resetModel( id );
sh_chat_message(id, -1, "Seleccionaste la Skin de Neo.");
}
//----------- Obi wan
case 3: {
resetModel( id );
sh_chat_message(id, -1, "Seleccionaste la Skin de Obi Wan Kenobi.");
}
//----------- Termo
case 4: {
resetModel( id );
sh_chat_message(id, -1, "Valor of this? %d", g_PlayerBuyThanos[ id ]); //That's only print for proofs
sh_chat_message(id, -1, "Seleccionaste la Skin de Termo solo por nivel.");
}
//----------- Thanos
case 5: {
resetModel( id );
sh_chat_message(id, -1, "Valor of this? %d", g_PlayerBuyThanos[ id ]); //That's only print for proofs
sh_chat_message(id, -1, "Seleccionaste la Skin de Thanos Solo de Admin.");
}
//----------- Thanos End Game
case 6: {
resetModel( id );
sh_chat_message(id, -1, "Valor of this? %d", g_PlayerBuyThanos[ id ]); //That's only print for proofs
if ( g_PlayerBuyThanos[id] != 1 ) {
new iXPToAdd = ( -5000 );
sh_set_user_xp(id, iXPToAdd, true);
g_PlayerBuyThanos[id] = 1;
}
sh_chat_message(id, -1, "Compraste la Skin de Thanos End Game.");
}
case MENU_EXIT: {
sh_chat_message(id, -1, "No Seleccionaste Ninguna Skin.");
}
//----------- Show Motd Info
default: {
show_motd( id , "Info Skins.txt" , "Info Skins." );
}
}
SaveData(id);
//lets finish up this function by destroying the menu with menu_destroy, and a return
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
//------------------------------------------------------------------------------------------------
// Save and Load Data from Nvault. //
//------------------------------------------------------------------------------------------------
public SaveData(id)
{
new szKey[ 40 ] , szData[4];
format(szData, charsmax( szData ),"%i %d",g_Model[id], g_PlayerBuyThanos[id] );
nvault_set( g_iVaultID , g_szAuthID[id], szData );
}
public LoadData(id)
{
new DataModel[4], BuyThanos[4], szData[4] , iTS;
nvault_get( g_iVaultID, g_szAuthID[ id ], szData, charsmax( szData ) );
parse( szData, DataModel, charsmax( DataModel ), BuyThanos, charsmax( BuyThanos ) );
g_Model[id] = str_to_num( DataModel );
g_PlayerBuyThanos[id] = str_to_num( BuyThanos );
if ( nvault_lookup( g_iVaultID , g_szAuthID[ id ] , szData , charsmax( szData ) , iTS ) ) {
g_Model[ id ] = str_to_num( DataModel );
g_PlayerBuyThanos[id] = str_to_num( BuyThanos );
}
else {
g_Model[id] = NoModelSet;
}
}