Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
Hi there!
First of all: I don't know if it's made yet. As far as I know, it isn't. I couldn't find it in the search option, so I decided to make it.
With this include, you can create area's and remove/update them. With a callback, you can check if a player did enter/exit an area.
Functions
Код:
IsPlayerInArea(playerid, areaid); - Check if a player is in 'areaid'
IsAreaCreated(areaid); - Check if the 'areaid' is created or not
GetLowestFreeAreaID(); - You don't need to use it. This is to prevent eventually bugs. It checks the first free area id
CreateArea(Float:MinX, Float:MaxX, Float:MinY, Float:MaxY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Creates an area
CreateArea2(Float:MinX, Float:MinY, Float:MaxX, Float:MaxY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Creates an area (gangzone format)
CreateArea3(Float:MaxX, Float:MinX, Float:MaxY, Float:MinY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Creates an area (worldbounds format)
DeleteArea(areaid) - Delete an area
UpdateArea(areaid, Float:MinX, Float:MaxX, Float:MinY, Float:MaxY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Updates an area it's position
UpdateArea2(areaid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Updates an area it's position (gangzone format)
UpdateArea3(areaid, Float:MaxX, Float:MinX, Float:MaxY, Float:MinY, Float:MinZ = -1.0, Float:MaxZ = -1.0) - Updates an area it's position (worldbounds format)
GetAreaInfo(areaid, &Float:MinX, &Float:MaxX, &Float:MinY, &Float:MaxY, &Float:MinZ, &Float:MaxZ) - Get's the position of an area (use variables to get the info!)
Installation
This isn't hard. Just make a new file in your pawno/include folder and put the content from the download in it.
Then, include the function in your filterscript/gamemode.
You can use the next callbacks:
OnPlayerEnterArea(playerid, areaid);
OnPlayerExitArea(playerid, areaid);
Download (v1.1)
http://pastebin.com/qmVwrhLg
Changelog
v1.0:
* Script created and released
v1.1:
* Checks if "IsPlayerInArea" exists. If it does, function'll be named as "IsPlayerInAreaEx".
Test
I've tested it with this gamemode:
http://pastebin.com/zQzmaZti
Just go to ganton and enter+exit it. You'll get the message that you'd enter/exit it.
I'd also did do it on Persing Square. Both working! GetAreaInfo did also work.
Known bugs
None yet. Please report them
I hope that something like this didn't exist yet. Really... :P
Regards,
Kevin
Re: Player Area's (OnPlayerEnterArea etc) -
wups - 21.02.2011
Everything looks okay, but if i were you, i'd do:
CreateArea(type ....
instead of
createarea1
createarea2...
And define it:
#define AREA_TYPE_GANGZONE 1
etc.
Re: Player Area's (OnPlayerEnterArea etc) -
Marricio - 21.02.2011
Nice! Good work
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
Quote:
Originally Posted by wups
Everything looks okay, but if i were you, i'd do:
CreateArea(type ....
instead of
createarea1
createarea2...
And define it:
#define AREA_TYPE_GANGZONE 1
etc.
|
Ehm do you even know the difference between 1, 2 and 3?
It's the format
Type 1: (my way to add)
MinX, MaxX, MinY, MaxY(, MinZ, MaxZ)
Type 2: (
Gang zone format)
MinX, MinY, MaxX, MaxY(,MinZ, MaxZ)
Type 3: (
Worldbound's format)
MaxX, MinX, MaxY, MinY(, MinZ, MaxZ)
About the Z: They're between brackets. They're not required to add.
However, that's why I don't use types. The formats are different
Re: Player Area's (OnPlayerEnterArea etc) -
sleepysnowflake - 21.02.2011
Exactly what i need ! Thank you !
Re: Player Area's (OnPlayerEnterArea etc) -
Hiddos - 21.02.2011
Wondering what this is doing on your Pastebin but w/e:
http://kwarde.pastebin.com/diptYyvc
Anyways, pretty okay script. But why not just ONE function with ONE format with THREE functions doing the same thing, but having a different format? It can't be that hard to read what goes where, right?
Edit: I suggest renaming 'IsPlayerInArea' to 'IsPlayerInAreaEx', as some people already used IsPlayerInArea.
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
about "http://kwarde.pastebin.com/diptYyvc": That was because someone was nagging that firefox was a shitbrowser. I'd crash his IE browser with that script xD (I'd make a webpage and I showed him the script)
About the functions: Some people are too... well ehm 'stupid' to shuffle the formats after creating it (eg. with Xtreme Vehicle Plotter).
About the IsPlayerInArea/IsPlayerInAreaEx: I will do
Thanks.
- Kevin
EDIT:
Done. Take a look at this:
pawn Код:
#if defined IsPlayerInArea
#define IsPlayerInAreaEx IsPlayerInKRPAArea
#else
#define IsPlayerInArea IsPlayerInKRPAArea
#endif
I guess that that'll work
Re: Player Area's (OnPlayerEnterArea etc) -
wups - 21.02.2011
Quote:
Originally Posted by Kwarde
Ehm do you even know the difference between 1, 2 and 3?
It's the format
Type 1: (my way to add)
MinX, MaxX, MinY, MaxY(, MinZ, MaxZ)
Type 2: ( Gang zone format)
MinX, MinY, MaxX, MaxY(,MinZ, MaxZ)
Type 3: ( Worldbound's format)
MaxX, MinX, MaxY, MinY(, MinZ, MaxZ)
About the Z: They're between brackets. They're not required to add.
However, that's why I don't use types. The formats are different
|
Ah, i understand, okay.
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
Okay
Re: Player Area's (OnPlayerEnterArea etc) -
iMonk3y - 21.02.2011
Cool, just what I needed! Thankyou Mr Kwadre!
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
No thanks.
Ehm, two things:
1) No need to say 'mr' : I'm 14
2) You may say Kevin
- Kevin (:P)
Re: Player Area's (OnPlayerEnterArea etc) -
justsomeguy - 21.02.2011
hmm i didnt realy get it how do these area's look like?
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.02.2011
You can't see them.
You make it invisible, and with the callback "OnPlayerEnterArea" and "OnPlayerExitArea" you can check if a player enter/exits an area
It can be usefull :P
Re: Player Area's (OnPlayerEnterArea etc) -
justsomeguy - 21.02.2011
ow i get it like this:
isplayerinarea(areaid(of playerid:P), "get outta here you! now!");
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 22.02.2011
Ehm almost like that yes :P
But with that "IsPlayerInArea": You can use the
public OnPlayerEnterArea(playerid, areaid)
to check if he enters it. And then with 'if(areaid == id)' you can check what area it is, and then do something.
Example of it here:
http://kwarde.pastebin.com/zQzmaZti
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 21.04.2011
* Bump *
Re: Player Area's (OnPlayerEnterArea etc) -
justsomeguy - 24.04.2011
did you bumbed your toe?
ont:
i actualy needed this for my script thank, glad you bumped
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 27.04.2011
Well lucky for you that I bumped this topic then
Re: Player Area's (OnPlayerEnterArea etc) -
Markx - 27.04.2011
Nice, but is there a tool that can get me the coordinates? I really need this
Re: Player Area's (OnPlayerEnterArea etc) -
Kwarde - 27.04.2011
I use this program:
https://sampforum.blast.hk/showthread.php?tid=372