Jump to content

*map in different dimensions & bug when far from SA


Krom

Recommended Posts

Hello, does anybody know if It's possible to set the dimension of *map file. In other words, when you change dimension from 0 to any other, every map objects disappears (those which set by *map file; haven't tried with dynamical spawn of objects yet). So how can I set *map to exist in, let's say, dimension 1, so when player change his dimension to 1, objects appear and when he change it back to default 0, they disappear.

One more question. When I get far away from SA mainland (coordinates like 100 thousands by "X", even for 50K it's already noticeable) player model begins to shake or something like that. Effect's getting stronger while moving further from SA, and it's really annoying. Anyone ever being affected by this?

Link to comment
Hello, does anybody know if It's possible to set the dimension of *map file. In other words, when you change dimension from 0 to any other, every map objects disappears (those which set by *map file; haven't tried with dynamical spawn of objects yet). So how can I set *map to exist in, let's say, dimension 1, so when player change his dimension to 1, objects appear and when he change it back to default 0, they disappear.

One more question. When I get far away from SA mainland (coordinates like 100 thousands by "X", even for 50K it's already noticeable) player model begins to shake or something like that. Effect's getting stronger while moving further from SA, and it's really annoying. Anyone ever being affected by this?

Dimensions are indeed not settable for an entire .map file, but it is SCRIPTABLE. You can use XML (my way) or another way (better one) to set the dimension of every content inside a .map file.

About that bug: What you need it to be so far anyway? If you would like to create your own city's or something, do it at about ±1500 Z, instead of X and Y. That'd be my advice.

Link to comment

Believe me I need it to be so far away. I doesn't talk about just one city. And I need water there as well. But that doesn't matter if I can make islands visible in different dimensions.

Could you explain me in a couple of words how to reach that result? You're talking about XML features, but I've began to explore MTA features not so long ago, so don't know much. Help would be so good. Still, thank you for saying it's possible. That solves second problem as well.

Link to comment
The shaking will be caused by precision errors in the vectors used for player positions. There's nothing you can do about that without rewriting GTA from scratch.

And THAT'll take some time...

Anyway:

Believe me I need it to be so far away. I doesn't talk about just one city. And I need water there as well. But that doesn't matter if I can make islands visible in different dimensions.

Could you explain me in a couple of words how to reach that result? You're talking about XML features, but I've began to explore MTA features not so long ago, so don't know much. Help would be so good. Still, thank you for saying it's possible. That solves second problem as well.

Ok, I believe you. Can't imagine it... But I'll believe you!

XML is just simply great! Although I can't give you alot of info about it because I'm quite new with it, knowing this is an advantage itself!

XML is very simple to use, you can save things you want to save in files, and you can make scripts in a way that they do not have to change the script itself to change a few results.

A pretty easy example is the .map file, actually XML. Only thing is that it's loaded alot easier. Imagine, you have made a resource that'll display a message in a message box WITH DELAY. You might want it to be 2 seconds, but someone else might want it to be 1 second. You make a XML file to let them change it, without even having to open the script file.

Now that you know about XML, you might want to know how it works. I'll redirect you to the XMLnode main page on the wiki. Like you most probably did with scripting other things, I'll let you learn it yourself:

http://development.mtasa.com/index.php?title=Xmlnode

Now note that XML is a bit slower and uses a bit more memory than normal in a script. But you can change that by loading everything from the start and saving it in variables and tables. But let's not rush and let you discover XML yourself first. Any questions can be placed on the forums.

Link to comment

not sure if it helps but this would be the code for a command named "/setdim" that moves every Object on the server to dimension 1.

function dim () 
    for k, v in ipairs (getElementsByType("object")) do 
        setElementDimension (v, 1) 
    end 
end 
  
addCommandHandler ("setdim", dim) 

Note: If you load a map/create a new object after executing /setdim the objects will be created in Dimension 0 though.

No Warrenty that it works due to the serial server beeing down i could not test it...

Link to comment

Thanks for your replies, however I definitely don't need ALL objects to be in one dimension. By the way, I've heard somewhere about some kind of limits for maps, so making them very big may (will) cause you to fall through the ground and so on. Is that true? As for script, I think I can simply use Mr.Hankey's example with checking objects by their coordinates or other options before setting dimensions. But why not to deal with XML too :) Sure once I'll need it's features much.

Link to comment

Ehm... Not all objects... Only from a map file? In that case I still have a small line that might help you...

/me looks for it

/me found it

Ok, loop through a list of all objects, and use the line below to check if it's a map object. If it is, you put it in a dimension. If it isn't, let it do nothing.

if getElementType( parent ) == "map" and getElementID( parent ) ~= "dynamic" then 

If it doesn't work, you might want to delete getElementID(parent)~="dynamic", since idk what it does. This line was for a map-vehicle-only-respawn script, and so "dynamic" may have to do with vehicles, maybe not. I'm not extremely good in English, so I don't know what dynamic even means... xD

But well, the line may be all that counts. And I think this SHOULD work. ;)

Link to comment

If you only want specific objects to be in dimension 1 you could simply make a new element type in the map and make it parent over all the objects that should be moved to dimension 1.

Now using this code:

function checkmap () 
    local dimelements = getElementsByType ("dimension") 
    for k,v in ipairs (dimelements) do 
        local children = getElementChildren (v) 
        for k,value in ipairs (children) do 
            if getElementType(value)  == "object" then 
                setElementDimension(value, tonumber(getElementData (v, "dimid"))) 
            end 
        end 
    end 
end 
  
addEventHandler ("onResourceStart", getRootElement (), checkmap) 

and this map:

  
<map> 
    <object posX="234" ... /> 
    <dimension dimid="1"> 
        <object posX="567" ... /> 
         
        ... 
         
        <object posX="890" ... /> 
    </dimension> 
</map> 

Every object that's a children of a dimension node (in this case the object with an xposition of 567 and 890) will be moved to the dimension definied with the attribute "dimid" of the dimension node.

Edit: The code might not work cause of typos or whatever but i cant test it atm because of mta not working here...

Edit2: I used getRootElement() on purpose! getResourceRootElement(getThisResource()) wouldn't make sense in this case.

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...