AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Maximum amount of money (https://forums.alliedmods.net/showthread.php?t=90198)

Debesėlis 04-15-2009 07:26

Maximum amount of money
 
How do you make the maximum allowed cash 16,000 because now it gives up to 18,000 and then subtracts to 16,000 in the next round.

PHP Code:

cs_set_user_money(idcs_get_user_money(id) + get_cvar_num("amx_money_num"))
client_print(idprint_chat"%L"LANG_PLAYER"MONEY"get_cvar_num("amx_money_num")) 


ConnorMcLeod 04-15-2009 07:38

Re: Money
 
Quote:

Originally Posted by Debesėlis (Post 805871)
How do you make the maximum allowed cash 16,000 because now it gives up to 18,000 and then subtracts to 16,000 in the next round.

PHP Code:

new amx_money_num_pointer

public plugin_init()
{
    
amx_money_num_pointer register_cvar("amx_money_num""5000")
}

give_money(id)
{
    new 
iMoneyToGive get_pcvar_num(amx_money_num_pointer)
    new 
iPlayerMoney cs_get_user_money(id)
    
iMoneyToGive min(16000 iPlayerMoneyiMoneyToGive)
    
iPlayerMoney += iMoneyToGive
    cs_set_user_money
(id,  iPlayerMoney)
    
client_print(idprint_chat"%L"LANG_PLAYER"MONEY"iMoneyToGive

Less details :
PHP Code:

give_money(id)
{
    new 
iPlayerMoney cs_get_user_money(id)
    new 
iMoneyToGive min(16000 iPlayerMoneyget_pcvar_num(amx_money_num_pointer))
    
cs_set_user_money(id,  iPlayerMoney iMoneyToGive)
    
client_print(idprint_chat"%L"LANG_PLAYER"MONEY"iMoneyToGive


hleV 04-15-2009 07:38

Re: Money
 
Code:
new MaxMoney = 16000; new BonusMoney = get_cvar_num("amx_money_num"); // Should use PCVAR new TotalMoney = cs_get_user_money(id) + BonusMoney;   if (BonusMoney >= MaxMoney)         cs_set_user_money(id, MaxMoney); else         cs_set_user_money(id, TotalMoney);
EDIT: Too late.

ConnorMcLeod 04-15-2009 07:39

Re: Money
 
Quote:

Originally Posted by hleV (Post 805880)
Code:
new MaxMoney = 16000; new BonusMoney = get_cvar_num("amx_money_num"); // Should use PCVAR new TotalMoney = cs_get_user_money(id) + BonusMoney;   if (TotalMoney >= MaxMoney)         cs_set_user_money(id, MaxMoney); else         cs_set_user_money(id, TotalMoney);
EDIT: Too late.

Fixed.

Debesėlis 04-15-2009 08:04

Re: Money
 
Its a small bit of code from a plugin. Everything works fine, I just want to make the maximum ammount of money given to be 16,000.
When I added the code, you gave me, I started getting an error saying something about iPlayerMoney not being used... :)

PHP Code:

public money(id)
{
    if(
money_active[id] == 1)
    {    
        new 
iMoneyToGive min(16000 iPlayerMoneyget_pcvar_num(amx_money_num))
        
cs_set_user_money(id,  cs_get_user_money(id) + iMoneyToGive)
        
client_print(idprint_chat"%L"LANG_PLAYER"MONEY"iMoneyToGive)  
    }



ConnorMcLeod 04-15-2009 08:50

Re: Money
 
Edited and should be fixed.

Debesėlis 04-15-2009 09:07

Re: Money
 
Quote:

Originally Posted by ConnorMcLeod (Post 805939)
Edited and should be fixed.

How do I get text that says money has been given to you or, if you've got 16,000, that your account is full.

PHP Code:

        new MaxMoney 16000;
        new 
BonusMoney get_cvar_num("amx_money_num");
        new 
TotalMoney cs_get_user_money(id) + BonusMoney;

        if (
TotalMoney >= MaxMoney)
                
cs_set_user_money(idMaxMoney);
        else
                
cs_set_user_money(idTotalMoney);
            
client_print(idprint_chat"%L"LANG_PLAYER"MONEY"get_cvar_num("amx_money_num"));
        
        if(
MaxMoney)
        {
            
client_print(idprint_chat"%L"LANG_PLAYER"MONEY_MAX"get_cvar_num("amx_money_num"));
        } 


YamiKaitou 04-15-2009 12:02

Re: Money
 
As per the Global Forum Rules, you need to have a descriptive topic title. If you wish for this topic to stay open, please correct the topic title before you post again.

Debesėlis 04-15-2009 12:35

Re: Help with money code
 
now better?


All times are GMT -4. The time now is 02:21.

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