08.01.2009, 02:14
Area functions and callbacks
This is a simple include file that can be very helpful for many different things. It's quick and easy to implement in your script.
Functions
native CreateArea(x1, y1, x2, y2) //Format : MaxX, MaxY, MinX, MinY - Returns the areaid
native DestroyArea(areaid)
native IsPlayerInArea(playerid, areaid)
native ReturnPlayerArea(playerid)
native Areas_OnPlayerConnect(playerid)
native Areas_OnPlayerDisconnect(playerid)
native Areas_OnGameModeInit()
To use
Add
And add the following functions to their specific callbacks in the script you will be using them in.
To create areas
Simply go in game and save the coordinates for each limit for the area.
_N(MaxY)_
| |
W(MaxX)| |E(MinX)
|_______|
S(MinY)
Then plug in the coordinates.
http://depositfiles.com/files/j5r6og7tb
http://pastebin.com/m5424ff87 - Paste in notepad - file/save as/Areas.inc
Enjoy.
This is a simple include file that can be very helpful for many different things. It's quick and easy to implement in your script.
Functions
native CreateArea(x1, y1, x2, y2) //Format : MaxX, MaxY, MinX, MinY - Returns the areaid
native DestroyArea(areaid)
native IsPlayerInArea(playerid, areaid)
native ReturnPlayerArea(playerid)
native Areas_OnPlayerConnect(playerid)
native Areas_OnPlayerDisconnect(playerid)
native Areas_OnGameModeInit()
To use
Add
pawn Code:
#include <areas> // Top of script
pawn Code:
Areas_OnPlayerConnect(playerid) // OnPlayerConnect
Areas_OnPlayerDisconnect(playerid) //OnPlayerDisconnect
Areas_OnGameModeInit() //OnGameModeInit
public OnPlayerEnterArea(playerid,areaid)//Somewhere else not in a function
{
return 1;
}
public OnPlayerExitArea(playerid,areaid)//Somewhere else not in a function
{
return 1;
}
Simply go in game and save the coordinates for each limit for the area.
_N(MaxY)_
| |
W(MaxX)| |E(MinX)
|_______|
S(MinY)
Then plug in the coordinates.
http://depositfiles.com/files/j5r6og7tb
http://pastebin.com/m5424ff87 - Paste in notepad - file/save as/Areas.inc
Enjoy.