AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to take money? (https://forums.alliedmods.net/showthread.php?t=95505)

PsYChOPaTiQuE 06-24-2009 10:32

How to take money?
 
Hello

I make a menu but I don't find the code to take some money of a player
I know
I have that for exemple and I would like to take 2000 when the player choose this option
Code:

        case 4: 
        {
  fm_give_item(id, "weapon_hegrenade")
  fm_give_item(id, "weapon_smokegrenade")
  fm_give_item(id, "weapon_flashbang")
  fm_give_item(id, "weapon_flashbang")
        }

Thank you

alan_el_more 06-24-2009 10:36

Re: How to take money?
 
cs_get_user_money

Hawk552 06-24-2009 10:46

Re: How to take money?
 
Here's a useful stock I just wrote up:

PHP Code:

stock cs_take_user_moneyidamount )
{
    new 
money cs_get_user_moneyid )
    if ( 
money amount )
        return 
0

    cs_set_user_money
idclampmoney amount016000 ) )

    return 
1


If the user had enough money, it will take it and return 1. If they don't, it won't do anything, and will return 0.

PsYChOPaTiQuE 06-25-2009 00:25

Re: How to take money?
 
sorry but I begin in scripting and I don't know how to put it in my menu

Can you show to me please?

shadow.hk 06-25-2009 00:39

Re: How to take money?
 
PHP Code:

case 4:  
{
  
fm_give_item(id"weapon_hegrenade")
  
fm_give_item(id"weapon_smokegrenade")
  
fm_give_item(id"weapon_flashbang")
  
fm_give_item(id"weapon_flashbang")
  
cs_take_user_money(id2000)


Add this to the bottom of your script.

PHP Code:

stock cs_take_user_moneyidamount 

    new 
money cs_get_user_moneyid 
    if ( 
money amount 
        return 

 
    cs_set_user_money
idclampmoney amount016000 ) ) 
 
    return 




If you don't know how to do that you really shouldn't be scripting yet. Read up on some tutorials.

PsYChOPaTiQuE 06-25-2009 00:53

Re: How to take money?
 
Yes I try to read some tutorials :)

Thank you that's work
+Karma for you and hawk552 ;)

PsYChOPaTiQuE 06-25-2009 01:01

Re: How to take money?
 
And how to put the menu only for the tero?
I want that only the tero can open the menu with /menu

Thank you :)

SnoW 06-25-2009 06:11

Re: How to take money?
 
PHP Code:

if( get_user_teamindex ) == )
{
     
//The index player is a terrorist.


Tho you could search little.

zacky 06-25-2009 07:03

Re: How to take money?
 
Quote:

Originally Posted by SnoW (Post 856577)
PHP Code:

if( get_user_teamindex ) == )
{
     
//The index player is a terrorist.


Tho you could search little.

get_user_team isn't good, better to use cs_get_user_team:
PHP Code:

if (cs_get_user_team(id) == CS_TEAM_T) {
      
// Player is a terrorist.



SnoW 06-25-2009 07:50

Re: How to take money?
 
Quote:

Originally Posted by zacky (Post 856608)
get_user_team isn't good, better to use cs_get_user_team:

get_user_team is fine. If you've tested it and it didn't work properly then it's fine, otherwise...
It's probably true that in some cases it can return wrong results, but I've been using it always and it has never came up with wrong information.


All times are GMT -4. The time now is 15:28.

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