Raised This Month: $ Target: $400
 0% 

[SOLVED] Saving upgrades with nVault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-25-2015 , 15:57   Re: Saving upgrades with nVault
Reply With Quote #1

It's only yes/no.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-25-2015 , 17:04   Re: Saving upgrades with nVault
Reply With Quote #2

Untested

Edit: Added load\save data on authorized\disconnect.
PHP Code:

#include <amxmodx>
#include <nvault>

new const szVersion[] = "0.1";

const 
MAXPLAYERS 32;

enum UpgradeTypes
{
    
utIncAlienSpeed,
    
utAddAlienHealth,
    
utAddPredHealth,
    
utDecrScreamCooldown,
    
utUnlockUltraClasses
}

enum UpgradeInfo
{
    
szDescription64 ],
    
iValue,
    
szMessage64 ]
}

new const 
g_UpgradesUpgradeTypes ][ UpgradeInfo ] = 
{
    { 
"Increase Alien Speed" 2130 "Your ^3Alien running speed ^1is now ^4increased" } ,
    { 
"Additional Alien Health" 2650 "You will now get more ^3health points ^1as an ^4Alien" } ,
    { 
"Additional predator Health" 3200 "You will now get more ^3health points ^1as a ^4Predator" } ,
    { 
"Decrease Scream Cooldown" 750 "You can now ^3scream ^1more often" } ,
    { 
"Unlock Ultra Classes" 5000 "You now have access to the ^3Ultra Classes^1" }
};

new 
g_PlayerUpgradesMAXPLAYERS ];
new 
g_szAuthIDMAXPLAYERS ][ 34 ];
new 
g_Vault;

public 
plugin_init() 
{
    
register_plugin"Upgrade Example" szVersion "bugsy" );

    if ( ( 
g_Vault nvault_open"upgrades" ) ) == INVALID_HANDLE )
        
set_fail_state"Error opening nvault" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
    
LoadUpgradesid );
}

public 
client_disconnectid )
{
    
SaveUpgradesid );
}

public 
AddUpgradeiPlayer UpgradeTypes:utUpgrade )
{
    
g_PlayerUpgradesiPlayer ] |= ( << _:utUpgrade );
    
    
client_printiPlayer print_chat "%s upgrade added: %s" g_UpgradesutUpgrade ][ szDescription ] , g_UpgradesutUpgrade ][ szMessage ] );
}

public 
RemoveUpgradeiPlayer UpgradeTypes:utUpgrade )
{
    
g_PlayerUpgradesiPlayer ] &= ~( << _:utUpgrade );
    
    
client_printiPlayer print_chat "%s upgrade has been removed" g_UpgradesutUpgrade ][ szDescription ] );
}

public 
ClearUpgradesiPlayer UpgradeTypes:utUpgrade )
{
    
g_PlayerUpgradesiPlayer ] = _:0;
    
    
client_printiPlayer print_chat "All upgrades have been removed" );
}

public 
bool:PlayerHasUpgradeiPlayer UpgradeTypes:utUpgrade )
{
    return 
bool:!!( g_PlayerUpgradesiPlayer ] & ( << _:utUpgrade ) );
}

public 
SaveUpgradesid )
{
    new 
szVal12 ];
    
    
num_to_strg_PlayerUpgradesid ] , szVal charsmaxszVal ) );
    
nvault_setg_Vault g_szAuthIDid ] , szVal );
}

public 
LoadUpgradesid )
{
    
g_PlayerUpgradesid ] = nvault_getg_Vault g_szAuthIDid ] );

__________________

Last edited by Bugsy; 10-26-2015 at 16:45.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode