When the player leave from area (+Rep)
#1

Hello!

How do i make when player leave from 30 radius or 20, There will be an execution will happen

For instance:

Your robbing the bank and you exit/leave the bank area then you will be failed robbing the bank, How? thanks!!!

I promise i will give an rep
Reply
#2

1. Use y_areas
2. SetTimer + Loop + IsPlayerInArea

For one area i prefer option number 2, but if you have more areas use y_areas - it is easy to use.
Reply
#3

You can create areas to be checked. Using an array would avoid area checking getting spammed. So when a player exist on an area or when a player enters the area, the array could be set to a value. And when the player leaves the area, it could be changed to another value.

https://sampwiki.blast.hk/wiki/Areacheck

You can also use Incognito's streamer which supports area detection.
Reply
#4

Any examples please
Reply
#5

You could always use https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
And made it so if it equalled false, then something happens.

Personally I'd find that easier to do than areas, as you can still use a radius.
Reply
#6

Quote:
Originally Posted by NoSoap
View Post
You could always use https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
And made it so if it equalled false, then something happens.

Personally I'd find that easier to do than areas, as you can still use a radius.
Thats what im planning to do , but how
Reply
#7

Quote:
Originally Posted by Trynda
View Post
Thats what im planning to do , but how
Quote:

if(!strcmp("/stadium",cmdtext))
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.843)
{
SendClientMessage(playerid,0xFFFFFFFF,"You are near the stadium entrance!");
}
return 1;
}

if(IsPlayerInRangeOfPoint(playerid, range in radius, X, Y, Z))
Reply
#8

Quote:
Originally Posted by Mark_Weston
View Post
if(IsPlayerInRangeOfPoint(playerid, range in radius, X, Y, Z))
ye, i know but, what code do i input when player leave on that radius thing
Reply
#9

There is no need for a timer because in samp exists areas where you can use a callback "OnPlayerLeaveDynamicArea" (streamer is required)

Example:

Code:
new areaID, zona;

public OnGameModeInit()
{
	areaID = CreateDynamicRectangle(0.0, 0.0, 50.0, 50.0);
	zona = GangZoneCreate(0.0, 0.0, 50.0, 50.0);
	GangZoneShowForAll(zona, G_RED);
	return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid) {
	if(areaid == areaID) {
		SendClientMessage(playerid, -1, "You have leaved that area!");
	}
	return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid) {
	if(areaid == areaID) {
		SendClientMessage(playerid, -1, "You have entered that area!");
	}
	return 1;
}


EDIT: to pick the cordinates you save the cordinates of the diagonal of your rectangle or you use

Code:
CreateDynamicCircle(x, y, size)

In my case the saved cordinates are
first point - x = 0, y = 0 (start of the diagonal)
second point - x = 50, y = 50 (end of the diagonal)

SRY for bad english
Reply
#10

Quote:
Originally Posted by Lordzy
View Post
You can also use Incognito's streamer which supports area detection.
This. Extremely easy and it even has a callback OnPlayerLeaveDynamicArea.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)