Raised This Month: $ Target: $400
 0% 

help with weapon ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fadetodarknezz
Member
Join Date: Oct 2007
Old 11-19-2007 , 18:40   help with weapon ammo
Reply With Quote #1

i want the gun in my hide n seek server when u start with it u have a random chance to get a gun.. i want to make it so u can only have 1 bullet..

for example.. i have a deagle.. i want it to have 1 bullet.. but when i spawn with it. i have 7 bullets and 1 ammo (7/1) i just want it to be 1/0

this is what i have been putting

EVERYTHING works perfect.. i just want it to have 1 ammo.. for any gun i choose.. like deagle

PHP Code:
if(random_num(0100) <= 5)
        {            
            
give_item(player"weapon_awp")
            
            
cs_set_user_bpammo(playerCSW_AWP1)
            
client_print(playerprint_chat"You were lucky, you got a AWP with 1 bullet (5 percent chance)")
        } 
fadetodarknezz is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-20-2007 , 00:27   Re: help with weapon ammo
Reply With Quote #2

cs_set_weapon_ammo(...) To set the ammo clip for weapons.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-20-2007 , 06:16   Re: help with weapon ammo
Reply With Quote #3

NOTE: You will have to find the weapon entity, not just weapon index / player index.

There might be a better way, but I tend to find entity by classname for the right weapon, and find the one whose owner is the player you want to do it for.

Last edited by purple_pixie; 11-20-2007 at 06:19.
purple_pixie is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-20-2007 , 10:35   Re: help with weapon ammo
Reply With Quote #4

A little stock to get the weapon entity num.
Code:
stock fm_get_weapon_id(index, const weapon[])
{
 new ent = -1;
 
 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", weapon)) != 0)
 {
  if(index == pev(ent, pev_owner))
   return ent;
 }
 return 1;
}
"cs_set_weapon_ammo(fm_get_weapon_id(id, "weapon_deagle"), 1);"
;)
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
fadetodarknezz
Member
Join Date: Oct 2007
Old 11-24-2007 , 23:40   Re: help with weapon ammo
Reply With Quote #5

Quote:
Originally Posted by Alka View Post
"cs_set_weapon_ammo(fm_get_weapon_id(id, "weapon_deagle"), 1);"
;)
PHP Code:
if(random_num(0100) <= 5)
        {            
            
give_item(player"weapon_awp")
            
            
cs_set_user_bpammo(playerCSW_AWP1)
            
client_print(playerprint_chat"You were lucky, you got a AWP with 1 bullet (5 percent chance)")
        } 
so how am i suppoused to do it in that? is it gonna be like

PHP Code:
if(random_num(0100) <= 5)
        {            
            
give_item(player"weapon_deagle")
            
            
cs_set_weapon_ammo(fm_get_weapon_id(idweapon_deagle), 1); ;)
            
client_print(playerprint_chat"You were lucky, you got a deagle with 1 bullet (5 percent chance)")
        } 
??
fadetodarknezz is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-25-2007 , 02:44   Re: help with weapon ammo
Reply With Quote #6

Copy that stock from my post above, "stock fm_get_weapon_id(index, const weapon[])", in your plugin at the end , and yes, after you give the deagle put this
Code:
cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_deagle), 1);
without ";)" lol :/
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-25-2007 , 04:42   Re: help with weapon ammo
Reply With Quote #7

if(random_num(0, 100) <= 5)
This is actually prox 5.95%.
( 0, 1, 2, 3, 4, 5 ) out of ( 0 - 100 wich is total 101 )

change 0 to 1.
[ --<-@ ] Black Rose is offline
fadetodarknezz
Member
Join Date: Oct 2007
Old 11-27-2007 , 01:15   Re: help with weapon ammo
Reply With Quote #8

still doesnt work.. i did what u said and i get these errors

