AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade plugin, i want menu no close. (https://forums.alliedmods.net/showthread.php?t=189001)

KillerMasa 07-02-2012 15:45

Grenade plugin, i want menu no close.
 
Hey,

i found grenade shop plugin, could you please make when players buy one grenade the menu not close, but you can close it.
PHP Code:

/* Script generated by Pawn Studio */
#include <amxmodx>
#include <cstrike>
#include <csx>
#include <fun>
#define PLUGIN "Grenade Shop"
#define AUTHOR "GXLZPGX"
#define VERSION "1.0"
new hecostflashcostsmokecost;
public 
plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
//command to open the menu
 
register_clcmd"say /nades""gshop" )
 
register_clcmd"say_team /nades""gshop" )
 
register_clcmd"say nades""gshop" )
 
register_clcmd"say_team nades""gshop" )
 
 
//cvars
 
hecost  register_cvar"gshop_hecost""500" )
 
flashcost  register_cvar"gshop_flashcost""750" )
 
smokecost  register_cvar"gshop_smokecost""500" )
}
public 
gshop(id)
{
 if( !
is_user_alive(id) )
 {
  return 
PLUGIN_HANDLED;
 }
 
 new 
menu menu_create"\yGrenade Shop""gshop_handler" )
 
 new 
szHE[32];
 
formatexszHEcharsmax(szHE), "HE Grenade %i$"get_pcvar_num(hecost) )
 
menu_additemmenuszHE"1")
 
 new 
szFLASH[32];
 
formatexszFLASHcharsmax(szFLASH), "Flash Grenade %i$"get_pcvar_num(flashcost) )
 
menu_additemmenuszFLASH"2")
 
 new 
szSMOKE[32];
 
formatexszSMOKEcharsmax(szSMOKE), "Smoke Grenade %i$"get_pcvar_num(smokecost) )
 
menu_additemmenuszSMOKE"3")
 
 
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
menu_display(idmenu0);
 
 return 
PLUGIN_HANDLED;
}
public 
gshop_handler(idmenuitem)
{
 if( 
item == MENU_EXIT )
 {
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], szName[64];
 new 
accesscallback;
 
 
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
 
 new 
key str_to_num(data);
 
 switch(
key)
 {
  case 
1:
  {
   if( !
is_user_alive(id) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   new 
money cs_get_user_money(id)
 
   if( 
money get_pcvar_num(hecost) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   if( 
user_has_weapon(idCSW_HEGRENADE) )
   {
    new 
ammo cs_get_user_bpammo(idCSW_HEGRENADE)
    
cs_set_user_bpammo(idCSW_HEGRENADEammo 1)
   } else {
    
give_itemid"weapon_hegrenade" )
   }
 
   
cs_set_user_moneyidmoney -= get_pcvar_num(hecost) )
  }
 
  case 
2:
  {
   if( !
is_user_alive(id) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   new 
money cs_get_user_money(id)
 
   if( 
money get_pcvar_num(flashcost) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   if( 
user_has_weapon(idCSW_FLASHBANG) )
   {
    new 
ammo cs_get_user_bpammo(idCSW_FLASHBANG)
    
cs_set_user_bpammo(idCSW_FLASHBANGammo 1)
   } else {
    
give_itemid"weapon_flashbang" )
   }
 
   
cs_set_user_moneyidmoney -= get_pcvar_num(flashcost) )
  }
 
  case 
3:
  {
   if( !
is_user_alive(id) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   new 
money cs_get_user_money(id)
 
   if( 
money get_pcvar_num(smokecost) )
   {
    return 
PLUGIN_HANDLED;
   }
 
   if( 
user_has_weapon(idCSW_SMOKEGRENADE) )
   {
    new 
ammo cs_get_user_bpammo(idCSW_SMOKEGRENADE)
    
cs_set_user_bpammo(idCSW_SMOKEGRENADEammo 1)
   } else {
    
give_itemid"weapon_smokegrenade" )
   }
 
   
cs_set_user_moneyidmoney -= get_pcvar_num(smokecost) )
  }
 }
 
 return 
