SA-MP Forums Archive
AreaCheck doesn't work. - 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: AreaCheck doesn't work. (/showthread.php?tid=237813)



AreaCheck doesn't work. - Gemini - 10.03.2011

I am working on a weapon free zone in las venturas. So when a player enters the zone, he will lose his weapons, (if hes currently holding them).

Heres the script; http://pastebin.com/b2qzEp1A

It says for now, to set the players health to 0. This is just for testing, I will make it ResetPlayerWeapon later.

It doesnt work, I can just enter the zone without getting killed. Can someone tell me what I did wrong?

PS: Im not sure if i've inputted the coordinates the way it should, but the area should be including whole las venturas, (not desert, city only..)

Thanks in advance.


Re: AreaCheck doesn't work. - Hashski - 10.03.2011

Half that code was wrong, you don't need to get the players location, You just need to check if the player(s) is in that location, just put your coords where i marked it.

pawn Код:
#define FILTERSCRIPT
#include <a_samp>
forward isPlayerInArea();
#if defined FILTERSCRIPT
#else
#endif

public OnGameModeInit()
{
    SetTimer("isPlayerInArea", 1000, 1);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    return 1;
}
public isPlayerInArea()
{
    for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
    {
        if(IsPlayerInRangeOfPoint(playerid, Float:range, Float:x, Float:y, Float:z); // Fill this in, Coords and such
        {
             SetPlayerHealth(i, 0);
        }
    }
}



Re: AreaCheck doesn't work. - Sascha - 10.03.2011

pawn Код:
#define FILTERSCRIPT
#include <a_samp>
forward isPlayerInArea();
#if defined FILTERSCRIPT
#else
#endif

public OnGameModeInit()
{
    SetTimer("isPlayerInArea", 1000, 1);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    return 1;
}
public isPlayerInArea()
   {
       new Float:X, Float:Y, Float:Z; //We use this to store player position
       for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
       {
           GetPlayerPos(i, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
           if (X <= 2918 && X >= 925 && Y >= 598 && Y <= 2606)
           /* This line is the important one!. Here, is where you change those numbers, by the ones
           you get from the /pos command. As you can see, those coordinates, are only the X and Y ones, the Z
           doesnt matter*/

           {
               SetPlayerHealth(i, 0);
           }
       }
   }
you mixed up "<" and ">" for the Y coordinate check

edit:
don't use Hashski's version as this will put an "Circile" around a point and won't make a square as you need...


Re: AreaCheck doesn't work. - Gemini - 10.03.2011

Great! it works. thank you so much Sascha. I did copy the script from wiki-samp but i guess that one is wrong.


Re: AreaCheck doesn't work. - Sascha - 10.03.2011

maybe you also just mixed up the coords at the Y part in the script..
you always need to check which of the coords is the higher and which one is the lower one :P


Re: AreaCheck doesn't work. - Gemini - 10.03.2011

Ok now ive got another question, I want to set another zone weapon free too, Ive got the coords already. But how do I add this to the script? x =17 - x =-218 and y =-174 - y=-386