/home/groups/amxmodx/tmp3/text88lMoz.sma(32) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/text88lMoz.sma(32) : error 017: undefined symbol "weapon_awp"
/home/groups/amxmodx/tmp3/text88lMoz.sma(32) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/text88lMoz.sma(32) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define Plugin "Weapon Chance"
#define Version "1.0"
#define Author "Doombringer"
#define TIME_TO_WAIT 5.0
public plugin_init()
{
 register_plugin(Plugin, Version, Author)
 register_logevent("round_start", 2, "1=Round_Start")
}
public main_func()
{
 new players[32], num
 get_players(players, num)
 
 new player
 for(new i = 0; i < num; i++)
 {
  player = players[i]
  
  if(random_num(0, 100) <= 5)
  {   
   give_item(player, "weapon_awp")
   
   cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_awp), 1);
   client_print(player, print_chat, "You were lucky, you got a AWP with 1 bullet (5 percent chance)")
  }
  
  if(random_num(0, 100) <= 1)
  {
   give_item(player, "weapon_fiveseven") 
   
   cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_fiveseven), 20);
   client_print(player, print_chat, "You were lucky, you got a five seven with 20 bullets (1 percent chance)")
  }
  
                if(random_num(0, 100) <= 10)
                {
                        give_item(player, "weapon_deagle")
                        
                        cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_deagle), 1);
                        client_print(player, print_chat, "You were lucky, you got a deagle with 1 bullet (10 percent chance)")
                }
  if(random_num(0, 100) <= 15)
  {
   give_item(player, "weapon_hegrenade")
   client_print(player, print_chat, "You were lucky, you got a hegrenade (15 percent chance)")
  }
  
                if(random_num(0, 100) <= 15)
                {
                        give_item(player, "weapon_smokegrenade")
                        client_print(player, print_chat, "You were lucky, you got a smokegrenade (15 percent chance)")
                }
  if(random_num(0, 100) <= 20)
  {
   give_item(player, "weapon_shield")   
   client_print(player, print_chat, "You were lucky, you got a shield (20 percent chance)")
  }
  if(random_num(0, 100) <= 25)
  {
   give_item(player, "weapon_glock18")
   
   cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_glock18), 2);
   client_print(player, print_chat, "You were lucky, you got a glock with 2 bullets (25 percent chance)")
  }
  if(random_num(0, 100) <= 25)
  {
   give_item(player, "weapon_usp")
   
   cs_set_weapon_ammo(fm_get_weapon_id(id, weapon_usp), 2);
   client_print(player, print_chat, "You were lucky, you got a usp with 2 bullets (25 percent chance)")
  }
 }
}
public round_start()
{
 set_task(TIME_TO_WAIT, "main_func")
}
stock fm_get_weapon_id(index, const weapon[])
{
 new ent = -1;
 
 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", weapon)) != 0)
 {
  if(index == pev(ent, pev_owner))
   return ent;
 }
 return 1;
}
fadetodarknezz is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-27-2007 , 05:10   Re: help with weapon ammo
Reply With Quote #9

Code:
#include <amxmodx> #include <fakemeta> #include <fun> #include <cstrike> #define Plugin "Weapon Chance" #define Version "1.0" #define Author "Doombringer" #define TIME_TO_WAIT 5.0 public plugin_init() {         register_plugin(Plugin, Version, Author)     register_logevent("round_start", 2, "1=Round_Start") } public main_func() {         new players[32], num     get_players(players, num)         new player         for ( new i = 0 ; i < num ; i++ ) {                 player = players[i]                 if(random_num(1, 100) <= 5)         {               give_weapon(player, CSW_AWP, 1, 0)             client_print(player, print_chat, "You were lucky, you got a AWP with 1 bullet (5 percent chance)")         }                 if(random_num(1, 100) <= 1)         {             give_weapon(player, CSW_FIVESEVEN, 20, 0)             client_print(player, print_chat, "You were lucky, you got a five seven with 20 bullets (1 percent chance)")         }                 if(random_num(1, 100) <= 10)         {             give_weapon(player, CSW_DEAGLE, 1, 0)             client_print(player, print_chat, "You were lucky, you got a deagle with 1 bullet (10 percent chance)")         }         if(random_num(1, 100) <= 15)         {             give_item(player, "weapon_hegrenade")             client_print(player, print_chat, "You were lucky, you got a hegrenade (15 percent chance)")         }                 if(random_num(1, 100) <= 15)         {             give_item(player, "weapon_smokegrenade")             client_print(player, print_chat, "You were lucky, you got a smokegrenade (15 percent chance)")         }         if(random_num(1, 100) <= 20)         {             give_item(player, "weapon_shield")               client_print(player, print_chat, "You were lucky, you got a shield (20 percent chance)")         }         if(random_num(1, 100) <= 25)         {             give_weapon(player, CSW_GLOCK18, 2, 0)             client_print(player, print_chat, "You were lucky, you got a glock with 2 bullets (25 percent chance)")         }         if(random_num(1, 100) <= 25)         {             give_weapon(player, CSW_USP, 2, 0)             client_print(player, print_chat, "You were lucky, you got a usp with 2 bullets (25 percent chance)")         }     } } public round_start() {     set_task(TIME_TO_WAIT, "main_func") } stock fm_get_weapon_id(index, const weapon[]) {     new ent = -1;         while ( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", weapon) ) != 0 ) {         if(index == pev(ent, pev_owner))             return ent;     }     return 1; } stock give_weapon(id, wpnID, ammo, bpammo) {         new weapon[32]     get_weaponname(wpnID, weapon, 31)         give_item(id, weapon)     cs_set_weapon_ammo(fm_get_weapon_id(id, weapon), ammo);     cs_set_user_bpammo(id, wpnID, cs_get_user_bpammo(id, wpnID) + bpammo) }

Last edited by [ --<-@ ] Black Rose; 11-28-2007 at 01:18.
[ --<-@ ] Black Rose is offline
fadetodarknezz
Member
Join Date: Oct 2007
Old 11-27-2007 , 18:32   Re: help with weapon ammo
Reply With Quote #10

/home/groups/amxmodx/tmp3/textDcmDGN.sma(96) : error 017: undefined symbol "wpnId"
/home/groups/amxmodx/tmp3/textDcmDGN.sma(96) : error 017: undefined symbol "wpnId"
fadetodarknezz 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 01:23.


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