PLUGIN_HANDLED;



<VeCo> 07-02-2012 15:53

Re: Grenade plugin, i want menu no close.
 
PHP Code:

 cs_set_user_moneyidmoney -= get_pcvar_num(smokecost) )
}
}
 
return 
PLUGIN_HANDLED

->

PHP Code:

 cs_set_user_moneyidmoney -= get_pcvar_num(smokecost) )
}
}
 
gshop(id)
 
 
return 
PLUGIN_HANDLED

This is not the request section, btw.

KillerMasa 07-02-2012 16:07

Re: Grenade plugin, i want menu no close.
 
@<VeCo>
Thank you so much, and i am sorry i thought this is the request section,
but can you make if player have not money then it like this:[IMG]http://desmond.**************/Himg189/scaled.php?server=189&filename=phototutoria.p ng&res=landing[/IMG]

<VeCo> 07-02-2012 16:12

Re: Grenade plugin, i want menu no close.
 
PHP Code:

 new szHE[32];
formatexszHEcharsmax(szHE), "HE Grenade %i$"get_pcvar_num(hecost) )
menu_additemmenuszHE"1")
 
new 
szFLASH[32];
formatexszFLASHcharsmax(szFLASH), "Flash Grenade %i$"get_pcvar_num(flashcost) )
menu_additemmenuszFLASH"2")
 
new 
szSMOKE[32];
formatexszSMOKEcharsmax(szSMOKE), "Smoke Grenade %i$"get_pcvar_num(smokecost) )
menu_additemmenuszSMOKE"3"

->

PHP Code:

 new money cs_get_user_money(id)
 new 
cost get_pcvar_num(hecost)
 new 
szHE[32];
 
formatexszHEcharsmax(szHE), "%sHE Grenade %i$"money cost "\d" "" ,cost )
 
menu_additemmenuszHE"1")
 
 
cost get_pcvar_num(flashcost)
 new 
szFLASH[32];
 
formatexszFLASHcharsmax(szFLASH), "%sFlash Grenade %i$"money cost "\d" "" ,cost )
 
menu_additemmenuszFLASH"2")
 
 
cost get_pcvar_num(smokecost)
 new 
szSMOKE[32];
 
formatexszSMOKEcharsmax(szSMOKE), "%sSmoke Grenade %i$"money cost "\d" "" ,cost )
 
menu_additemmenuszSMOKE"3"

The code is bad, btw...

KillerMasa 07-02-2012 16:30

Re: Grenade plugin, i want menu no close.
 
You are the best! >D

<VeCo> 07-02-2012 16:36

Re: Grenade plugin, i want menu no close.
 
Quote:

Originally Posted by KillerMasa (Post 1741465)
You are the best! >D, 2 warning, but it does not matter : )

They are because the code isn't idented. Maybe because you have copy/pasted it directly from here and maybe there isn't a space before the new money line.

You can just set:
PHP Code:

#pragma tabsize 0 

Or see where the lines aren't indented and fix them, because the code will look bad. However, this warning doesn't affect the actual code, so it isn't a problem.

KillerMasa 07-02-2012 16:56

Re: Grenade plugin, i want menu no close.
 
Yes, thank you fixed : ), btw i have this:
PHP Code:

formatexszHEcharsmax(szHE), "%sHE Grenade \y%i$"money cost "\d" 
"" ,cost 

And when player's don't have money the color is still yellow, How i can change it to red? (When player dont have money)

<VeCo> 07-03-2012 08:51

Re: Grenade plugin, i want menu no close.
 
PHP Code:

if(money cost)
{
formatexszHEcharsmax(szHE), "\dHE Grenade \r%i$"cost 
} else {
formatexszHEcharsmax(szHE), "HE Grenade \y%i$"cost 



KillerMasa 07-03-2012 09:22

Re: Grenade plugin, i want menu no close.
 
Where i set this?

<VeCo> 07-03-2012 09:23

Re: Grenade plugin, i want menu no close.
 
Put it instead of the line you gave.


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

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