AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ] Fix add ammo (https://forums.alliedmods.net/showthread.php?t=174695)

ShLuMieL 12-23-2011 22:05

[REQ] Fix add ammo
 
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

kiki33hun 12-24-2011 03:07

Re: [REQ] Fix add ammo
 
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;



Devil259 12-24-2011 05:53

Re: [REQ] Fix add ammo
 
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.

ConnorMcLeod 12-24-2011 06:00

Re: [REQ] Fix add ammo
 
Quote:

Originally Posted by Devil259 (Post 1618776)
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)



ShLuMieL 12-24-2011 08:06

Re: [REQ] Fix add ammo
 
i want if i buy 2 times it add me 2 bullet not stay on 1 bullet.

Devil259 12-24-2011 08:07

Re: [REQ] Fix add ammo
 
Quote:

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

addBpAmmo( id , CSW_AWP , 1 )


All times are GMT -4. The time now is 11:50.

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