Jump to content

Gate opens


Recommended Posts

I took a look at the hay code and all they had was the random x y z, I want it to tell where I want it to go, just like a gate like this:

|------------||------------|

|------------||------------|

|------------||------------|

Then it opens like this:

|------| <<<<<<< >>>>>>> |------|

|------| <<<<<<< >>>>>>> |------|

|------| <<<<<<< >>>>>>> |------|

vv

|---| <<<<<<< >>>>>>> |---|

|---| <<<<<<< >>>>>>> |---|

|---| <<<<<<< >>>>>>> |---|

That's how I seen it, and when you type a command it opens like that, still need more help, and yes I did take a look at moveObject and createObject, I will double check.

Link to comment

Valdmo Morelli has told you enough...

And its normal that wiki uses random values. You can't say open seasame to wiki to it work out the script excatly how you need it! :lol:

Theres example how its done, but u have to get right coords manually.

I made a script for gaining needed coords. I'll ul them later, but everything u need is to get right coords for both states.

And you will need some math skills if you want em to be perfectly positioned.

Thats all you are gonna need I hope you can gather that :P

I would do it, but I'm busy with another request, so I'll see what can I do later.

Nidza

Link to comment
Valdmo Morelli has told you enough...

And its normal that wiki uses random values. You can't say open seasame to wiki to it work out the script excatly how you need it! :lol:

Theres example how its done, but u have to get right coords manually.

I made a script for gaining needed coords. I'll ul them later, but everything u need is to get right coords for both states.

And you will need some math skills if you want em to be perfectly positioned.

Thats all you are gonna need I hope you can gather that :P

I would do it, but I'm busy with another request, so I'll see what can I do later.

Nidza

I know you can't just say open seasame in the chatbox and it will open.... I was saying an example, and he can do whatever he wants with his answers.

Edit: and I said it has already been created, if other people can do it, I can too.

Link to comment

BTW: I made a bit advanced fuel script, I'll release it tomorrow, so you can check it out.

This one is working with distance traveled not with time passed so it gives more accurate results

Yes! Please do so! That would be very thoughtful of you, me and my friends like traveling though the freeway and it would be way more fun with fuel! If this is what your talking about?

Edit: Also please don't go off topic, post in my fuel topic. :D

Link to comment

Vladmo I don't think we are able to make it fit perfectly without MTA's map editor. It's most precise tool to do such things, because I guess the ppl on server on which u saw that was doing a coords changing by script until it fit perfectly...

Maybe I'm wrong, I'm also curious about that...

Link to comment

since I am the maker of this script i can shed some light about how to do it. im not copying and pasting becasue teh script is huge and you would need to have our map file for it to appear normal. what you need to do is this

open map editor (mtasa race) and place objects that do not move

place the gates in a closed position and note the object ID and the xyz coorinates

do the same for the open position

make a function that creates the gates (i.e. gate = createObject ( ObjectID, X, Y, Z ))

make a function that moves the gates to an open poition and do the same for closed ( moveObject ( gate, time, openX, openY, openZ ) )

then put it in the way you want to trigger it, if command put addCommandHandler ( "opensesame", openGate )

or maybe if you are feeling crafty make a colSphere so it opens when you enter it and closes when you leave it. it is all up to you. just check the wiki for info if you are stuck.

Link to comment
since I am the maker of this script i can shed some light about how to do it. im not copying and pasting becasue teh script is huge and you would need to have our map file for it to appear normal. what you need to do is this

open map editor (mtasa race) and place objects that do not move

place the gates in a closed position and note the object ID and the xyz coorinates

do the same for the open position

make a function that creates the gates (i.e. gate = createObject ( ObjectID, X, Y, Z ))

make a function that moves the gates to an open poition and do the same for closed ( moveObject ( gate, time, openX, openY, openZ ) )

then put it in the way you want to trigger it, if command put addCommandHandler ( "opensesame", openGate )

or maybe if you are feeling crafty make a colSphere so it opens when you enter it and closes when you leave it. it is all up to you. just check the wiki for info if you are stuck.

Ok thanks Vercetti and what do you mean do the same for the open position?

Link to comment

Here's a quick gate thing - just dumps one in the world at (0,0,0) and two commands "up" and "down". Move it to where you want it (rotate it on create object also ?) and control it how you need. But it's basically something like this:

  
gGate = { 
            x = 0,y = 0, z = 6, 
            zMove = 6, 
            model = 971, 
            moveTime = 3000, 
            down = true 
        } 
  
addEventHandler("onResourceStart",getRootElement(),  
    function(res) 
        if res == getThisResource() then 
            gGate.object = createObject(gGate.model,gGate.x,gGate.y,gGate.z) 
        end 
    end 
) 
  
function gGate.moveFinished() 
    gGate.down = not gGate.down 
    gGate.timer = nil 
end 
  
function gGate.move(gateState,zDiff) 
    if (gGate.timer == nil) and (gGate.down == gateState) then 
        local x,y,z = getElementPosition(gGate.object) 
        moveObject(gGate.object,gGate.moveTime,x,y,z + zDiff) 
        gGate.timer = setTimer(gGate.moveFinished,gGate.moveTime,1) 
    end 
end 
  
addCommandHandler('up', 
    function(player,cmd) 
        gGate.move(true,gGate.zMove) 
    end 
) 
  
addCommandHandler('down', 
    function(player,cmd) 
        gGate.move(false,-gGate.zMove) 
    end 
) 
  

If you want more gates/control/options etc. get scripting and modify this (or a similar code snippet).

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