AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Item for money? (https://forums.alliedmods.net/showthread.php?t=107772)

drakeris 10-30-2009 05:20

Item for money?
 
for example i blocked the buying but nowi want to make that they could buy by command for example:
PHP Code:

register_event("say /ak100" and etc

i done the uying command but how to make so when he buys helooses my wanted ammount?

unnyquee 10-30-2009 07:48

Re: Item for money?
 
There's no such event.. after you blocked the buy commands, you can do something like this:

PHP Code:

// in your includes
#include <cstrike> // for cs_set_user_bpammo
#include <fun> // for give_item

// in your plugin_init()
pCvarCostAk register_cvar("buy_ak_cost");
register_clcmd("say /ak47""cmdBuyAK");

// in cmdBuyAk
new iMoney get_pcvar_num(pCvarCostAk);

if(
cs_get_user_money(id) < iMoney)
{
     
client_print(idprint_center"#Cstrike_TitlesTXT_Not_Enough_Money");
     return 
PLUGIN_HANDLED;
}
give_item(id"weapon_ak47");
cs_set_user_bpammo(id"weapon_ak47"0);
cs_set_weapon_ammo("weapon_ak47"30);

cs_set_user_money(idcs_get_user_money iMoney1); 


drakeris 10-30-2009 07:54

Re: Item for money?
 
i know how to give the gun but i need codefor to use money for example when palyer buys item he loooses money the amount of the guns cost so i need only how to make so he loose money after doing "/ak47"

xPaw 10-30-2009 07:55

Re: Item for money?
 
cs_get_user_money( )
cs_set_user_money( )

unnyquee 10-30-2009 08:00

Re: Item for money?
 
Edited :)
@ xPaw: You posted before this post :grrr:

xPaw 10-30-2009 08:16

Re: Item for money?
 
fixed a bit
PHP Code:

new iMoney get_pcvar_numpCvarCostAk ), iCurrentMoney cs_get_user_moneyid );

if( 
iCurrentMoney iMoney ) {
    
client_printidprint_center"#Cstrike_TitlesTXT_Not_Enough_Money" );
    
    return 
PLUGIN_HANDLED;
}

// stuff

cs_set_user_moneyidiCurrentMoney iMoney); 


drakeris 10-30-2009 08:21

Re: Item for money?
 
so how to set the cost?

<VeCo> 10-30-2009 08:23

Re: Item for money?
 
Quote:

Originally Posted by drakeris (Post 975939)
so how to set the cost?

PCVAR

unnyquee 10-30-2009 08:23

Re: Item for money?
 
The cost is the value of the pCvarCostAk..


All times are GMT -4. The time now is 17:46.

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