Distance range of a place
#1

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.
Reply
#2

Use DynamicArea

PHP код:
native STREAMER_TAG_AREA CreateDynamicCircle(Float:xFloat:yFloat:sizeworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCylinder(Float:xFloat:yFloat:minzFloat:maxzFloat:sizeworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicSphere(Float:xFloat:yFloat:zFloat:sizeworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicRectangle(Float:minxFloat:minyFloat:maxxFloat:maxyworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCuboid(Float:minxFloat:minyFloat:minzFloat:maxxFloat:maxyFloat:maxzworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicCube(Float:minxFloat:minyFloat:minzFloat:maxxFloat:maxyFloat:maxzworldid = -1interiorid = -1playerid = -1);
native STREAMER_TAG_AREA CreateDynamicPolygon(Float:points[], Float:minz = -FLOAT_INFINITYFloat:maxz FLOAT_INFINITYmaxpoints sizeof pointsworldid = -1interiorid = -1playerid = -1);
native DestroyDynamicArea(STREAMER_TAG_AREA areaid);
native IsValidDynamicArea(STREAMER_TAG_AREA areaid); 
Reply
#3

Create an area and then call it in "OnPlayerEnterDynamicArea"?
Reply
#4

Quote:
Originally Posted by Volumen
Посмотреть сообщение
Create an area and then call it in "OnPlayerEnterDynamicArea"?
Yes.
Reply
#5

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.
Reply
#6

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(playerid999999);
       
on[playerid] = true;
    }
    else 
//or if(on[playerid])
    
{
        
SetPlayerHealth(playerid100);
        
on[playerid] = false;
    }
    return 
1;

Reply
#7

So, should I start the timer every time the player spawns (OnPlayerSpawn)?
Reply
#8

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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)