[Tool/Web/Other] Random Spawn Array Generator
#1

Random Spawn Array Generator
What is it?
It's a simple tool to generate an array in Pawn from a SavedPositions.txt file. It will automatically format and generate the array to store all of the positions. This is the kind of script I wrote for myself when doing a large bulk of these things, since doing it manually is painful.
__________________________________________________

I don't understand, can you give me an example?
Okay sure, lets say for example you are getting a HUGE amount of random spawn locations for your server, then you want to store them all in an array so you can set the player to each of the positions randomly. So you open your SavedPositions.txt with all of the saved positions in it, which looks like this:

Code:
AddPlayerClass(1,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(2,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(269,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(270,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(271,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(272,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(47,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(48,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(49,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(50,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(51,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(52,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(53,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(54,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(55,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(56,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(57,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(58,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(68,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(69,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(70,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(71,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(72,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(73,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(75,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(76,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(78,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(79,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(80,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(81,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(82,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(83,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(84,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(85,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(87,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(88,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(89,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(91,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(92,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(93,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(95,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(96,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(97,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(98,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(99,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
* Taken from Grand Larency as an example.

With this tool, you simply copy and paste that in, and it turns into:

pawn Code:
new randomSpawns[45][4] = {
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503}
};
This can then be turned into a random spawn system, for example to be used with this tutorial:

https://sampforum.blast.hk/showthread.php?tid=162488
__________________________________________________

Are there any other uses besides random spawns?
Well maybe you want to add a trucking mission with random destinations, that may also require such positions saved into an array, be creative!
__________________________________________________

Tool Location
http://www.jatochnietdan.com/tools/?tool=randomspawn

Tool Source
http://pastebin.com/13nAj00J
* Excludes designs and formatting
__________________________________________________

Enjoy! Feedback and suggestions are appreciated as always
Reply
#2

Amazing dude!
I really really REALLY hate to start copying the X,Y,Z,A from each code
I will definitly use it!
Reply
#3

I love you! This is a really helpful tool thank you.
Reply
#4

Looks nice, keep up the good work!
Reply
#5

Looks Awesome, Nice job btw.
Reply
#6

Thanks, good work, the link was favorited.
Reply
#7

Very nice, I usually just use a custom command for saving formatted positions..

pawn Code:
CMD:s(playerid, params[])
{
    if(PlayerInfo[playerid][LoggedIn])
    {
        new Float:X, Float:Y, Float:Z, File:save;
        GetPlayerPos(playerid, X, Y, Z);
        if(!fexist("lsx/surprisa.txt"))
        {
            save=fopen("lsx/surprisa.txt",io_write);
            fclose(save);
            print("File 'suprisa.txt' created succesfully!");
        }

        new entry[128], entry2[128];
        format(entry, 128, "{%.2f, %.2f, %.2f},", X, Y, Z);
        format(entry2, 128, "\r\n%s",entry);
        save = fopen("lsx/surprisa.txt", io_append);
        fwrite(save, entry2);
        fclose(save);
        SendClientMessage(playerid, White, "Position saved.");
    }
    else
    {
        SendClientMessage(playerid, Red, "Log in, fool.");
    }
    return 1;
}
.. and then just put them in an array, but this is another method, great job.
Reply
#8

the suorce don't work's
Reply
#9

Quote:
Originally Posted by [O.z]Caroline
View Post
the suorce don't work's
What's wrong with it?
Reply
#10

#edit.
fixed.
Reply
#11

I could use this tool right about now, but the link isn't working properly...

EDIT: I just D/Led the source and uploaded it to my web-server, so disregard the message above. Thanks!

EDIT 2: It appears that the source doesn't have all of the required stuff to make the tool function correctly, or does it?
Reply
#12

Awesome tool! I will definetly be using it!
Reply
#13

Pretty useful. Thank you.
Reply
#14

It's bugged lel,

Because it must gives

Код:
new float:coord
not
Код:
new coord
Reply
#15

Would you mind making this into a application?
Reply
#16

how to use this? place it in FS/include/in gamemode? i dont understand... can u pls help me? make a little tut or somethin i dont understand how to use
Reply
#17

mmm ? and the Float: ?

If you dont put that, probaly, you have warnings :S


Correct code:

pawn Код:
new Float:randomSpawns[45][4] = {
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503},
    {1759.0189,-1898.1260,13.5622,266.4503}
};
Im just saying, good Woork
Reply
#18

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
I could use this tool right about now, but the link isn't working properly...

EDIT: I just D/Led the source and uploaded it to my web-server, so disregard the message above. Thanks!

EDIT 2: It appears that the source doesn't have all of the required stuff to make the tool function correctly, or does it?
I've fixed the source to work independently.

Quote:
Originally Posted by Rapgangsta
Посмотреть сообщение
It's bugged lel,

Because it must gives

Код:
new float:coord
not
Код:
new coord
I've fixed that too, along with the array size specified in the 2nd dimension, as it was always set to 4 even if you didn't include the angles.

Sorry for the late reply, better late than never!
Reply
#19

LINK IS DOWN!
Reply
#20

Someone Has the LINK?
Reply


Forum Jump:


Users browsing this thread: 20 Guest(s)