Weapons Drop
#1

Hey guys, well I'm using Insanity's FS, the drop gun fs which is this: https://sampforum.blast.hk/showthread.php?tid=171730

I tried to restrict some weapons, using the ForbidWeaponDrop but they ain't working. I just tried with the colt, and shotgun, but they ain't working. Here's my code below. Any ideas?

Код:
public ForbidWeaponDrop(weaponid)
{
	weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
	weaponid = (weaponid > 22 || weaponid < 0) ? (0) : (weaponid);
	weaponid = (weaponid > 25 || weaponid < 0) ? (0) : (weaponid);
	ForbiddenWeaponsDrop[weaponid] = true;
	return 1;
}

public FreeWeaponDrop(weaponid)
{
	weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
	weaponid = (weaponid > 22 || weaponid < 0) ? (0) : (weaponid);
	weaponid = (weaponid > 25 || weaponid < 0) ? (0) : (weaponid);
	ForbiddenWeaponsDrop[weaponid] = false;
	return 1;
}
Another thing which I wanted to implement is exactly like in Singleplayer where if a player pickups the same kind of weapon, unless they hit the TAB button, the gun is not replaced. Although in Insanity's FS, say If I had an m4 and I died dropping it, and I respawned with an AK47 and when I pickup my previous dropped weapons, as soon as I pickup the m4, it replaces the AK47. So I want the similar Singleplayer thing with the TAB key. Can anyone help me on this?
+REP to everyone that helps me with this endeavor. Thank you.
Reply
#2

Well, first look at the logic you have right now:
pawn Код:
weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
weaponid = (weaponid > 22 || weaponid < 0) ? (0) : (weaponid);
weaponid = (weaponid > 25 || weaponid < 0) ? (0) : (weaponid);
Each line says "if weapon id is bigger than X or less than 0, return 0, otherwise return weapon id". First line prevents banning all weapons with ids (-Inf; 0) U (46; Inf), second line (-Inf; 0) U (22; Inf), third (-Inf; 0) U (25; Inf). Now when you sum it up, you get (-Inf; 0) U (22; Inf), i.e you could remove all lines except middle one to get exactly the same result. I think you wanted something more like:
pawn Код:
weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
if (!(weaponid == 22 || weaponid == 25)) weaponid = 0;
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Well, first look at the logic you have right now:
pawn Код:
weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
weaponid = (weaponid > 22 || weaponid < 0) ? (0) : (weaponid);
weaponid = (weaponid > 25 || weaponid < 0) ? (0) : (weaponid);
Each line says "if weapon id is bigger than X or less than 0, return 0, otherwise return weapon id". First line prevents banning all weapons with ids (-Inf; 0) U (46; Inf), second line (-Inf; 0) U (22; Inf), third (-Inf; 0) U (25; Inf). Now when you sum it up, you get (-Inf; 0) U (22; Inf), i.e you could remove all lines except middle one to get exactly the same result. I think you wanted something more like:
pawn Код:
weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
if (!(weaponid == 22 || weaponid == 25)) weaponid = 0;
Hmmm, I tried it, and I tested it, I still drop the colt and shotgun and am still able to pick em up....
Reply
#4

Change in switch, case statement which weapon you want to forbid.
PHP код:
public ForbidWeaponDrop(weaponid// return 1 if the weapon is forbidden, return 0 is the weapon isn't
{
    if(!(
<= weaponid <= 46) && (19 <= weaponid <= 21)) // if the weapon is valid - < 46 or between 19 & 21
    
{
        
ForbiddenWeaponsDrop[weaponid] = true;
        return 
1;
    }
    else
    {
        switch(
weaponid// we check, case by case
        
{
            case 
2224ForbiddenWeaponsDrop[weaponid] = true;
            default : return 
0;
        }
    }
    return 
1;
}
public 
FreeWeaponDrop(weaponid// if a weapon is forbidden, it can not be authorized
{
    if(
ForbidWeaponDrop(weaponid))
        return 
ForbiddenWeaponsDrop[weaponid] = false0;
    else
        return 
ForbiddenWeaponsDrop[weaponid] = false1;

By the way, I don't know why do you use ForbiddenWeaponsDrop?
Reply
#5

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Change in switch, case statement which weapon you want to forbid.
PHP код:
public ForbidWeaponDrop(weaponid// return 1 if the weapon is forbidden, return 0 is the weapon isn't
{
    if(!(
<= weaponid <= 46) && (19 <= weaponid <= 21)) // if the weapon is valid - < 46 or between 19 & 21
    
{
        
ForbiddenWeaponsDrop[weaponid] = true;
        return 
1;
    }
    else
    {
        switch(
weaponid// we check, case by case
        
{
            case 
2224ForbiddenWeaponsDrop[weaponid] = true;
            default : return 
0;
        }
    }
    return 
1;
}
public 
FreeWeaponDrop(weaponid// if a weapon is forbidden, it can not be authorized
{
    if(
ForbidWeaponDrop(weaponid))
        return 
ForbiddenWeaponsDrop[weaponid] = false0;
    else
        return 
ForbiddenWeaponsDrop[weaponid] = false1;

By the way, I don't know why do you use ForbiddenWeaponsDrop?
I'm using it cause its where you put the ID's of the weapons you restrict right? According to Insanity's script.

I also tried your code, unfortunately the damn colt and shotgun is still dropping as pickups... No idea why...
Reply
#6

Alright, can you post the filterscript here using pastebin.com please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)