Loading maps
#1

Hey all! I'm currently creating server which will load maps dynamically, and by that I mean on loading objects and vehicles out of the gamemode.
I thought about creating text file for every map which will look something like this:
Код:
spawn1=4340.79199  -2143.98535  15.60294  
vehicle1=4357.69336  -2152.39355  15.60294  
...
But I'm not sure if loading of 100 objects and 20 vehicles would cause the server to start lagg.
Does anyone have any advice on creating this dynamic system? I know I could manage something up with includes maybe but I'm not sure.
Thanks.
Reply
#2

Yes possible, Though for spawns make a different .ini file and for map make different..... So if you load map ' Map123.ini ' you can do so it will load the spawn positions , make the name of the spawn of a specific map the same as the map name like
Map name : Map123.ini (Map)
Spawn pos : Map123.ini (Spawn for Map123)
Is that what you need or you don't know how?
Reply
#3

I know how to do it but I'm trying to see all possibilities about loading stuff like objects.
Reply
#4

For vehicles you need to have them like this:
Код:
modelid,Float:x,Float:y,Float:z,colour1,colour2 ; Comment if needed
in a txt file. Check scriptfiles/vehicles/any txt file for more examples.
Reply
#5

Quote:
Originally Posted by Stinged
Посмотреть сообщение
For vehicles you need to have them like this:
Код:
modelid,Float:x,Float:y,Float:z,colour1,colour2 ; Comment if needed
in a txt file. Check scriptfiles/vehicles/any txt file for more examples.
scriptfiles/Maps/Map123.ini (Map)
scriptfiles/Maps/Spawns/Map123.ini (Spawns)

That's for Map and spawns
So Make like if Map123.ini (Map) is loaded, tell it to load Map123.ini (spawn)
If Map111.ini (Map) , load Map111.ini (spawn)
i hope you get it..
Reply
#6

Hmm, how about this?
pawn Код:
public OnGameModeInit() // only for example
{
     #include Maps/map1.txt
     return 1;
}
// map1.txt
CreateVehicle(469,1656.7000000,-1348.5000000,159.8000000,270.0000000,245,245,10); //Sparrow
CreateVehicle(469,1656.7000000,-1337.8000000,159.8000000,270.0000000,245,245,10); //Sparrow

CreateDynamicObject(4602,1940.8000000,-1338.2000000,87.5000000,0.0000000,0.0000000,0.0000000); //object(laskyscrap4_lan) (2)
CreateDynamicObject(3095,1946.2000000,-1354.1000000,158.7000000,0.0000000,180.0000000,0.0000000); //object(a51_jetdoor) (1)
...
So I'm just placing text from map1.txt somewhere in the script. I should also save all objects into one array and after using the object, I could just delete all of them. Does that sound good?
Reply
#7

Use This Include specially made for loading dynamic objects
http://forum.sa-mp.com/showthread.ph...highlight=load
+REP If I've Helped You..
Reply
#8

That's the wrong way, You are not reading from a file.
The script you made won't really work
It must be something like this

pawn Код:
#define Spawn_Path "/Maps/Spawns/%s.ini" //Name the file the SAME as the map!! Also before EVERY spawn pos, put 0 for team 1, 1 for team 2.
#define Map_Path "/Maps/%s.ini"
Edit: The script link posted above might work, But it won't get the spawn positions and i haven't tested that yet..
Reply
#9

I would just use a filterscript to do this example.
Quick, dirty, easy and look mom the streamer does most of the cleanup work!

pawn Код:
#include <a_samp>
#include <streamer>

new Vehicles[MAX_VEHICLES];


public OnFilterScriptInit()
{
    CreateDynamicObject(970, -2000.89941, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 128.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 133.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 139.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 145.39941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 151.09961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 157.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 162.59961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 168.19922, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 174.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -1995.50000, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);

    Vehicles[CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60)];

}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_VEHICLES; i++) if(Vehicles[i] > 0) DestroyVehicle(i);
    return 1;
}
Reply
#10

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I would just use a filterscript to do this example.
Quick, dirty, easy and look mom the streamer does most of the cleanup work!

