AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A bug in my plugin (Snipers) (https://forums.alliedmods.net/showthread.php?t=89254)

TitANious 04-04-2009 06:42

A bug in my plugin (Snipers)
 
PHP Code:

#include <amxmodx> 
#include <fun> 

#define PLUGIN        " Snipers " 
#define VERSION        "1.0" 
#define AUTHOR        "TitANious (xPaw)" 


public plugin_init( )

    
register_pluginPLUGINVERSIONAUTHOR ); 
     
    
register_clcmd"say /scout",    "cmdGiveSniper" ); 
    
register_clcmd"say /sg550",    "cmdGiveSniper" ); 
    
register_clcmd"say /g3sg1",    "cmdGiveSniper" ); 
    
register_clcmd"say /awp",    "cmdGiveSniper" ); 
    
register_clcmd"say_team /scout",    "cmdGiveSniper" ); 
    
register_clcmd"say_team /sg550",    "cmdGiveSniper" ); 
    
register_clcmd"say_team /g3sg1",    "cmdGiveSniper" ); 
    
register_clcmd"say_team /awp",    "cmdGiveSniper" ); 
    


public 
cmdGiveSniperid )
{
    new 
weapon get_user_weapon(id__); 
    new 
Arg[32], szWeapon[32], szAmmoName[32]
    
read_argv(1Argcharsmax(Arg))
    switch( 
Arg[2] ) // Arg2 is /name, Arg[0] is '/', Arg[1] is first letter but 2 weapons share so check Arg[2]
    
{
        case 
'3':
        {
            if(
weapon == CSW_G3SG1)
            {
                
szAmmoName "ammo_762nato"
            
}
            else
            {
                
client_cmd(id"slot 1; drop")
                
szWeapon "weapon_g3sg1"
                
szAmmoName "ammo_762nato"
            
}
            
give_item(idszWeapon)
            }
            case 
'c':
            {
                if(
weapon == CSW_SCOUT)
                {
                    
szAmmoName "ammo_762nato"
                
}
                else
                {
                    
client_cmd(id"slot 1; drop")
                    
szWeapon "weapon_scout"
                    
szAmmoName "ammo_762nato"
                
}
                
give_item(idszWeapon)
            }
                case 
'g':
                {
                    if(
weapon == CSW_SG550)
                    {
                        
szAmmoName "ammo_556nato"
                    
}
                    else
                    {
                        
client_cmd(id"slot 1; drop")
                        
szWeapon "weapon_sg550"
                        
szAmmoName "ammo_556nato"
                    
}
                    
give_item(idszWeapon)
                }
                    case 
'w':
                    {
                        if(
weapon == CSW_AWP)
                        {
                            
szAmmoName "ammo_338magnum"
                        
}
                        else
                        {
                            
client_cmd(id"slot 1; drop")
                            
szWeapon "weapon_awp"
                            
szAmmoName "ammo_338magnum"
                        
}
                        
give_item(idszWeapon)
                        
// 3 is the max for each ammo type, don't try to give 10.
                        
for(new ii<3i++)
                        {
                        
give_item(idszAmmoName)
                        }
                    }
                }
            } 

My bug:
Code:

Exampel:
Starting game.
I haven't bought anything
I press /scout
It dont equips, but drops



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

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