SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/01/2018, 12:40 PM   #1
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 867
Reputation: 122
Question Weapons Drop

Hey guys, well I'm using Insanity's FS, the drop gun fs which is this: http://forum.sa-mp.com/showthread.php?t=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?

Code:
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.
Sting. is offline   Reply With Quote
Old 02/01/2018, 02:59 PM   #2
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,530
Reputation: 552
Default Re: Weapons Drop

Well, first look at the logic you have right now:
pawn Code:
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 Code:
weaponid = (weaponid > 46 || weaponid < 0) ? (0) : (weaponid);
if (!(weaponid == 22 || weaponid == 25)) weaponid = 0;
Misiur is offline   Reply With Quote
Old 02/01/2018, 07:05 PM   #3
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 867
Reputation: 122
Default Re: Weapons Drop

Quote:
Originally Posted by Misiur View Post
Well, first look at the logic you have right now:
pawn Code:
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 Code:
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....
Sting. is offline   Reply With Quote
Old 02/01/2018, 07:12 PM   #4
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,931
Reputation: 256
Default Re: Weapons Drop

Change in switch, case statement which weapon you want to forbid.
PHP Code:
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?
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 03/01/2018, 10:09 AM   #5
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 867
Reputation: 122
Default Re: Weapons Drop

Quote:
Originally Posted by Dayrion View Post
Change in switch, case statement which weapon you want to forbid.
PHP Code:
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...
Sting. is offline   Reply With Quote
Old 03/01/2018, 05:48 PM   #6
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,931
Reputation: 256
Default Re: Weapons Drop

Alright, can you post the filterscript here using pastebin.com please?
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop weapons problem...HELP Mikkel_RE Scripting Help 3 27/11/2012 09:17 PM
[FilterScript] Insanity Weapons Drop CyNiC Filterscripts 14 25/08/2012 08:37 PM
drop weapons when someone dies iStarzz Help Archive 0 04/06/2010 05:47 PM
Problem - Drop Weapons MrLeNy Help Archive 5 01/06/2010 09:06 PM


All times are GMT. The time now is 07:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.