How to check Legal weapons or not
#1

Hey guys, i want to make 2 different kinds of Weapon, the weapon with Valid Licenses (Legal) and with No License (Illegal) And i need help from you guys to make /showgun


For example, I want the /showgun command looked like this:

Weapons on %s <<< Player Name
[Legal] Desert Eagle
[Illegal] AK-47
[Illegal] Shotgun
Knife
Parachute



I wanted to copy and edit from /listguns but it makes me confused. /listguns contains server-sided and non-server sided weapons.
/listguns code
Код:
CMD:listguns(playerid, params[])
{
//	//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(playerid, COLOR_WHITE, "[USAGE] /listguns [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			new weapons[13][2], weaponname[50];
			SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
			format(string, sizeof(string), "Weapons on %s:", GetPlayerNameEx(giveplayerid));
			SendClientMessageEx(playerid, COLOR_WHITE, string);
			for (new i = 0; i < 13; i++)
			{
				GetPlayerWeaponData(giveplayerid, i, weapons[i][0], weapons[i][1]);
				if(weapons[i][0] > 0)
				{
					if(PlayerInfo[giveplayerid][pGuns][i] == weapons[i][0])
					{
						GetWeaponName(weapons[i][0], weaponname, sizeof(weaponname));
						format(string, sizeof(string), "%s (%d) Ammo (%d).", weaponname, weapons[i][0], weapons[i][1]);
						SendClientMessageEx(playerid, COLOR_GRAD1, string);
					}
					else
					{
						GetWeaponName(weapons[i][0], weaponname, sizeof(weaponname));
						format(string, sizeof(string), "%s (%d) Ammo (%d) (non server-side).", weaponname, weapons[i][0], weapons[i][1]);
						SendClientMessageEx(playerid, COLOR_GRAD1, string);
					}
				}
			}
			SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
		}
		else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "{007FFF}[Izin] {FFFFFF}You are not authorized to use this command!");
	}
	return 1;
}
I made both of this below
For the Illegal guns, the pGuns will be 0 until 13, the Legal guns will be 14 until 23
Код:
GivePlayerIllegalWeapon( playerid, WeaponID, Ammo )
{
	switch( WeaponID )
	{
  		case 0, 1:
		{
			PlayerInfo[playerid][pGuns][ 0 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 0 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 2, 3, 4, 5, 6, 7, 8, 9:
		{
			PlayerInfo[playerid][pGuns][ 1 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 1 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 22, 23, 24:
		{
			PlayerInfo[playerid][pGuns][ 2 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 2 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 25, 26, 27:
		{
			PlayerInfo[playerid][pGuns][ 3 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 3 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 28, 29, 32:
		{
			PlayerInfo[playerid][pGuns][ 4 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 4 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 30, 31:
		{
			PlayerInfo[playerid][pGuns][ 5 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 5 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 33, 34:
		{
			PlayerInfo[playerid][pGuns][ 6 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 6 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 35, 36, 37, 38:
		{
			PlayerInfo[playerid][pGuns][ 7 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 7 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 16, 17, 18, 39, 40:
		{
			PlayerInfo[playerid][pGuns][ 8 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 8 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 41, 42, 43:
		{
			PlayerInfo[playerid][pGuns][ 9 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 9 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 10, 11, 12, 13, 14, 15:
		{
			PlayerInfo[playerid][pGuns][ 10 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 10 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 44, 45, 46:
		{
			PlayerInfo[playerid][pGuns][ 11 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 11 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
	}
	return 1;
}

GivePlayerLegalWeapon( playerid, WeaponID, Ammo )
{
	switch( WeaponID )
	{
  		case 0, 1:
		{
			PlayerInfo[playerid][pGuns][ 12 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 12 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 2, 3, 4, 5, 6, 7, 8, 9:
		{
			PlayerInfo[playerid][pGuns][ 13 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 13 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 22, 23, 24:
		{
			PlayerInfo[playerid][pGuns][ 14 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 14 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 25, 26, 27:
		{
			PlayerInfo[playerid][pGuns][ 15 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 15 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 28, 29, 32:
		{
			PlayerInfo[playerid][pGuns][ 16 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 16 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 30, 31:
		{
			PlayerInfo[playerid][pGuns][ 17 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 17 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 33, 34:
		{
			PlayerInfo[playerid][pGuns][ 18 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 18 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 35, 36, 37, 38:
		{
			PlayerInfo[playerid][pGuns][ 19 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 19 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 16, 17, 18, 39, 40:
		{
			PlayerInfo[playerid][pGuns][ 20 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 20 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 41, 42, 43:
		{
			PlayerInfo[playerid][pGuns][ 21 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 21 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 10, 11, 12, 13, 14, 15:
		{
			PlayerInfo[playerid][pGuns][ 22 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 22 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
		case 44, 45, 46:
		{
			PlayerInfo[playerid][pGuns][ 23 ] = WeaponID;
			PlayerInfo[playerid][pGunsAmmo][ 23 ] = Ammo;
			GivePlayerWeapon( playerid, WeaponID, Ammo );
		}
	}
	return 1;
}
Reply
#2

This, isn't how you learn to script...

Editting the listguns command just because it lists guns, is really bad as it's checking for HACKED and picked up guns, nothing to do with legally obtained weapons.


And what I'd say you want to focus on first is the licence itself, then the rest will come easier as that's how you learn. Don't just edit some code, see how it works, and understand it.
Reply
#3

I'm still a newbie scripter and I need help in making /showgun command.
Reply
#4

There is FireArm License script.
But i want to make a "Weapon License" for each weapon to make the weapons legal or not.
Reply
#5

BUMP
Reply
#6

If you want to show "Legal" and "Illegal" you should look if the gun's id with the player is illegal in your server or legal??
Reply
#7

serverside weapons are weapons that are given to player by server and others player got with hacking
Reply
#8

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
serverside weapons are weapons that are given to player by server and others player got with hacking
He doesn't mean illegal weapon = hacked, He means illegal weapon = A weapon that a license doesn't allow you to have it.. Deadly weapons like AK and M4 these weapons shouldn't be owned unless by LEO officers in RP servers, That's what he means, actually.
Reply
#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
#10

If you were actually wanting to learn, then you'd learn how to make things, and not simply edit what appears to fit the 'need'.

As I said, this isn't a good idea... It's like you're attempting to start in the middle, where you should be starting with more simple things, and learning.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)