Put sv_smokecost to 0 if you want give it for free. Put -1 to disabled plugin. Any other value above 0 is price.
Code:
#include < amxmodx >
#include < cstrike >
#include < fun >
new g_pSmokeCost;
public plugin_init( ) {
register_plugin( "Buy Smoke", "1.0", "AMXx Community" );
register_clcmd( "say /smoke", "CmdSmoke" );
register_clcmd( "say_team /smoke", "CmdSmoke" );
g_pSmokeCost = register_cvar( "sv_smokecost", "250");
}
public CmdSmoke( const id ) {
if( cs_get_user_team( id ) != CS_TEAM_T ) {
GreenPrint( id, "^4*^1 Only Terrorists can buy a FrostNade!" );
return PLUGIN_HANDLED;
}
else if( !is_user_alive( id ) ) {
GreenPrint( id, "^4*^1 You need to be alive to buy FrostNade!" );
return PLUGIN_HANDLED;
}
new iPrice = get_pcvar_num( g_pSmokeCost );
if( iPrice < 0 ) {
GreenPrint( id, "^4*^1 Smoke-Grenades have been disabled!" );
return PLUGIN_HANDLED;
}
if( user_has_weapon( id, CSW_SMOKEGRENADE ) ) {
GreenPrint( id, "^4*^1 You already have a FrostNade!" );
return PLUGIN_HANDLED;
}
if( iPrice > 0 ) {
new iMoney = cs_get_user_money( id ) - iPrice;
if( iMoney < 0 ) {
GreenPrint( id, "^4*^1 You dont have enough money to buy a Smoke-Grenade!" );
return PLUGIN_HANDLED;
}
cs_set_user_money( id, iMoney );
}
new szName[ 32 ];
get_user_name( id, szName, 31 );
give_item( id, "weapon_smokegrenade" );
GreenPrint( 0, "^4*^3 %s^1 has bought a^4 FrostNade^1!", szName, iPrice );
return PLUGIN_HANDLED;
}
GreenPrint( const id, const message[ ], any:... ) {
new szMessage[ 192 ];
vformat( szMessage, 191, message, 3 );
static iSayText;
if( !iSayText )
iSayText = get_user_msgid( "SayText" );
message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, _, id );
write_byte( id ? id : 1 );
write_string( szMessage );
message_end( );
}