[Include] PML - Paddy's Map Loader
#1

Paddy's Map Loader 0.2

Description:
This include allows you to load MTA .map files and create the objects/ vehicles without a converting site.
It's also able to load already converted SAMP objects/ vehicles from a .pml file (the files need to be ANSI encoded!).
I know that there are lots of these loaders out there but i was bored and try to make my own.
I tried to keep the usage as easy as possible but also provide some nice features.

Installation:
Simply copy/ download the include and save it in <Your Server Folder Here>\pawno\include...
(if you use a differend editor/ IDE I assume you know where to save the includes)
And include it somewhere under #include <a_samp> in your script.

Usage:
There are 8 main functions in this include:
Код:
LoadMTAMap(src[], Float:dist = 90.0)
LoadSAMPMap(src[], Float:dist = 90.0)
LoadMTAMapToArrays(src[], objar[], vehar[], Float:dist = 90.0);
LoadSAMPMapToArrays(src[], objar[], vehar[], Float:dist = 90.0);
RemoveMapObjects(map[])
RemoveMapVehicles(map[])
RespawnMapVehicles(map[])
RemoveMap(map[])
There are some other functions too (a split function for example)...

Loading a MTA .map:
Drag the MTA .map file into your "scriptfiles" folder.
Next go to your script and decide where you want to load the Map.
Then simply load the map with this function:
Код:
LoadMTAMap("<MAPNAME>.map", 123);
The first parameter is the location of the file, the second is the drawing distance (it uses SA:MP's inbuild object streamer).
If you want to load the objects/ vehicles to an array use LoadMTAMapToArrays.
Sadly it doesn't support the MTA colors, so you need to apply SA:MP colors to all vehicles.
Код:
<vehicle ... color="<color1>,<color2>" ...</vehicle>
Loading a SA:MP .pml:
First you need to make a new file with a text editor of your choise (it must support ANSI encoding tough).
Next put all your SA:MP objects/ vehicles in there.

Example:
Код:
CreateObject(968,2238.1999512,2450.5000000,10.6000004,0.0000000,270.0000000,270.0000000); //object(barrierturn) (1)
AddStaticVehicleEx(523,2314.0000000,2495.1999512,2.9000001,90.0000000,-1,-1,-1); //HPV1000
Save it as as .pml file in your scriptfiles folder.
Next go to your script and decide where you want to load the Map.
Then simply load the map with this function:
Код:
LoadSAMPMap("<MAPNAME>.pml", 123);
The first parameter is the location of the file, the second is the drawing distance (it uses SA:MP's inbuild object streamer).
If you want to load the objects/ vehicles to an array use LoadSAMPMapToArrays.

Removing maps/ Respawn vehicles:
This is very easy, just use the code below.
Код:
RemoveMap("<MAPFILE>");
Just replace the <MAPFILE> with the name of you map (example: MAP.map).

If you only want to delete the objects/ vehicles use:
Код:
RemoveMapObjects("<MAPFILE>");

//or

RemoveMapVehicles("<MAPFILE>");
You can also respawn all the vehicles from the map file, just use:
Код:
RespawnMapVehicles("<MAPFILE>");
Bugs/ Problems & Requests:
If you found a bug, have a problem just pm me/ reply to this thread.
If you want another map format added pm me with some example code pls.

Changelog:

Version 0.2:
[ADD] Added LoadMTAMapToArrays/ LoadSAMPMapToArrays so you can load maps to arrays in you Gamemode (usefull for gates and stuff...)
[ADD] Added a define for vehicle respawn-rate for LoadMTAMap/ LoadMTAMapToArrays
[FIX] You can now spawn vehicles at any time with LoadMTAMap/ LoadMTAMapToArrays


Download:

Old Versions: Here




This was only tested with SA:MP 0.3e!
Reply
#2

Pretty awesome ! Nice work and thanks
Reply
#3

nice job ++rep
Reply
#4

Updated!
Now you can load your objects/ vehicles into arrays so you can make gates and add numberplates...
Reply
#5

Wow, this is awesome!
Reply
#6

Just a suggestion, you should add support for returning only the arrays of objects and vehicles without actually creating them. There are a few good reason for doing this I'll list them off.

- Maybe the user wants to load the map into a streamer
- Maybe the user only wants objects but no vehicles
- Maybe the user wants to load the objects into their own variables

Код:
LoadMTAMapToArrays(src[], objar[], vehar[], Float:dist = 90.0, CreateVehicles = 1, CreateObjects = 1);
LoadSAMPMapToArrays(src[], objar[], vehar[], Float:dist = 90.0, CreateVehicles = 1, CreateObjects = 1);
The good news is it can't be any more than 5 minutes to integrate that feature
Reply
#7

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
- Maybe the user wants to load the map into a streamer
Hmm i could add a function wich returns x, y, z, rotation... to an array so you could use it with a different streamer.
Good idea by the way

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
- Maybe the user only wants objects but no vehicles
You can delete the vehicles with RemoveMapVehicles.

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
- Maybe the user wants to load the objects into their own variables
The ID's are already loaded into the users array.
Reply
#8

rename src to mapsrc or map, for consistency
Reply
#9

God dammit. This is so sexy gonna use it for Country Wars. Thank a lot. Will keep your credits. Rep+4

Your first include is amazing. Wow where did you learn scripting?
Reply
#10

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
God dammit. This is so sexy gonna use it for Country Wars. Thank a lot. Will keep your credits. Rep+4

Your first include is amazing. Wow where did you learn scripting?
1. Thank you, i hope that it helps you with your project
2. I know a bit about C++ and I learned Java, so Pawn (a C like language) was "easy" to learn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)