AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Do not cut the money. (https://forums.alliedmods.net/showthread.php?t=84196)

ianglowz 01-22-2009 10:23

Do not cut the money.
 
I buy the weapon.But it do not cut the money.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define PLUGIN    "Stat & Weapon Menu"
#define VERSION    "1.1"
#define AUTHOR    "ianglowz"
new plugin_on;
new 
speedpricearmorpricehealthprice;
new 
mp5priceawppricescoutprice;
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR);
 
register_clcmd("say /stat" "statmenu");
 
register_clcmd("say /weapon" "weaponmenu");
 
 
plugin_on    register_cvar("sm_plugin_on","1");
 
speedprice    register_cvar("sm_speed_price","2000");
 
armorprice    register_cvar("sm_armor_price","2000");
 
healthprice    register_cvar("sm_health_price","2500");
 
mp5price    register_cvar("sm_mp5_price","3000")
 
awpprice    register_cvar("sm_awp_price","7000")
 
scoutprice    register_cvar("sm_scout_price","4000")
}
public 
statmenuid ) {
 if( 
get_pcvar_num(plugin_on) == ) {
  
  new 
menu menu_create"Choose your stat""menu_handler");
  
  
menu_additem(menu"Speed""1"0);
  
menu_additem(menu"Armor""2"0);
  
menu_additem(menu"Health""3",0);
  
  
menu_setprop(menuMPROP_EXITMEXIT_ALL);
  
menu_display(idmenu0);
 }
}
public 
menu_handler(idmenuitem) {
 if (
item == MENU_EXIT) {
  
menu_destroy(menu);
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], iName[64]
 new 
accesscallback
 
 menu_item_getinfo
(menuitemaccessdata,5iName63callback)
 
 new 
key str_to_num(data)
 switch( 
key ) {
  case 
1: {    
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(speedprice)) {
    
client_print(idprint_chat"You have selected Speed Stats."
    
set_user_maxspeed(id5.0)    
    } else {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
  
  case 
2:{
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(armorprice)) {
    
client_print(idprint_chat"You have selected Armor Stats.")
    
set_user_armor(id,200)
    } else {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
  
  case 
3:{ 
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(healthprice)) {
    
client_print(idprint_chat"You have choose Health Stats")
    
set_user_health(id,200)
    }  else  {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
 }
 
menu_destroy(menu);
 return 
PLUGIN_HANDLED;
}
public 
weaponmenuid ) {
 if( 
get_pcvar_num(plugin_on) == ) {
  
  new 
menu menu_create"Choose your stat""weapon_handler");
  
  
menu_additem(menu"MP5NAVY""1"0);
  
menu_additem(menu"AWP""2"0);
  
menu_additem(menu"SCOUT""3",0);
  
  
menu_setprop(menuMPROP_EXITMEXIT_ALL);
  
menu_display(idmenu0);
 }
}
public 
weapon_handler(idmenuitem) {
 if (
item == MENU_EXIT) {
  
menu_destroy(menu);
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], iName[64]
 new 
accesscallback
 
 menu_item_getinfo
(menuitemaccessdata,5iName63callback)
 
 new 
key str_to_num(data)
 switch( 
key ) {
  case 
1: {    
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(mp5price)) {
    
client_print(idprint_chat"You have selected MP5NAVY Weapon."
    
give_item(id "weapon_mp5navy");
    
give_item(id "ammo_9mm");
    
give_item(id "ammo_9mm");
    
give_item(id "ammo_9mm");
    } else {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
  
  case 
2:{
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(awpprice)) {
    
client_print(idprint_chat"You have selected AWP Weapon")
    
give_item(id ,"weapon_awp");
    
give_item(id ,"ammo_338magnum");
    
give_item(id ,"ammo_338magnum");
    
give_item(id ,"ammo_338magnum");
    } else {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
  
  case 
3:{ 
   new 
money cs_get_user_money(id);
   
   if (
money >= get_pcvar_num(scoutprice)) {
    
client_print(idprint_chat"You have choose SCOUT Weapon")
    
give_item(id"weapon_scout");
    
give_item(id"ammo_762nato");
    
give_item(id"ammo_762nato");
    
give_item(id"ammo_762nato");
    
give_item(id"ammo_762nato");
    }  else  {
    
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
   }
  }
 }
 
menu_destroy(menu);
 return 
PLUGIN_HANDLED;
}

public 
message(id)
{
    
client_print(id print_chat "Write /stats to get your stats.")
    
client_print(id print_chat "Also write /weapon tu buy weapon set.")
}

public 
client_putinserver()
{
    
set_task20.0 "message" "" "a" 1)
    


Help please.

Owyn 01-22-2009 10:50

Re: Do not cut the money.
 
mb you forgot to make a substract money function?... i see just give item and check money

ianglowz 01-22-2009 10:54

Re: Do not cut the money.
 
I don't get the subtract money function.It like this?

PHP Code:

-= 


Dores 01-22-2009 11:45

Re: Do not cut the money.
 
Code:
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(price_pcvar)); // Replace price_pcvar with your plugin's pcvar(s).


ianglowz 01-22-2009 23:59

Re: Do not cut the money.
 
Thanks Dores.

:)


All times are GMT -4. The time now is 01:53.

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