SA-MP Forums Archive
If a player enters an area - 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)
+--- Thread: If a player enters an area (/showthread.php?tid=598422)



If a player enters an area - AndreiWow - 12.01.2016

How do I send a message to a player if he enters an area?

I want to get this message if a player aproach the tolls

Guard: Hello, would you like to pass?

I want it to send to everyone in the area with proxdetector but I don't know how to make it show when a player enters that area IN a car if possible, if not, I will do it with a pickup..


Respuesta: If a player enters an area - p0isoN - 12.01.2016

OnPlayerEnterDynamicArea(playerid, areaid);

OnPlayerLeaveDynamicArea(playerid, areaid);

CreateDynamicRectangle(Float:minx, Float:miny, Float:maxx, Float:maxy, worldid = -1, interiorid = -1, playerid = -1);


Re: If a player enters an area - Abagail - 12.01.2016

The best way (the way I'd recommend, atleast) is using dynamic areas provided by the Streamer Plugin.

Area natives:
pawn Код:
native STREAMER_TAG_AREA CreateDynamicCircle(Float:x, Float:y, Float:size, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCylinder(Float:x, Float:y, Float:minz, Float:maxz, Float:size, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicRectangle(Float:minx, Float:miny, Float:maxx, Float:maxy, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCuboid(Float:minx, Float:miny, Float:minz, Float:maxx, Float:maxy, Float:maxz, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCube(Float:minx, Float:miny, Float:minz, Float:maxx, Float:maxy, Float:maxz, worldid = -1, interiorid = -1, playerid = -1);
native STREAMER_TAG_AREA CreateDynamicPolygon(Float:points[], Float:minz = -FLOAT_INFINITY, Float:maxz = FLOAT_INFINITY, maxpoints = sizeof points, worldid = -1, interiorid = -1, playerid = -1);
native DestroyDynamicArea(STREAMER_TAG_AREA areaid);
native IsValidDynamicArea(STREAMER_TAG_AREA areaid);
native GetDynamicPolygonPoints(STREAMER_TAG_AREA areaid, Float:points[], maxpoints = sizeof points);
native GetDynamicPolygonNumberPoints(STREAMER_TAG_AREA areaid);
native TogglePlayerDynamicArea(playerid, STREAMER_TAG_AREA areaid, toggle);
native TogglePlayerAllDynamicAreas(playerid, toggle);
native IsPlayerInDynamicArea(playerid, STREAMER_TAG_AREA areaid, recheck = 0);
native IsPlayerInAnyDynamicArea(playerid, recheck = 0);
native IsAnyPlayerInDynamicArea(STREAMER_TAG_AREA areaid, recheck = 0);
native IsAnyPlayerInAnyDynamicArea(recheck = 0);
native GetPlayerDynamicAreas(playerid, STREAMER_TAG_AREA areas[], maxareas = sizeof areas);
native GetPlayerNumberDynamicAreas(playerid);
native IsPointInDynamicArea(STREAMER_TAG_AREA areaid, Float:x, Float:y, Float:z);
native IsPointInAnyDynamicArea(Float:x, Float:y, Float:z);
native GetDynamicAreasForPoint(Float:x, Float:y, Float:z, STREAMER_TAG_AREA areas[], maxareas = sizeof areas);
native GetNumberDynamicAreasForPoint(Float:x, Float:y, Float:z);
native AttachDynamicAreaToObject(STREAMER_TAG_AREA areaid, STREAMER_TAG_OBJECT_ALT objectid, type = STREAMER_OBJECT_TYPE_DYNAMIC, playerid = INVALID_PLAYER_ID, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);
native AttachDynamicAreaToPlayer(STREAMER_TAG_AREA areaid, playerid, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);
native AttachDynamicAreaToVehicle(STREAMER_TAG_AREA areaid, vehicleid, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);
In this case, a rectangle would probably be the best to do the job. To detect when the player enters the area, the OnPlayerEnterDynamicArea callback is called.


Re: If a player enters an area - Omirrow - 12.01.2016

Are you trying to create a toll system? If so, you can create it with IsPlayerInRangeOfPoint as well.


Re: If a player enters an area - AndreiWow - 12.01.2016

Yes and I want them to receive a message when stopping at the toll from the guard

I dont have OnPlayerEnterDynamicArea in the script, how do I create it?


Re: If a player enters an area - -CaRRoT - 12.01.2016

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Yes and I want them to receive a message when stopping at the toll from the guard

I dont have OnPlayerEnterDynamicArea in the script, how do I create it?
I wouldnt recommend using these functions for a toll system. Answering your question tho, you can get it by downloading Incognito's streamer from the plugins section then you'll have access to those functions.

I would recommend using two coordinates where you want the car to stop (on either sides) - creating two pickups there and starting the code when the player pickup either one of them while being in the car - so you'd use OnPlayerPickupPickup & IsPlayerInRangeOfPoint, pretty simple and easy to create as it might get a little bit complicated otherwise.


Re: If a player enters an area - AndreiWow - 12.01.2016

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
I wouldnt recommend using these functions for a toll system. Answering your question tho, you can get it by downloading Incognito's streamer from the plugins section then you'll have access to those functions.

I would recommend using two coordinates where you want the car to stop (on either sides) - creating two pickups there and starting the code when the player pickup either one of them while being in the car - so you'd use OnPlayerPickupPickup & IsPlayerInRangeOfPoint, pretty simple and easy to create as it might get a little bit complicated otherwise.
Thought so, thanks.