Need help with random functions.
#1

Hello,

I have a problem. I'm trying to make a random location, which is not close to the start.

This is my code:

Random Locations:

pawn Код:
new Locations[][ALocation] =
{
    {"LS Gate 1", 1738.3202,-2425.8325,14.4741}, // Location 1
    {"LS Gate 2", 1641.5100,-2423.1333,14.4730}, // Location 2
    {"LS Gate 3", 1562.1697,-2428.0403,14.4765}, // Location 3
    {"SF Gate 2", 1574.6689,1539.6458,11.7481}, // Location 4
    {"SF Gate 3", -1382.1825,-225.9442,15.0717}, // Location 5
    {"LV Gate 2", -1323.3275,-255.5832,15.0703} // Location 6
};
And i have these ints:

pawn Код:
new Float:Pos1[MAX_PLAYERS];
new Float:Pos2[MAX_PLAYERS];
new Float:Pos3[MAX_PLAYERS];
Right, once it finds one random location at the start, the Random locations get saved into the above floats.

How can i check that the random location for the next random location, is no where near to the Pos1, Pos2, Pos3?

I hope you understand what i mean. What could i do to check?


Thanks!
+rep will be given.
Reply
#2

Bump - any experienced scripters out there that can help me? >.
Reply
#3

This is the code I've maid,it has a few errors,I will edit it once I fix e'm
pawn Код:
enum ALocation
{
    Name[24],
    Float: x,
    Float: y,
    Float: z
};

new
    Locations[][ALocation] =
{
    {"LS Gate 1", 1738.3202,-2425.8325,14.4741}, // Location 1
    {"LS Gate 2", 1641.5100,-2423.1333,14.4730}, // Location 2
    {"LS Gate 3", 1562.1697,-2428.0403,14.4765}, // Location 3
    {"SF Gate 2", 1574.6689,1539.6458,11.7481}, // Location 4
    {"SF Gate 3", -1382.1825,-225.9442,15.0717}, // Location 5
    {"LV Gate 2", -1323.3275,-255.5832,15.0703} // Location 6
};

//Put it wherever you want to
new locrand = random(sizeof(Locations));
new Float:Pos1,Float:Pos2,Float:Pos3; // Couldn't see why the MAX_PLAYERS was necessary
if(Pos1 == Locations[locrand][x] || Pos2 == Locations[locrand][y] || Pos3 == Locations[locrand][z]) return 0;
else {
Pos1 = Locations[locrand][x];
Pos2 = Locations[locrand][y];
Pos3 = Locations[locrand][z]; }
Edit: Fixed all errors,try this and tell me if it works
Reply
#4

nuriel8833 man u so pro. i saw u on all script discussion themes. wow. congratZ u know scripting too much!
Reply
#5

Quote:
Originally Posted by nuriel8833
Посмотреть сообщение
This is the code I've maid,it has a few errors,I will edit it once I fix e'm
pawn Код:
enum ALocation
{
    Name[24],
    Float: x,
    Float: y,
    Float: z
};

new
    Locations[][ALocation] =
{
    {"LS Gate 1", 1738.3202,-2425.8325,14.4741}, // Location 1
    {"LS Gate 2", 1641.5100,-2423.1333,14.4730}, // Location 2
    {"LS Gate 3", 1562.1697,-2428.0403,14.4765}, // Location 3
    {"SF Gate 2", 1574.6689,1539.6458,11.7481}, // Location 4
    {"SF Gate 3", -1382.1825,-225.9442,15.0717}, // Location 5
    {"LV Gate 2", -1323.3275,-255.5832,15.0703} // Location 6
};

//Put it wherever you want to
new locrand = random(sizeof(Locations));
new Float:Pos1,Float:Pos2,Float:Pos3; // Couldn't see why the MAX_PLAYERS was necessary
if(Pos1 == Locations[locrand][x] || Pos2 == Locations[locrand][y] || Pos3 == Locations[locrand][z]) return 0;
else {
Pos1 = Locations[locrand][x];
Pos2 = Locations[locrand][y];
Pos3 = Locations[locrand][z]; }
Edit: Fixed all errors,try this and tell me if it works
But it could still choose LS Gate 3, if you were at LS Gate 2. If you understand.


You get the LS Gate 2 Co-ords.
You want to find a random airport which is NOT LS Gate 1, 2 or 3 (Make a radius distance?)


:/. Thanks for helping though.

Also, that script would not check for another location? I need it to.
Reply
#6

Quote:
Originally Posted by ProdrifterX
Посмотреть сообщение
nuriel8833 man u so pro. i saw u on all script discussion themes. wow. congratZ u know scripting too much!
Thanks lol,even though I am not that pro.. I still dont know everything about Pawno
But thank you so much

Quote:
Originally Posted by GamingTurf
Посмотреть сообщение
But it could still choose LS Gate 3, if you were at LS Gate 2. If you understand.


You get the LS Gate 2 Co-ords.
You want to find a random airport which is NOT LS Gate 1, 2 or 3 (Make a radius distance?)


:/. Thanks for helping though.
Then you need whole different variables for each and every gate.
And that is more complicated,its getting late in here but tomorrow I will help you with that
Reply
#7

Ah, well thanks for helping, and if i don't get this fixed (i will post if it gets resolved), then please help :P.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)