Raised This Month: $ Target: $400
 0% 

How to take money?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 06-24-2009 , 10:32   How to take money?
Reply With Quote #1

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
__________________
PsYChOPaTiQuE is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 06-24-2009 , 10:36   Re: How to take money?
Reply With Quote #2

cs_get_user_money
__________________
alan_el_more is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-24-2009 , 10:46   Re: How to take money?
Reply With Quote #3

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 06-25-2009 , 00:25   Re: How to take money?
Reply With Quote #4

sorry but I begin in scripting and I don't know how to put it in my menu

Can you show to me please?
__________________
PsYChOPaTiQuE is offline
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 06-25-2009 , 00:39   Re: How to take money?
Reply With Quote #5

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.
shadow.hk is offline
Send a message via MSN to shadow.hk
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 06-25-2009 , 00:53   Re: How to take money?
Reply With Quote #6

Yes I try to read some tutorials

Thank you that's work
+Karma for you and hawk552 ;)
__________________
PsYChOPaTiQuE is offline
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 06-25-2009 , 01:01   Re: How to take money?
Reply With Quote #7

And how to put the menu only for the tero?
I want that only the tero can open the menu with /menu

Thank you
__________________
PsYChOPaTiQuE is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 06-25-2009 , 06:11   Re: How to take money?
Reply With Quote #8

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

Tho you could search little.
SnoW is offline
Send a message via MSN to SnoW
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-25-2009 , 07:03   Re: How to take money?
Reply With Quote #9

Quote:
Originally Posted by SnoW View Post
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.

zacky is offline
Send a message via Skype™ to zacky
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 06-25-2009 , 07:50   Re: How to take money?
Reply With Quote #10

Quote:
Originally Posted by zacky View Post
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.
SnoW is offline
Send a message via MSN to SnoW
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 15:28.


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