pawn Код:
#include <a_samp>
#include <streamer>

new Vehicles[MAX_VEHICLES];


public OnFilterScriptInit()
{
    CreateDynamicObject(970, -2000.89941, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 128.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 133.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 139.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 145.39941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 151.09961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 157.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 162.59961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 168.19922, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 174.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -1995.50000, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);

    Vehicles[CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60)];

}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_VEHICLES; i++) if(Vehicles[i] > 0) DestroyVehicle(i);
    return 1;
}
Thanks but I don't want to load any filterscripts.
Do you think loading stuff from include would be a good idea?
Reply
#11

Just use a filterscript I don't see the big deal it simplifies the whole process and yes there is more than one way to skin a cat but why bother making this more difficult than it has to be?
Reply
#12

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Just use a filterscript I don't see the big deal it simplifies the whole process and yes there is more than one way to skin a cat but why bother making this more difficult than it has to be?
Good point am using a filterscript for my mapping's i find it the best way also am pretty sure you can use it as a include to.
Reply
#13

Here is the thing he wants to do it dynamically so using a FS is by far his best option in my opinion since the streamer automatically deletes objects in a filterscript he really only needs to worry about cleaning up vehicles. This also simplifies things if he needs to set textures as well or use any other dynamic elements such as areas that are in the streamer. In this case the easiest way is the best way and I would always recommend avoiding filterscripts but this is an excellent use and the right time to use them.
Reply
#14

Okay, thanks for clearing that out for me.
But what about this. I plan to have more than 1 arenas in my server (every arena loads it's own FS). Using filterscripts in that case would not be an option, right?
Reply
#15

Here is what you have to look at.

static maps - These maps are ALWAYS loaded and belong in the gamemode
dynamic maps - These maps load unload as required and belong in a filterscript

Get it ?

In the case of static maps all you need to do is create include files in fact they are almost identical to a filterscript with a few differences.

Example I'm using y_hooks here but you can use als method 7 if you want I just like this way since it simplifies the code.

pawn Код:
#include <YSI\y_hooks>

hook OnGameModeInit()
{
    CreateDynamicObject(970, -2000.89941, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 128.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 133.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 139.89941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 145.39941, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 151.09961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 157.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 162.59961, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 168.19922, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -2000.89941, 174.00000, 27.20000,   0.00000, 0.00000, 90.00000);
    CreateDynamicObject(970, -1995.50000, 122.29980, 27.20000,   0.00000, 0.00000, 90.00000);

    CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60)
}
Then it's just a matter of stacking these include files in your gamemode.

Example.

pawn Код:
#include "maps\map1.pwn"
#include "maps\map2.pwn"
#include "maps\map3.pwn"
#include "maps\map4.pwn"
#include "maps\map5.pwn"
#include "maps\map6.pwn"
If your loading filterscripts you need to do this.

pawn Код:
SendRconCommand("loadfs map1");
SendRconCommand("unloadfs map1");
Reply
#16

I understand the difference between static and dynamic maps. I wouldn't load all maps at once.
I know now that using filterscripts for loading something dynamically is good, but my only concern is limit of loaded filterscripts because I don't know will I have to load more than 16 maps.
Reply
#17

pawn Код:
SendRconCommand("loadfs map1");
SendRconCommand("unloadfs map2");
You don't have to load more than 1, if you load map 1, you unload the map2. Means you won't reach the limit
Reply
#18

Look, I will have more than one arena, every arena uses it's own map so yeah, I have to load more than one FS.
Reply
#19

Then i wouldn't suggest using Fs method. you can just add maps in the script files as i've told you before and load them in-game.
If you don't know how, i think i can help :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)