SA-MP Forums Archive
Disable weapons only in ammunation interiors - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Disable weapons only in ammunation interiors (/showthread.php?tid=163122)



Disable weapons only in ammunation interiors - Cypress - 26.07.2010

Hello

I want to disable weapons inside ammunation interiors. I don't want to disable them in all interiors.

Just when player enter to ammunation his weapons scroll and he can't use them until he exit from ammunation.

I think it's something like AllowInteriorWeapons , but it disables weapons in all interiors.

Thanks for your help.


Re: Disable weapons only in ammunation interiors - Calgon - 26.07.2010

You can check if the player is in an ammunation by using IsPlayerInRangeOfPoint, then if they are, SetPlayerArmedWeapon(playerid, 0); which will set their weapon to knuckles. I suppose you'll wanna create a player loop and the if statement, quick example:

pawn Код:
forward playerLoop();
public playerLoop()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 15, x, y, z))
        {
            SetPlayerArmedWeapon(i, 0);
        }
    }
}
You'll need to grab the coordinates yourself, and replace them with the x, y and z, you'll probably also want to create a few other code blocks, seeing as there's various ammunations:

pawn Код:
if(IsPlayerInRangeOfPoint(i, 15, x, y, z) || IsPlayerInRangeOfPoint(i, 15, x, y, z))
Don't forget to grab the coordinates.

You'll also need to set a timer for this loop, so it repeats, add this to OnGameModeInit:

Код:
SetTimer("playerLoop", 1000, true);



Re: Disable weapons only in ammunation interiors - Cypress - 26.07.2010

Quote:
Originally Posted by Calgon
Посмотреть сообщение
You can check if the player is in an ammunation by using IsPlayerInRangeOfPoint, then if they are, SetPlayerArmedWeapon(playerid, 0); which will set their weapon to knuckles. I suppose you'll wanna create a player loop and the if statement, quick example:

pawn Код:
forward playerLoop();
public playerLoop()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 15, x, y, z))
        {
            SetPlayerArmedWeapon(i, 0);
        }
    }
}
You'll need to grab the coordinates yourself, and replace them with the x, y and z, you'll probably also want to create a few other code blocks, seeing as there's various ammunations:

pawn Код:
if(IsPlayerInRangeOfPoint(i, 15, x, y, z) || IsPlayerInRangeOfPoint(i, 15, x, y, z))
Don't forget to grab the coordinates.

You'll also need to set a timer for this loop, so it repeats, add this to OnGameModeInit:

Код:
SetTimer("playerLoop", 1000, true);
Thank you.

EDIT: Its not working.


Re: Disable weapons only in ammunation interiors - Calgon - 26.07.2010

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Thank you.

EDIT: Its not working.
...read what I said... you need to get the coordinates YOURSELF.


Re: Disable weapons only in ammunation interiors - Cypress - 26.07.2010

Quote:
Originally Posted by Calgon
Посмотреть сообщение
...read what I said... you need to get the coordinates YOURSELF.
Код:
public playerLoop()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(1, 15, 292.72, -108.23, 1001.51))
        {
            SetPlayerArmedWeapon(i, 0);
        }
    }
}
Its not working i tested it.