st_mapobjects -
desu - 23.07.2018
Hi, russian't))0
I wrote this library for the sake of interest without dependences on other libraries.
This library will allow you to load MTA map files without converting.
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"
V1: Just for fun =/
V2: Using y_xml, sscanf2 and streamer plugins
GitHub
Re: st_mapobjects -
NaS - 23.07.2018
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!
Re: st_mapobjects -
urGrand - 23.07.2018
So good work, +rep Styajkin
Re: st_mapobjects -
desu - 13.08.2018
include was updated
Re: st_mapobjects -
urGrand - 23.08.2018
Nice, Styajkin-Sipotyajkin
Re: st_mapobjects -
NaS - 23.08.2018
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!
Re: st_mapobjects -
desu - 24.08.2018
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(mapid, objectid);
public OnMapDestroy(mapid, objectid);
public OnDynamicMapCreate(mapid, objectid);
public OnDynamicMapDestroy(mapid, objectid);
native LoadMapFromFile(const path[]);
native LoadObjectsFromMap(mapid, Float:drawdistance = 200.0);
native DestroyMapObjects(mapid);
#if defined _streamer_included
native LoadDynamicObjectsFromMap(mapid, playerid = -1, Float:streamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA - 1, priority = 0);
native DestroyDynamicMapObjects(mapid);
#endif
Only time is not so much... Someday I'll release i.