SA-MP Forums Archive
Help with reading map objects and spawns from a file. - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with reading map objects and spawns from a file. (/showthread.php?tid=223952)



[SOLVED]Help with reading map objects and spawns from a file. - [P4] - 10.02.2011

THIS IS SOLVED.
Hello everyone,

So here's the thing.
I'm using/editing, well more editing(Learning) than using, Grim_'s Sumo Gamemode.And, you've to create objects, and different spawn positions for every map...
And the code for spawns is something like:
pawn Код:
new Float:SumoSpawns[MAX_MAPS][MAX_PLAYERS][4] =
{
    {
        {x, y, z, blah}, //Spawns for Map1
        {x, y, z, blah},
        .....
    },
    {
        {x, y, z, blah}, //Spawns for Map2
        {x, y, z, blah},
        .....
    },
And so on...
And the map part looks like:
pawn Код:
LoadMapObjects()
{
    switch(iMap)
    {
        case 0:
        {
            CreateObject{Blaaaaah}; //Map1
            CreateObject{Blaaaaah};
        }
        case 1:
        {
            CreateObject{Blaaaaah}; //Map2
            CreateObject{Blaaaaah};        
        }
    }
}
..So what i wanted is to (somehow) read the map objects and spawns, from a .txt file in scriptfiles.Because like this(i have 12 maps at the moment) the code is really messy and takes long time to find what i was looking for.And yes, i've looked at the wiki and searched around but had no success.

Thanks in advance.


Re: Help with reading map objects and spawns from a file. - [P4] - 11.02.2011

Sorry for bumping, but I really need help with this. Thanks.


Re: Help with reading map objects and spawns from a file. - dice7 - 11.02.2011

Check the LoadStaticVehiclesFromFile() function from Grandlarc (gamemode you get with the server) for hints on how to do it


Re: Help with reading map objects and spawns from a file. - [P4] - 11.02.2011

Thank you! It helped me But now i'm getting this error:
Код:
\pawno\include\sumo_spawns.inc(269) : error 052: multi-dimensional arrays must be fully initialized
It is the last line in sumo_spawns.inc.It looks:
Код:
#define MAX_MAPS 12
new Float:SumoSpawns[MAX_MAPS][MAX_PLAYERS][4] = 
{
        {
-REST OF SPAWN POSITIONS-
        },
	{
 		{bla, bla, -bla, -bla};
		{ble, ble, -ble, -ble};
 		{And 18 more spawn positions}        		
	}
}; //Here is the error o.O



Re: Help with reading map objects and spawns from a file. - [P4] - 11.02.2011

Just to say, i did it.I just had to #define MAX_PLAYERS in the include, it works now.Thanks for helping very much.