AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_ammo (https://forums.alliedmods.net/showthread.php?t=89317)

One 04-04-2009 19:54

get_user_ammo
 
PHP Code:

new weapon_list[][]=
{
    
CSW_P228,
    
CSW_SCOUT,
    
CSW_XM1014,
    
CSW_MAC10,
    
CSW_AUG,
    
CSW_ELITE,
    
CSW_FIVESEVEN,
    
CSW_UMP45,
    
CSW_SG550,
    
CSW_GALIL,
    
CSW_FAMAS,
    
CSW_USP,
    
CSW_GLOCK18,
    
CSW_AWP,
    
CSW_MP5NAVY,
    
CSW_M249,
    
CSW_M3,
    
CSW_M4A1,
    
CSW_TMP,
    
CSW_G3SG1,
    
CSW_DEAGLE,
    
CSW_SG552,
    
CSW_AK47,
    
CSW_P90


PHP Code:

new weapon1clip1ammo1
                get_user_ammo
(idweapon1clip1ammo1)
                if (
ammo1 <= 5)
                if (
clip1 <= 5)
                {
//do


lol?? i just wanna check if players ammo/clip is lower then 5 :O whats wrong?

BOYSplayCS 04-04-2009 19:57

Re: get_user_ammo
 
Don't hold me to it, but I think you can do it like:
(I'm new to this stuff as well.)

PHP Code:

public ddf(id)
{
    new 
weapon1clip1ammo1
    get_user_ammo
(idweapon1clip1ammo1)
    if (
ammo1 <= && clip1 <= 5)
    {
        
//do
    
}
    return 
PLUGIN_HANDLED


You see, when you add "&&" you are checking two 'if' statements in one, instead of checking two different ones. This is more efficient. The code I provided SHOULD work, but I'm not sure.

One 04-04-2009 20:05

Re: get_user_ammo
 
ty but its the same :cry:

PHP Code:

public client_prethink(id)
{
    new 
button pev(id,pev_button)
    if(
button IN_RELOAD)
    {
         switch(
random_num(0,2))
        {
             case 
0:
             {
                 new 
weapon1clip1ammo1
                get_user_ammo
(idweapon1clip1ammo1)
                if (
ammo1 <= && clip1 <= 5)
                {
                
client_cmd(id,"speak l4d_radio/Reloading01.wav");
                
client_cmd(id"say_team Reloading...Need backup")
                }
                return 
PLUGIN_HANDLED
            
}
            case 
1:
            {
                new 
weapon1clip1ammo1
                get_user_ammo
(idweapon1clip1ammo1)
                if (
ammo1 <= && clip1 <= 5)
                {
                
client_cmd(id,"speak l4d_radio/Reloading02.wav");
                
client_cmd(id"say_team Realoading!")
                }
                return 
PLUGIN_HANDLED
            
}
            case 
2:
            {
                new 
weapon1clip1ammo1
                get_user_ammo
(idweapon1clip1ammo1)
                if (
ammo1 <= && clip1 <= 5)
                {
                
client_cmd(id,"speak l4d_radio/Reloading03.wav");
                
client_cmd(id"say_team Need backup!")
                }
                return 
PLUGIN_HANDLED
            
}
            case 
3:
            {
                new 
weapon1clip1ammo1
                get_user_ammo
(idweapon1clip1ammo1)
                if (
ammo1 <= && clip1 <= 5)
                {
                
client_cmd(id,"speak l4d_radio/Reloading04.wav");
                
client_cmd(id"say_team Give me backup!i´m reloading")
                }
                return 
PLUGIN_HANDLED
            
}
            
        
        } 
        
        
        
//new radioSound = random_num( 0, (sizeof radio_snd) - 1 );
        //client_cmd(id,"%s", radio_snd[ random_num( 0, charsmax( radio_snd ) ) ]);
        //client_cmd(id,"spk %s", radio_snd[radioSound( 1, charsmax( radio_snd   ) ) ]);
    
}
    return 
PLUGIN_HANDLED


bullshit howmany ammo i have, this plays the sound & prints the test.i just wont to block the spam & this plays if player has only 5 shots in weapon.

hmm whats wrong?!

One 04-09-2009 15:38

Re: get_user_ammo
 
sry for bump.:mrgreen::oops:

xPaw 04-09-2009 16:05

Re: get_user_ammo
 
PHP Code:

    new iClipiAmmoiWeapon get_user_weaponidiClipiAmmo );
    
    if( 
iAmmo <= ) {
        
client_printidprint_chat"Your ammo is under 5." );
        
        
// stuff
    
}
    
    if( 
iClip <= ) {
        
client_printidprint_chat"Your clip is under 5." );
        
        
// stuff
    



One 04-09-2009 16:07

Re: get_user_ammo
 
ty. but why isnt my own not working? hmmm :-?

hleV 04-09-2009 16:33

Re: get_user_ammo
 
Shoudn't
Code:
new weapon_list[][]=
be
Code:
new weapon_list[] =
?

xPaw 04-10-2009 03:30

Re: get_user_ammo
 
Quote:

Originally Posted by One (Post 801719)
ty. but why isnt my own not working? hmmm :-?

Becuase instead of weapon1 you should have index of weapon on player :) just read funcwiki

One 04-10-2009 08:11

Re: get_user_ammo
 
Quote:

Originally Posted by xPaw (Post 801983)
Becuase instead of weapon1 you should have index of weapon on player :) just read funcwiki

Oh yeaaaaaaaaaaaaaaa......... F*** i 4got that :)) damn


All times are GMT -4. The time now is 02:22.

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