Veteran Member
Join Date: Sep 2019
Location: Egypt
|
09-08-2020
, 20:42
Re: nVault Tutorial
|
#105
|
Quote:
Originally Posted by Bugsy
Think about it logically.
1. Read this tutorial again
2. Read how nvault_remove() works, specifically what you pass to it.
http://www.amxmodx.org/api/nvault/nvault_remove
Code:
public ResetBank(id)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
if (access(id, FLAGS_RESET_BANK))
{
//Why are you retrieving the name when it is never used?
get_user_name( id, szAdminName, charsmax(szAdminName))
get_user_authid( id, szAdminAuthid, charsmax(szAdminAuthid))
new szAuth[35], szTemp[10];
get_user_authid(id, szAuth, charsmax(szAuth));
//Why are you formatting the money value into szTemp? nVault stores data using a KEY and you need only this to remove a vault record.
formatex(szTemp, charsmax(szTemp), "%i", iMoney[id]);
//No, nvault remove works by specifying the vault iD (iVault) and the key for the data to be removed (szAuth)
//You basically used nvault_remove() as you would to SET data in the vault with nvault_set().
nvault_remove(iVault, szAuth, szTemp);
console_print(id, "[ADMIN] %s Reset Bank", szAdminName)
Log("[RESETMONEY] Admin: %s || SteamID: %s Reset Bank", szAdminName, szAdminAuthid)
ChatColor(0, "^x01[ADMIN]^x04 %s^x01: Reset bank.", szAdminName)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
|
I read it again is this correct ?? if it's not then please give me an example
PHP Code:
public ResetBank(id)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
if (access(id, FLAGS_RESET_BANK))
{
new szData[8];
new szKey[40];
get_user_name( id, szAdminName, charsmax(szAdminName))
get_user_authid(id, szPlayerID, charsmax(szPlayerID));
formatex( szKey , charsmax( szKey ) , "%s", szPlayerID[id] );
formatex( szKey , charsmax( szKey ) , "%i", iMoney[id] );
nvault_remove( iVault , szKey , szData );
console_print(id, "[ADMIN] %s Reset Bank", szAdminName)
Log("[RESETMONEY] Admin: %s || SteamID: %s Reset Bank", szAdminName, szPlayerID)
ChatColor(0, "^x01[ADMIN]^x04 %s^x01: Reset bank.", szAdminName)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
Edit: I did it but not worked too
PHP Code:
public ResetBank(id)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
if (access(id, FLAGS_RESET_BANK))
{
new szPlayer[32]
read_argv(1, szPlayer, charsmax(szPlayer))
new iPlayer = find_player("a", szPlayer)
if(iPlayer)
{
iMoney[iPlayer] = 0;
}
new szData[32], iTimestamp
if(nvault_lookup(iVault, szPlayer, szData, charsmax(szData), iTimestamp))
nvault_remove(iVault, szPlayer)
get_user_name( id, szAdminName, charsmax(szAdminName))
get_user_authid(id, szPlayerID, charsmax(szPlayerID));
console_print(id, "[ADMIN] %s Reset Bank", szAdminName)
Log("[RESETMONEY] Admin: %s || SteamID: %s Reset Bank", szAdminName, szPlayerID)
ChatColor(0, "^x01[ADMIN]^x04 %s^x01: Reset bank.", szAdminName)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
Last edited by Supremache; 09-08-2020 at 20:52.
|
|