SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/03/2019, 03:02 PM   #1
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default InRangeOfPoint

I need a way to loop through this coordinates and check if the player is in a range of them.

pawn Code:
static const Float:RandomSpawn[][4] =
{
    {1320.7914,1262.0884,10.8203,357.0813},
    {408.3192,2452.5623,16.5000,5.9386},
    {-1321.2762,-219.7926,14.1484,12.5747 },
    {1910.8484,-2419.6887,13.5391,182.4597},
    {-2310.8376,-1616.5333,483.8190,176.1664},
    {-2416.7188,332.4720,34.9688,240.4801},
    {-2594.4063,460.8942,14.6094,0.4960},
    {-2898.3438,486.8863,4.9141,271.0871},
    {-2873.9099,735.1693,29.9604,278.4891},
    {-2894.7317,1077.8719,31.4435,269.9459},
    {-2897.3389,1175.7565,12.2720,266.9634},
};

How?
SymonClash is offline   Reply With Quote
Old 29/03/2019, 03:08 PM   #2
Lirbo
Gangsta
 
Lirbo's Avatar
 
Join Date: Jan 2014
Posts: 503
Reputation: 8
Default Re: InRangeOfPoint

Quote:
Originally Posted by SymonClash View Post
I need a way to loop through this coordinates and check if the player is in a range of them.

pawn Code:
static const Float:RandomSpawn[][4] =
{
    {1320.7914,1262.0884,10.8203,357.0813},
    {408.3192,2452.5623,16.5000,5.9386},
    {-1321.2762,-219.7926,14.1484,12.5747 },
    {1910.8484,-2419.6887,13.5391,182.4597},
    {-2310.8376,-1616.5333,483.8190,176.1664},
    {-2416.7188,332.4720,34.9688,240.4801},
    {-2594.4063,460.8942,14.6094,0.4960},
    {-2898.3438,486.8863,4.9141,271.0871},
    {-2873.9099,735.1693,29.9604,278.4891},
    {-2894.7317,1077.8719,31.4435,269.9459},
    {-2897.3389,1175.7565,12.2720,266.9634},
};

How?
never used this before but a gross guess would be

Code:
new rand = random(12);
SpawnPlayer(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2]);
SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
__________________
Lirbo is offline   Reply With Quote
Old 29/03/2019, 03:10 PM   #3
Pizzy
Huge Clucker
 
Join Date: May 2012
Posts: 355
Reputation: 113
Default Re: InRangeOfPoint

turn it off and on again it should do the trick
Pizzy is offline   Reply With Quote
Old 29/03/2019, 04:14 PM   #4
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default Re: InRangeOfPoint

@Lirbo: As i can see you haven't read my post. I don't need a random spawn system (which i have it already), but i just need the IsInRangeOfPoint check.

@Pizzy: What?
SymonClash is offline   Reply With Quote
Old 29/03/2019, 04:28 PM   #5
bgedition
Huge Clucker
 
bgedition's Avatar
 
Join Date: Oct 2013
Location: 127.0.0.1
Posts: 422
Reputation: 37
Default Re: InRangeOfPoint

You could probably use this in a timer or in OnPlayerUpdate. To get the number of spawns you could use sizeof and then in a for loop you could check each point with IsPlayerInRangeOfPoint.
__________________
Never point your finger at some one, you will always have three fingers pointing back at you.
bgedition is offline   Reply With Quote
Old 29/03/2019, 04:34 PM   #6
Lirbo
Gangsta
 
Lirbo's Avatar
 
Join Date: Jan 2014
Posts: 503
Reputation: 8
Default Re: InRangeOfPoint

Quote:
Originally Posted by SymonClash View Post
@Lirbo: As i can see you haven't read my post. I don't need a random spawn system (which i have it already), but i just need the IsInRangeOfPoint check.

@Pizzy: What?
Code:
#define MAX_LOCATIONS 12
new Float:F[3];
GetPlayerPos(playerid, F[0], F[1], F[2]);
for(new i; i < MAX_LOCATIONS; i++)
{
    if(IsPlayerInRangeOfPoint(playerid, DISTANCE, RandomSpawn[i][0], RandomSpawn[i][1], RandomSpawn[i][2]))
    {
//code
    }
}
__________________
Lirbo is offline   Reply With Quote
Old 29/03/2019, 08:08 PM   #7
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default Re: InRangeOfPoint

Thank you.
SymonClash is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
InRangeOfPoint Issue Cole_William Scripting Help 2 26/07/2014 09:18 PM
need help InRangeOfPoint iThePunisher Scripting Help 6 16/04/2014 12:03 PM
InRangeOfPoint Problems yaron0600 Scripting Help 1 07/05/2013 08:19 PM
InRangeOfPoint Help [+rep] Jack.7331 Scripting Help 2 18/03/2012 09:32 AM
Vehicle(without player) InRangeOfPoint? [DRD]Rodney Help Archive 8 11/08/2010 03:43 PM


All times are GMT. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.