IsPlayerInRangeOfPoint loop + timer
#1

I'm trying to make a loop and timer, so that the script constantly checks the player location. I need it for this code:
PHP код:
    if(IsPlayerInRangeOfPoint(playerid1.51742.9924, -1863.207613.5754))
    {
        
ShowPlayerDialog(playerid100DIALOG_STYLE_MSGBOX"TAXI JOB""Are you sure you want to take this job?""Yes""No");
    } 
If someone could add a loop & timer for it, it'd be awesome, or just give me an example of how to do it.
Reply
#2

pawn Код:
forward LOC_CHECK();
public LOC_CHECK()
{
    for(new x =0; x < MAX_PLAYERS; x++)
    {
         if(IsPlayerInRangeOfPoint(x, 1.5, 1742.9924, -1863.2076, 13.5754))
         {
               ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "TAXI JOB", "Are you sure you want to take this job", "Yes", "No");
         }
    }
    return 1;
}

public OnGameModeInIt( )
{
     SetTimer("LOC_CHECK", 5000, true);
     return 1;
}
Though I strongly recommend you avoid this, since it's very inefficient. Try pickups or somethin'
Reply
#3

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
pawn Код:
forward LOC_CHECK();
public LOC_CHECK()
{
    for(new x =0; x < MAX_PLAYERS; x++)
    {
         if(IsPlayerInRangeOfPoint(x, 1.5, 1742.9924, -1863.2076, 13.5754))
         {
               ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "TAXI JOB", "Are you sure you want to take this job", "Yes", "No");
         }
    }
    return 1;
}

public OnGameModeInIt( )
{
     SetTimer("LOC_CHECK", 5000, true);
     return 1;
}
Though I strongly recommend you avoid this, since it's very inefficient. Try pickups or somethin'
Hm.. Is the streamer plugin more "efficient" for this?
Reply
#4

Quote:
Originally Posted by reckst4r
Посмотреть сообщение
Hm.. Is the streamer plugin more "efficient" for this?
I prefer not to use any streamers unless your gamemode is a stunt one with 2000+ objects.

Use default SA-MP pickups?

pawn Код:
new taxi_pickup;

// OnGameModeInIt
{
    taxi_pickup = CreatePickup(....);
    return 1;
}

// OnPlayerPickupPickUp
    if(pickupid == taxi_pickup)
    {
        ShowPlayerDialog(....);
    }


// OnPlayerDialogResponse
if(wautseveras == atwaisds)
{
    watever;
}
Reply
#5

OK, I'll try that. Thanks alot.
Reply
#6

i suggest you to use a (an invisible) pickup - its radius is close to your 1.5 units required, and it triggers a callback without the need of yet another timer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)