SA-MP Forums Archive
[Include] [INC] Areas - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [INC] Areas (/showthread.php?tid=80118)

Pages: 1 2


[INC] Areas - mister-fred - 02.06.2009


Description
This script will allows you to create easily area, for one player or for all palyers

Functions
Code:
CreateArea(Float:minX, Float:maxX, Float:minY, Float:maxY); // Create area for all players, return id of the zone or INVALID_AREA if the number of maximum area is reached
DestroyArea(areaid); // Destroy area, return true if the area has been destroyed, false if the id is incorrect or that the area was not created
IsPlayerInArea(playerid, areaid); //Check if a player is in the 'areaid', return: true if the player is in area, false if not in area
GetPlayerInArea(playerid); //return: the id of the area in which is the player, INVALID_AREA if the player is not in an area
SetPlayerInArea(playerid,areaid); //Place the player in the center of the area, return: true if the player has been placed in the area, false if the id of the zone is incorrect or that the area was not created

 // The following function returns the same as their equivalent in area for all player
CreatePlayerArea(playerid,Float:minX, Float:maxX, Float:minY, Float:maxY);
DestroyPlayerArea(playerid,areaid);
IsPlayerInPlayerArea(playerid, areaid);
GetPlayerInPlayerArea(playerid);
SetPlayerInPlayerArea(playerid,areaid);
Download
V1.0


Install

- Place the file 'areas.inc' in your folder /pawno/include
- Add '# include <areas>' at the top of your gamemode
- Add 'AR_OnGameModeInit();' At the top of the 'OnGameModeInit'
- Add 'AR_OnGameModeExit();' in 'OnGameModeExit'
- Add 'AR_OnPlayerConnect(playerid)'; in 'OnPlayerConnect'
- Add 'AR_OnPlayerDisconnect(playerid)'; in 'OnPlayerDisconnect'
- Add at the bottom of your script this:
pawn Code:
public OnPlayerEnterArea(playerid,areaid)
{
    return 1;
}
public OnPlayerExitArea(playerid,areaid)
{
    return 1;
}
public OnPlayerEnterPlayerArea(playerid,areaid)
{
    return 1;
}
public OnPlayerExitPlayerArea(playerid,areaid)
{
    return 1;
}




Re: [INC] Areas - James_Alex - 02.06.2009

very very nice


Re: [INC] Areas - Correlli - 02.06.2009

Good work.


Re: [INC] Areas - HuRRiCaNe - 03.06.2009

well done , is going to be useful


Re: [INC] Areas - JoshTheBoss - 03.06.2009

awesome, it is absolutely extravagent!!! (lolz)


Re: [INC] Areas - Emrets61 - 23.06.2009

This is very good INC but, this does not work. You give examples ?


Re: [INC] Areas - Grim_ - 23.06.2009

I swear I've seen these same exact functions before.
*Swift_ goes searching.


Re: [INC] Areas - [LNL]Remulis - 23.06.2009

Nice DUDE


Re: [INC] Areas - Emrets61 - 23.06.2009

Where is the link ?


Re: [INC] Areas - Emrets61 - 23.06.2009

Quote:
Originally Posted by Emrets61
Where is the link ?
Quote:
Originally Posted by Emrets61
This is very good INC but, this does not work. You give examples ?



Re: [INC] Areas - mister-fred - 24.06.2009

The link is the image, then click on the image of the file

For an example I ferris tomorrow.


Re: [INC] Areas - Emrets61 - 24.06.2009

I added codes:

[code=Up]#include <areas>[/code]

[code=OnGameModeInit]
public OnGameModeInit()
{
AR_OnGameModeInit();
return 1;
}[/code]

[code=OnGameModeExit]
public OnGameModeExit()
{
AR_OnGameModeExit();
return 1;
}[/code]

[code=OnPlayerConnect]
public OnPlayerConnect(playerid)
{
AR_OnPlayerConnect(playerid);
return 1;
}[/code]

[code=OnPlayerDisconnect]
public OnPlayerDisconnect(playerid)
{
AR_OnPlayerDisconnect(playerid);
return 1;
}[/code]

[code=OnPlayerSpawn]
public OnPlayerSpawn(playerid)
{
TatilAlani = CreateArea(-2942.825, -2954.502, 2954.502, -2907.791);
return 1;
}[/code]

[code=OnPlayerEnterArea]public OnPlayerEnterArea(playerid,areaid)
{
if(IsPlayerInArea(playerid, TatilAlani))
{
SetPlayerPos(playerid,-2203.3171,-2771.0288,35.5669);
SetPlayerFacingAngle(playerid,75.036;
SendPlayerFormattedText(playerid, "Tatil alanına girebilmek iзin bilet almalısınız.", 0);
}
return 1;
}
[/code]

But not work !


Re: [INC] Areas - SiJ - 24.06.2009

So.. Does anybody tested this?


Re: [INC] Areas - Emrets61 - 24.06.2009

I creating mode for my server. This mode is really important. In the short time period must be published. Give you example? Please.


Re: [INC] Areas - Martins342 - 24.06.2009

GetPlayerInArea must be GetAreaOfPlayer or GetPlayerArea, I think.


Re: [INC] Areas - Emrets61 - 24.06.2009

I added:

pawn Код:
public OnPlayerEnterArea(playerid,areaid)
{
    GetPlayerInArea(playerid);
    if(IsPlayerInArea(playerid, TatilAlani))
    {
    SetPlayerPos(playerid,-2203.3171,-2771.0288,35.5669);
    SetPlayerFacingAngle(playerid,75.0368);
    SendPlayerFormattedText(playerid, "Tatil alanına girebilmek iзin bilet almalısınız.", 0);
    }
    return 1;
}
Not work !


Re: [INC] Areas - mister-fred - 24.06.2009


At the top of your script:
pawn Код:
new TatilAlani;
In OnGameModeInit or elsewhere
pawn Код:
TatilAlani = CreateArea(/*The coordinated minX, maxX, minY, maxY*/);
pawn Код:
public OnPlayerEnterArea(playerid,areaid)
{
    if(areaid == TatilAlani)
    {
      SetPlayerPos(playerid,-2203.3171,-2771.0288,35.5669);
      SetPlayerFacingAngle(playerid,75.0368);
      SendPlayerFormattedText(playerid, "Tatil alanına girebilmek iзin bilet almalısınız.", 0);
    }
    return 1;
}
GetPlayerInArea return areaid in which the player, it can for example be used in a command such as:

pawn Код:
if(strcmp(cmd,"/mycmd",true) == 0)
{
   if(GetPlayerInArea(playerid) != TatilAlani)
   {
      SendClientMessage(playerid,0xFFFFFFFF,"Not in area TatilAlani!");
      return 1;
   }
}



Re: [INC] Areas - Emrets61 - 24.06.2009

I really thank you very much.


Re: [INC] Areas - Emrets61 - 24.06.2009

Not work.


Re: [INC] Areas - mister-fred - 24.06.2009

Your coordinate are can be incorrect