[Include] st_mapobjects
#1

Hi, russian't))0
I wrote this library for the sake of interest without dependences on other libraries.
  • Description
This library will allow you to load MTA map files without converting.
  • Uses
Loading:
PHP код:
map LoadFromMapFile("PATH_TO_MAP_FILE"); 
Destroying:
PHP код:
DestroyMap(map); 
Max maps:
If you want to change this limit, then define MAX_MAPS before include
PHP код:
#define MAX_MAPS 100
#include "st_mapobjects" 
  • Updates
V1: Just for fun =/
V2: Using y_xml, sscanf2 and streamer plugins
  • Dowload
GitHub
Reply
#2

It looks good, but one thing I noticed is the way you extract the data from each entry.

It obviously works so I'm not saying it is wrong, but it could be optimized quite a bit.

What you currently do is search the whole line for "posX", then search the whole line for "posY", and so on (with all possible data/elements), which means each line is processed multiple times.
You could instead extract each keyword in one run and then write the data to the target step by step as they are found.

So for example a line with 3 elements ("posX", "posY", "posZ") can be looped through to find the keywords/elements, and everytime one is found you write the data to the target variable or array. That way you only process small parts of the line for each element and save a bit processing time. For huge map files this results in quite a speed difference.

Also, what I personally miss a bit is the fact that you cannot decide what happens with items that were found. If I see it right, it basically just creates the objects that are found.
You could think of adding a callback that is called for each loaded item, with item type, position etc. Then the user could decide what to do with a loaded item (create a dynamic object, a player class, a vehicle, or a custom item).

Right now it only creates static objects with CreateObject, if I were to use the Streamer Plugin I had to edit the Include to change attributes like Stream Distance or Virtual Worlds. I think everyone uses the Streamer Plugin nowadays so I think at least adding support and some customization for that would be a great thing!
Add virtualworld, interior, playerid and stream/draw distance arguments to the "LoadMapFile" function so I could for example load specific maps into world 3.

Other than that it works well, good job. If you add some customization and streamer support it will be really useful!
Reply
#3

So good work, +rep Styajkin
Reply
#4

include was updated
Reply
#5

Nice, Styajkin-Sipotyajkin
Reply
#6

Quote:
Originally Posted by desu
Посмотреть сообщение
include was updated
Just one more thing and I will shut up :P
Add some more arguments, like virtualworld, interior or streamdistance/drawdistance. This will make it much more useful! Some maps are just for specific interiors or virtualworlds or even players. Give the users some options

Anyway, good update!
Reply
#7

Quote:
Originally Posted by NaS
Посмотреть сообщение
Just one more thing and I will shut up :P
Add some more arguments, like virtualworld, interior or streamdistance/drawdistance. This will make it much more useful! Some maps are just for specific interiors or virtualworlds or even players. Give the users some options

Anyway, good update!
Thank you :3

At the moment I'm write a plugin. And there it is.

PHP код:
public OnMapCreate(mapidobjectid);
public 
OnMapDestroy(mapidobjectid);
public 
OnDynamicMapCreate(mapidobjectid);
public 
OnDynamicMapDestroy(mapidobjectid);
native LoadMapFromFile(const path[]);
native LoadObjectsFromMap(mapidFloat:drawdistance 200.0);
native DestroyMapObjects(mapid);
#if defined _streamer_included
native LoadDynamicObjectsFromMap(mapidplayerid = -1Float:streamdistance STREAMER_OBJECT_SDFloat:drawdistance STREAMER_OBJECT_DDSTREAMER_TAG_AREA areaid STREAMER_TAG_AREA 1priority 0);
native DestroyDynamicMapObjects(mapid);
#endif 
Only time is not so much... Someday I'll release i.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)