SA-MP Forums Archive
[Help needed] Adding several weapons not abled under a command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help needed] Adding several weapons not abled under a command. (/showthread.php?tid=297963)



[Help needed] Adding several weapons not abled under a command. - Da' J' - 18.11.2011

Alright, so i have a command /putgun 1/2. And i need to set big weapons like AK-47, M4, Shotgun, Sawnoff, MP5 etc. disabled for /putgun 1, and all small weapons disabled to store for command /putgun 2. Small weapons are Deagle, Colt45, UZI and Tec9 ofc.

Shoukd it be done with GetPlayerWeapon? If so, how can i make it for every of those weapons? :/


Re: [Help needed] Adding several weapons not abled under a command. - Daddy Yankee - 18.11.2011

PHP код:
stock IsABigWeapon(playerid)
{
    switch(
GetPlayerWeapon(playerid))
    {
        case 
30,31,24,23,29: return 1;
    }
    return 
0;

The put a restriction on /putgun1 like

PHP код:
if(!IsABigWeapon)
            {
                
SendClientMessage(playeridCOLOR_GRAD1"You can't put this weapon.");
                return 
1;
            } 
Then you do same for the small ones, with different id's of course.

PS: I'm not sure about the shawnoff id (23)


Re: [Help needed] Adding several weapons not abled under a command. - Da' J' - 18.11.2011

Ok. And sawnoff is not ID 23, that's SD lol. And i should put something like "new IsABigWeapon();" in the start of the whole script?


Re: [Help needed] Adding several weapons not abled under a command. - Da' J' - 18.11.2011

Quote:
Originally Posted by Daddy Yankee
Посмотреть сообщение
The put a restriction on /putgun1 like

PHP код:
if(!IsABigWeapon)
            {
                
SendClientMessage(playeridCOLOR_GRAD1"You can't put this weapon.");
                return 
1;
            } 
I did that, and i get this:
pawn Код:
C:\Users\Da' J'\Desktop\GTA San Andreas modfiles\Raven's Roleplay 0.3d V4.2\gamemodes\larp.pwn(32322) : error 076: syntax error in the expression, or invalid function call
C:\Users\Da'
J'\Desktop\GTA San Andreas modfiles\Raven's Roleplay 0.3d V4.2\gamemodes\larp.pwn(32341) : error 076: syntax error in the expression, or invalid function call
Helps?


Re: [Help needed] Adding several weapons not abled under a command. - Unte99 - 18.11.2011

EDITED:

pawn Код:
if(!IsABigWeapon(playerid))
{
    SendClientMessage(playerid, COLOR_GRAD1, "You can't put this weapon.");
    return 1;
}



Re: [Help needed] Adding several weapons not abled under a command. - Da' J' - 19.11.2011

Well now it works. Thank you, i should've notice that even myself tho lol. But thanks man.


Re: [Help needed] Adding several weapons not abled under a command. - MP2 - 19.11.2011

But that checks if they HAVE a big weapon on their player already, surely you want to prevent that?

pawn Код:
stock GetWeaponSize(weaponid)
{
    switch(weaponid)
    {
        case 1, 2, 3, 4: return 1;
        case 5, 6, 7, 8: return 2;
        default: return 0;
    }
}

// Weapons 1-4 are marked as 'small guns' and 5-8 as 'big guns'
// IDs that aren't listed as big or small will be restricted

// For putgun 1:

if(GetWeaponSize(weaponid) != 1) return SendClientMessage(playerid, 0xFF0000FF, "Only small weapons may be used.");

// For putgun 2:

if(GetWeaponSize(weaponid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "Only big weapons may be used.");
Un-tested, not sure if it even compiles, though the theory is correct.