SA-MP Forums Archive
[Tool/Web/Other] Random Spawn Array Generator - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Tools and Files (https://sampforum.blast.hk/forumdisplay.php?fid=82)
+---- Thread: [Tool/Web/Other] Random Spawn Array Generator (/showthread.php?tid=199377)

Pages: 1 2


Random Spawn Array Generator - JaTochNietDan - 15.12.2010

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


Re: Random Spawn Array Generator - nuriel8833 - 15.12.2010

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


Re: Random Spawn Array Generator - Luis- - 15.12.2010

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


Re: Random Spawn Array Generator - Hiddos - 15.12.2010

Looks nice, keep up the good work!


Re: Random Spawn Array Generator - HyperZ - 15.12.2010

Looks Awesome, Nice job btw.


Re: Random Spawn Array Generator - CyNiC - 18.07.2011

Thanks, good work, the link was favorited.


Re: Random Spawn Array Generator - Famalamalam - 22.07.2011

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.


Re: Random Spawn Array Generator - [O.z]Caroline - 05.11.2011

the suorce don't work's


Re: Random Spawn Array Generator - JaTochNietDan - 05.11.2011

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


Re: Random Spawn Array Generator - [O.z]Caroline - 05.11.2011

#edit.
fixed.


Re: Random Spawn Array Generator - Scenario - 27.11.2011

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?


Re: Random Spawn Array Generator - seanny - 28.11.2011

Awesome tool! I will definetly be using it!


Re: Random Spawn Array Generator - ricardo178 - 28.11.2011

Pretty useful. Thank you.


Re: Random Spawn Array Generator - Rapgangsta - 30.12.2011

It's bugged lel,

Because it must gives

Код:
new float:coord
not
Код:
new coord



Re: Random Spawn Array Generator - Snowman12 - 11.01.2012

Would you mind making this into a application?


Re: Random Spawn Array Generator - niels44 - 19.01.2012

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


Respuesta: Random Spawn Array Generator - [Nikk] - 19.01.2012

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


Re: Random Spawn Array Generator - JaTochNietDan - 10.03.2012

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!


Re: Random Spawn Array Generator - iWhite - 20.01.2013

LINK IS DOWN!


Respuesta: Random Spawn Array Generator - [Cali]ChrOnic_T - 21.07.2014

Someone Has the LINK?