How to check Legal weapons or not
#9

PHP код:

stock CheckWeaponLaws
(weaponid)
{
    switch(
weaponid)
    {
        case 
24: return false;
        case 
30: return true;
        
//example, if the weapon is a deagle, returns false, if it's an AK returns true.
    
}
    return 
1;
}
CMD:listguns(playeridparams[])
{
//    //if(AdminOnDuty[playerid] < 1) return SendClientMessage(playerid, COLOR_GREY, "{007FFF}[INFO] {FFFFFF}You need to be On-Duty Administrator to use this command");
    
if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new 
string[128], giveplayerid;
        if(
sscanf(params"u"giveplayerid)) return SendClientMessageEx(playeridCOLOR_WHITE"[USAGE] /listguns [playerid]");
        if(
IsPlayerConnected(giveplayerid))
        {
            new 
weapons[13][2], weaponname[50];
            
SendClientMessageEx(playeridCOLOR_GREEN,"_______________________________________");
            
format(stringsizeof(string), "Weapons on %s:"GetPlayerNameEx(giveplayerid));
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
            for (new 
013i++)
            {
                
GetPlayerWeaponData(giveplayeridiweapons[i][0], weapons[i][1]);
                if(
weapons[i][0] > 0)
                {
                    if(
PlayerInfo[giveplayerid][pGuns][i] == weapons[i][0])
                    {
                        if(
CheckWeaponLaws(weapons[i][0])) //if the weapon id returns true, this means it's illegal.
                        
{
                            
GetWeaponName(weapons[i][0], weaponnamesizeof(weaponname));
                            
format(stringsizeof(string), "[Illegal] %s (%d) Ammo (%d)."weaponnameweapons[i][0], weapons[i][1]);
                            
SendClientMessageEx(playeridCOLOR_GRAD1string);
                        }
                        else 
//if it doesn't return true, then it means it's legal.
                        
{
                            
GetWeaponName(weapons[i][0], weaponnamesizeof(weaponname));
                            
format(stringsizeof(string), "[Legal] %s (%d) Ammo (%d)."weaponnameweapons[i][0], weapons[i][1]);
                            
SendClientMessageEx(playeridCOLOR_GRAD1string);
                        }
                    }
                    else
                    {
                        if(
CheckWeaponLaws(weapons[i][0]))
                        {
                            
GetWeaponName(weapons[i][0], weaponnamesizeof(weaponname));
                            
format(stringsizeof(string), "[Illegal] %s (%d) Ammo (%d) (non server-side)."weaponnameweapons[i][0], weapons[i][1]);
                            
SendClientMessageEx(playeridCOLOR_GRAD1string);
                        }
                        else
                        {
                            
GetWeaponName(weapons[i][0], weaponnamesizeof(weaponname));
                            
format(stringsizeof(string), "[Legal] %s (%d) Ammo (%d) (non server-side)."weaponnameweapons[i][0], weapons[i][1]);
                            
SendClientMessageEx(playeridCOLOR_GRAD1string);
                        }
                    }
                }
            }
            
SendClientMessageEx(playeridCOLOR_GREEN,"_______________________________________");
        }
        else 
SendClientMessageEx(playeridCOLOR_GRAD1"Invalid player specified.");
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"{007FFF}[Izin] {FFFFFF}You are not authorized to use this command!");
    }
    return 
1;

Simples.
Reply


Messages In This Thread
How to check Legal weapons or not - by Dirda - 09.07.2018, 11:04
Re: How to check Legal weapons or not - by Sew_Sumi - 09.07.2018, 11:14
Re: How to check Legal weapons or not - by Dirda - 09.07.2018, 11:39
Re: How to check Legal weapons or not - by Dirda - 09.07.2018, 11:46
Re: How to check Legal weapons or not - by Dirda - 10.07.2018, 05:59
Re: How to check Legal weapons or not - by JasonRiggs - 10.07.2018, 06:44
Re: How to check Legal weapons or not - by CodeStyle175 - 10.07.2018, 06:53
Re: How to check Legal weapons or not - by JasonRiggs - 10.07.2018, 06:57
Re: How to check Legal weapons or not - by ItsRobinson - 10.07.2018, 13:30
Re: How to check Legal weapons or not - by Sew_Sumi - 10.07.2018, 17:14

Forum Jump:


Users browsing this thread: 1 Guest(s)