This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Save Money


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bence98007
Member
Join Date: Jun 2012
Old 11-12-2012 , 02:27   Save Money
Reply With Quote #1

Hi!

I need a plugin, whos save my money on disconnect, and load it when i connect. Nvault please.

Thanks!
Bence98007 is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 11-12-2012 , 08:17   Re: Save Money
Reply With Quote #2

Quote:
Originally Posted by Bence98007 View Post
Hi!

I need a plugin, whos save my money on disconnect, and load it when i connect. Nvault please.

Thanks!
Try this
PHP Code:
#include <amxmodx>
#include <nvault>
#include <fakemeta>

new gVaultgMoneyMsgId

#define get_user_money(%1)    (get_pdata_int(%1, 115))

#define STARTING_MONEY_AMOUNT    5300

set_user_money(idiAmount)
{
    
set_pdata_int(id115iAmount)
    if(
is_user_alive(id))
    {
        
emessage_begin(MSG_ONEgMoneyMsgId,_id)
        
ewrite_long(iAmount)
        
ewrite_byte(0)
        
emessage_end()
    }
}

public 
plugin_init()
{
    
gVault nvault_open("money")
    
gMoneyMsgId get_user_msgid("Money")
}

public 
client_putinserver(id)
    
load_money(id)
    
public 
client_disconnect(id)
    
save_money(id)

load_money(id)
{
    new 
iAmountszAuthId[33]
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    if((
iAmount nvault_get(gVaultszAuthId)))
    {
        
set_user_money(idiAmount)
        
client_print(idprint_chat"*** Your money has been loaded!")
        return
    }
    
    
iAmount STARTING_MONEY_AMOUNT
    nvault_set
(gVaultszAuthId"0")
    
    
set_user_money(idiAmount)
    
client_print(idprint_chat"*** Your money has been loaded!")
}

save_money(id)
{
    new 
iMoney get_user_money(id)
    
    new 
szMoney[20]
    
num_to_str(iMoneyszMoney19)
    new 
szAuthId[33]; get_user_authid(idszAuthId32)
    
    
nvault_remove(gVaultszAuthId)
    
    
nvault_set(gVaultszAuthIdszMoney)

__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 11-13-2012 , 05:56   Re: Save Money
Reply With Quote #3

I'd prefer to use fvault ...
Torge is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-13-2012 , 07:16   Re: Save Money
Reply With Quote #4

Quote:
Originally Posted by Torge View Post
I'd prefer to use fvault ...
That doesn't matter.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
myusername
Senior Member
Join Date: Aug 2012
Old 12-15-2012 , 08:06   Re: Save Money
Reply With Quote #5

what if user money more than 16k? which means that server has a unlimited money?
__________________
Rest in piece.
myusername is offline
myusername
Senior Member
Join Date: Aug 2012
Old 01-18-2014 , 04:16   Re: Save Money
Reply With Quote #6

BUMP
__________________
Rest in piece.
myusername 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 12:36.


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