Distance range of a place -
Volumen - 16.01.2019
How can I do so that when a player is near a black market, a 'textdraws' appears saying to the player: "Black market is a few meters near your position", and when the player moves away from that area the' textdraw 'is hidden.
Re: Distance range of a place -
Lokii - 16.01.2019
Use
DynamicArea
PHP код:
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);
Re: Distance range of a place -
Volumen - 16.01.2019
Create an area and then call it in "OnPlayerEnterDynamicArea"?
Re: Distance range of a place -
Lokii - 16.01.2019
Quote:
Originally Posted by Volumen
Create an area and then call it in "OnPlayerEnterDynamicArea"?
|
Yes.
Re: Distance range of a place -
Volumen - 16.01.2019
It's okay. By the way, and if I want to check the distance between two players as I would (IsPlayerInRangeOfPoint)?
When a player is near a player who is working as a seller of "Hot dog" also show a 'textdraw'. It occurred to me to use "IsPlayerInRangeOfPoint" with a timer to compare the distance of the 2 players, but that would flood messages.
Re: Distance range of a place -
Lokii - 16.01.2019
use boolean once you're near one set it to true and check if allready true do nothing if not true show td
then when leaving check if the boolean is true hide td and set it to false
example
PHP код:
new bool:on[MAX_PLAYERS];
CMD:superman(playerid)
{
if(!on[playerid])
{
SetPlayerHealth(playerid, 999999);
on[playerid] = true;
}
else //or if(on[playerid])
{
SetPlayerHealth(playerid, 100);
on[playerid] = false;
}
return 1;
}
Re: Distance range of a place -
Volumen - 16.01.2019
So, should I start the timer every time the player spawns (OnPlayerSpawn)?
Re: Distance range of a place -
Lokii - 16.01.2019
You can do it without timers;
PHP код:
new player_time[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
new time = gettime();
if(player_time[playerid] != time)
{
player_time[playerid] = time;
//code here
}
return 1;
}