Raised This Month: $ Target: $400
 0% 

[REQ] Fix add ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 12-23-2011 , 22:05   [REQ] Fix add ammo
Reply With Quote #1

hey to all

someone ca fix this plugin pls?

PHP Code:
#include <amxmodx>
#include <cstrike>
#define PLUGIN "Ammo"    
#define VERSION "1.0"    
#define AUTHOR "Asaf Mazon"  
public plugin_init()
{    
 
register_plugin(PLUGINVERSIONAUTHOR)    
 
 
register_clcmd("say /ammo""ammo"); 
}    
public 
ammo(id)
{
 new 
menu menu_create("Awp""ammo2");
 
menu_additem(menu"\wAwp 1 Bullet""1"0);
 
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
 
menu_display(idmenu0);
 return 
PLUGIN_HANDLED;
}
public 
ammo2(idmenuitem)
{
 if(
item == MENU_EXIT)
 {
  
menu_destroy(menu);
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], szName[64];
 new 
accesscallback;
 
menu_item_getinfo(menuitemaccessdata,5szName,63callback);
 
 new 
key str_to_num(data);
 new 
awp cs_get_user_bpammo(idCSW_AWP)
 
 switch(
key)
 {
  case 
1:
  {
   
cs_set_user_bpammo(idawp 1)
   
  }
 }
 
menu_destroy(menu);
 return 
PLUGIN_HANDLED;

i want if now i have awp its will add me 1 bullet and if i press again its

add me more 1 bullet and if i press it again its will add me more 1 bullet.

Thanks's
ShLuMieL is offline
kiki33hun
Veteran Member
Join Date: Jul 2011
Location: Magyarország
Old 12-24-2011 , 03:07   Re: [REQ] Fix add ammo
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta_util>

#define PLUGIN "Ammo"    
#define VERSION "1.0"    
#define AUTHOR "Asaf Mazon"  
public plugin_init()
{    
 
register_plugin(PLUGINVERSIONAUTHOR)    
 
 
register_clcmd("say /ammo""ammo"); 
}    
public 
ammo(id)
{
 new 
menu menu_create("Awp""ammo2");
 
menu_additem(menu"\wAwp 1 Bullet""1"0);
 
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
 
menu_display(idmenu0);
 return 
PLUGIN_HANDLED;
}
public 
ammo2(idmenuitem)
{
 if(
item == MENU_EXIT)
 {
  
menu_destroy(menu);
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], szName[64];
 new 
accesscallback;
 
menu_item_getinfo(menuitemaccessdata,5szName,63callback);
 
 new 
key str_to_num(data);
 
 switch(
key)
 {
  case 
1:
  {
      
      new 
awp fm_give_item(id"weapon_awp");
      
cs_set_weapon_ammo(awp1);
   
  }
 }
 
menu_destroy(menu);
 return 
PLUGIN_HANDLED;

__________________
kiki33hun is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-24-2011 , 05:53   Re: [REQ] Fix add ammo
Reply With Quote #3

If you want to add 1 bpammo, use this

Code:
stock addBpAmmo( index , weapon , num ) {      new newAmmo = (cs_get_user_bpammo( id , weapon )+num)      cs_set_user_bpammo( index , weapon , newAmmo ) }

addBpAmmo( id , CSW_AWP , 1 )

PS : To remove ammo, use negative values.

PS2: Untested.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-24-2011 , 06:00   Re: [REQ] Fix add ammo
Reply With Quote #4

Quote:
Originally Posted by Devil259 View Post
Code:
stock addBpAmmo( index , weapon , num ) {      cs_set_user_bpammo( index , weapon , cs_get_user_bpammo( id , weapon ) + num ) }
Simplified.


Following one could be usefull :
PHP Code:
enum
{
    
ammo_none,
    
ammo_338magnum 1,
    
ammo_762nato,
    
ammo_556natobox,
    
ammo_556nato,
    
ammo_buckshot,
    
ammo_45acp,
    
ammo_57mm,
    
ammo_50ae,
    
ammo_357sig,
    
ammo_9mm
}

new const 
g_szAmmoNames[][] = {
    
"",
    
"338magnum",
    
"762nato",
    
"556natobox",
    
"556nato",
    
"buckshot",
    
"45acp",
    
"57mm",
    
"50ae",
    
"357sig",
    
"9mm"
}

new const 
g_iMaxAmmo[] = {-1309020090321001003552120}
new const 
g_iDefaultAmmo[] = {-1103030308125071330}

addBpAmmo(idiIdamount = -1max = -1)
{
    new 
iAmmoType
    
switch(iId)
    {
        case 
CSW_AWPiAmmoType ammo_338magnum
        
case CSW_SCOUTCSW_AK47CSW_G3SG1iAmmoType ammo_762nato
        
case CSW_M249iAmmoType ammo_556natobox
        
case CSW_FAMASCSW_M4A1CSW_AUGCSW_SG550CSW_GALICSW_SG552iAmmoType ammo_556nato
        
case CSW_M3CSW_XM1014iAmmoType ammo_buckshot
        
case CSW_USPCSW_UMP45CSW_MAC10iAmmoType ammo_45acp
        
case CSW_FIVESEVENCSW_P90iAmmoType ammo_57mm
        
case CSW_DEAGLEiAmmoType ammo_50ae
        
case CSW_P228iAmmoType ammo_357sig
        
case CSW_GLOCK18CSW_MP5NAVYCSW_TMPCSW_ELITEiAmmoType ammo_9mm
        
default:return 0
    
}
    switch( 
max )
    {
        case -
1:max g_iMaxAmmo[iAmmoType]
        case 
0:max 999999999
    
}
    if( 
amount == -// give default
    
{
        
amount g_iDefaultAmmo[iAmmoType]
    }
    
ExecuteHamB(Ham_GiveAmmoidamountg_szAmmoNames[iAmmoType], max)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-24-2011 at 06:13.
ConnorMcLeod is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-24-2011 , 08:07   Re: [REQ] Fix add ammo
Reply With Quote #5

Quote:
Originally Posted by Devil259 View Post
Code:
stock addBpAmmo( index , weapon , num ) {      cs_set_user_bpammo( index , weapon , cs_get_user_bpammo( id , weapon ) + num ) }
addBpAmmo( id , CSW_AWP , 1 )
__________________
You can do anything you set your mind to, man.

Devil259 is offline
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 12-24-2011 , 08:06   Re: [REQ] Fix add ammo
Reply With Quote #6

i want if i buy 2 times it add me 2 bullet not stay on 1 bullet.
ShLuMieL is offline
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 11:50.


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