Jump to content

[SOLVED] MTA:SA Custom Maps


Recommended Posts

Hello MTA:SA community!

This is my first post in these forums, so bear with me if you find any mispelling or confusing English text (not my native language).

I have a fair knowledge in programming languages, and I'm developing a game mode right now from scratch (but of course I'm learning from other open free gamemodes out there), well I've come to the point I want to build a custom map for my game mode and got a few questions regarding MAPS:

1- Is it possible to create a map from scratch without Los Santos and all the default maps that come with GTA? (I mean a whole new "world", not far positioned maps)

2- If it's possible how do I do so? Any tools or scripts written in a legible way is very welcome; if not, how do you block default maps so that they don't mix up with the world you're trying to build?

3- GTA "map" is huge and divided into "sections", or is each "section" (say, city) called a map? A brief explanation about terminologies would be cool (yes, I'm very new to MTA game modding!)

4- I know there is a Map Editor that comes along with MTA, is that the best map editting tool for customized maps, or do you recommend another one?

That's it for now, if you can help in any of these it'll be much appreciated! :)

Edited by Guest
Link to comment
To remove the San Andreas original map you must use:
removeWorldModel 

If I'm right, the function has an example which removes it all.

Thank you.

Yes, I saw that function and got to remove all the objects (actually it was done before this post, but it's nice to ensure this is the right way to get it done), once everything had been removed the player literally started falling as expected but then again, do I have to build things on the world after clearing everything?

I'm failing to see the connection between Map Editors and an empty world, I take I have to create everything through script after clearing the world??

Questions 1 and (partially) 2 have been aswered, any other input?

Link to comment

removeWorldModel will clear the GTA map models. Then you can create your own world with map editor. The models created with createObject or nodes in map files will not be cleared. To remove these you will have to use destroyElement instead.

If you're a 3D modeller and you want to create your own map and export custom models (.dff) then you can use my map exporter script for 3DS Max found here viewtopic.php?f=108&t=27406 I'm also working on a map importer as well. Here is a sample video:

Link to comment

@50p,

I'll check your map editor script, I'm very grateful for you answers, thanks!

Before I leave you alone, another question raised: during a server run, if I createObject(), is it possible to get its ID to manage it in different functions (within the same script scope)? getElementByID() doesn't work on objects created on the fly with createObject(), so I suppose that's not possible at the moment, right?

Link to comment

You can store the elements within a table and then use getElementModel. You can use getElementByID if you previously used setElementID but you can't have more than 1 element with the same ID.

Link to comment

@50p, thanks!

Actually it turned out simpler than I thought, but now another issue appeared: I set the marker position and its SIZE, but when the *.map is loaded the size isn't take into account (this is, it becomes size 1, I want it to cover a larger area).

Same thing for scaled doors or grids, they *appear* to be bigger, but the collision only respects the default size, not the scaled one, am I missing something?

Sample:

<marker id="marker (cylinder) (5)" type="cylinder" color="#0000ffff" size="105" interior="0" dimension="0" alpha="0" posX="2077.3999" posY="2406.1001" posZ="7.3" rotX="0" rotY="0" rotZ="0" baseId="object (drydock1_SFSe) (79)"></marker> 
  

Tiny area!

@Edit

I added an event handler for onMarkerHit server-side, but it triggers within what seems to be 1unit area radius, which is not intended (I want a 80units for the marker's radius).

@Edit2

While I'm still interested in understanding the issue with marker collisions (I'm inclined to believe that having everything loaded together in a single map file is better heh), I found https://wiki.multitheftauto.com/wiki/OnColShapeHit event and it suits nicely for what I want, for instance I can store a colshape in my database and assign it to an area I want to detect people who come inside. But is it the best or at least a "good" way of doing it?

Link to comment

I don't think you can set cylinder's size that big. That must be GTA limit since cylinder markers are only used for missions so they are small. Like you said, it colshapes are better for your case since seeing 80 units wide marker would not be ideal.

Also, collision of scaled objects will not scale with them, you can read about it on wiki:

This function changes the visible size of an object. It is very important to note that this does not affect the collision models for the object, as such this is unsuitable for use for interaction with players, vehicles or other objects.
Link to comment

@50p, that settles the question thanks but now I'm afraid no objects within map files should be trusted, I was hoping that at least colshapes would work out but this definition fails too:

<colcircle id="colcircle (pbase_marker_5)" collision="1" posX="2077.3999" posY="2406.1001" posZ="7.3" radius="105" baseId="object (drydock1_SFSe) (79)"/> 

I'm just giving up on map files since they're not reliable for real collisions, I hope that scripted colshapes create the collision for colshapes at least.

Again, thank you and sorry for asking too much!

Link to comment

@50p, hmmm not sure it would help as I'm creating the colshape markers server-side, but I believe I'm safe to go (I stored them in a xml file since using databases would be overkill later on).

Thanks for all your help, hopefully my questions will help someone else in the future! :)

@Edit

Just to leave a more helpful thing here, so others can benefit from the script:

function loadInitialBaseData() 
    if source ~= getResourceRootElement() then return end -- This event will happen with any resource start, isolate it to this resource 
    -- Opens db connection 
    db = dbConnect("sqlite", "bases.db") 
     
    -- Creates colshapes on the world 
    xmlRootTree = xmlLoadFile("base_markers.xml") -- Attempt to load the xml file    
    if xmlRootTree then -- If the xml loaded then... 
        xmlColshapes = xmlFindChild(xmlRootTree,"colshapes",0) -- Find the hud sub-node 
        if xmlColshapes then 
            -- Retrieve all  sub-node names or values     
            xmlColshapesTable = xmlNodeGetChildren(xmlColshapes) -- Create a table of this branch's children 
            for i,node in pairs(xmlColshapesTable) do -- Loop through the branch's children for sub-nodes 
                -- If node is valid, use its attributes to create the colshape 
                if node then 
                    local posX = xmlNodeGetAttribute(node, "posX") 
                    local posY = xmlNodeGetAttribute(node, "posY") 
                    local radius = xmlNodeGetAttribute(node, "radius") 
                    local colMarker = createColCircle(posX, posY, radius) 
                    if colMarker then -- If collision shape was created succesfully, attach other data to it 
                        setElementData(colMarker, "id", xmlNodeGetAttribute(node, "id")) 
                        setElementData(colMarker, "baseId", xmlNodeGetAttribute(node, "baseId")) 
                    end 
                end 
            end 
        end 
        xmlUnloadFile(xmlRootTree) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot,loadInitialBaseData) 

Link to comment

You would also need to check if the child of is the specific type because you could have rectangle but you'd still use createColCircle. That's just a tip to give you more flexibility for the future. If createCol... functions do create the shapes of the specific size then map integration needs to be fixed. Please report that on our bugs page: http://bugs.mtasa.com/main_page.php,

Link to comment
You would also need to check if the child of is the specific type because you could have rectangle but you'd still use createColCircle. That's just a tip to give you more flexibility for the future. If createCol... functions do create the shapes of the specific size then map integration needs to be fixed. Please report that on our bugs page: http://bugs.mtasa.com/main_page.php,

Clever! I'll fix that right away! (also, opening a new thread so this one isn't cluttered with ongoing questions xD)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...