SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Tools and Files

Reply
 
Thread Tools Display Modes
Old 15/12/2010, 12:46 PM   #1
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 4,301
Reputation: 357
Default Random Spawn Array Generator

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:

http://forum.sa-mp.com/showthread.php?t=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
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
[Tools]: [Random Spawn Array Generator]

Learn PAWN and more:
http://www.jatochnietdan.com



Last edited by JaTochNietDan; 18/07/2011 at 12:49 AM.
JaTochNietDan is offline   Reply With Quote
Old 15/12/2010, 12:50 PM   #2
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,189
Reputation: 16
Default Re: Random Spawn Array Generator

Amazing dude!
I really really REALLY hate to start copying the X,Y,Z,A from each code
I will definitly use it!
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 15/12/2010, 12:59 PM   #3
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: Wigan, England
Posts: 2,959
Reputation: 223
Default Re: Random Spawn Array Generator

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

LUIS' FUN BOX
December 2014
---------------------------------
YouTube
YouTube | Twitter
On a break from YouTube.

Luis- is offline   Reply With Quote
Old 15/12/2010, 01:04 PM   #4
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 3,933
Reputation: 1872
Default Re: Random Spawn Array Generator

Looks nice, keep up the good work!
__________________
Don't PM me.
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Old 15/12/2010, 01:30 PM   #5
HyperZ
High-roller
 
HyperZ's Avatar
 
Join Date: Aug 2009
Location: Pakistan
Posts: 1,410
Reputation: 65
Default Re: Random Spawn Array Generator

Looks Awesome, Nice job btw.
__________________
HyperZ is offline   Reply With Quote
Old 18/07/2011, 12:49 AM   #6
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 4,301
Reputation: 357
Default Re: Random Spawn Array Generator

Quote:
Originally Posted by LikeMouse View Post
Where's the suorce code ?

and very nice tool!
Fixed.
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
[Tools]: [Random Spawn Array Generator]

Learn PAWN and more:
http://www.jatochnietdan.com


JaTochNietDan is offline   Reply With Quote
Old 18/07/2011, 01:10 AM   #7
CyNiC
High-roller
 
CyNiC's Avatar
 
Join Date: Jan 2009
Location: Brazil
Posts: 1,377
Reputation: 154
Default Re: Random Spawn Array Generator

Thanks, good work, the link was favorited.
CyNiC is offline   Reply With Quote
Old 22/07/2011, 03:08 PM   #8
Famalamalam
Gangsta
 
Famalamalam's Avatar
 
Join Date: Apr 2011
Posts: 496
Reputation: 39
Default Re: Random Spawn Array Generator

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.
__________________

Famalamalam is offline   Reply With Quote
Old 05/11/2011, 01:12 AM   #9
[O.z]Caroline
High-roller
 
[O.z]Caroline's Avatar
 
Join Date: Sep 2011
Location: Brazil
Posts: 1,463
Reputation: 92
Default Re: Random Spawn Array Generator

the suorce don't work's
__________________
[O.z]Caroline is offline   Reply With Quote
Old 05/11/2011, 01:15 AM   #10
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 4,301
Reputation: 357
Default Re: Random Spawn Array Generator

Quote:
Originally Posted by [O.z]Caroline View Post
the suorce don't work's
What's wrong with it?
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
[Tools]: [Random Spawn Array Generator]

Learn PAWN and more:
http://www.jatochnietdan.com


JaTochNietDan 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
ERROR: Must be assigned to an array | with random messages Яσскѕтая Help Archive 10 21/07/2010 09:40 AM
Random Number Generator master000 Help Archive 2 03/03/2010 01:18 AM
[Q] Array Problem Involving random skins [ERP]Snow Help Archive 3 19/07/2009 11:17 AM
Random Name Generator Streetplaya Everything and Nothing 19 20/12/2008 03:15 PM


All times are GMT. The time now is 11:05 AM.


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