Jump to content

Making a working parachute


Vercetti1010

Recommended Posts

Hi, sorry to ask another question so soon, but I am having a lot of confusion with this script im working on. It is supposed to simulate the Single player parachute when you click your mouse and put the parachute away when you click again. I loaded it into my server and turned it on and tested it and got no errors but nothing happens. I even tied a command to it to see if it worked and still nothing happened. Can someone help me figure out why this won't do anything?

parachuteclient.lua

function workingChute(key,keyState) 
weapon = getPlayerWeapon(getLocalPlayer()) 
if (weapon == 46) then 
    if (doesPlayerHaveJetpack(getLocalPlayer()) then 
        outputChatBox("You can't open your parachute on a jetpack!",255,0,0) 
    else 
        if (isPlayerInVehicle(getLocalPlayer()) then 
            outputChatBox("You can't open your parachute in a vehicle!",255,0,0) 
        else 
            if (parachute) then 
                destroyElement(parachute) 
                setGravity(0.008) 
            else 
                parachute = createObject(3131,0,0,0) 
                    attachElementToElement(parachute,getLocalPlayer()) 
                    setGravity(0.002) 
                 
            end 
        end 
    end 
end 
end 
  
  
  
  
function fixKeys(getLocalPlayer()) 
bindKey("mouse1","down",workingChute) 
end 
  
addEventHandler("onClientPlayerJoin",getRootElement(),fixKeys) 
  

meta.xml

<meta> 
    <info author="MasterOfPuppets" decription="Allows a working parachute" version="1.0" type="script"/> 
    <script src="parachuteclient.lua" type="client"/> 
</meta> 

Link to comment

Thanks for the info on that event, I'll definitely try that out when I get home. However, i believe that even if the key bind executed perfectly, nothing would happen when I clicked my mouse. While testing, I added a temporary command to test the individual function and still nothing happened. No errors or warnings came of it and there was no parachute and gravity was still normal.

Edited by Guest
Link to comment
Thanks for the info on that event. However, i know for a fact that even if the key bind executed perfectly, nothing would happen when I clicked my mouse. While testing, I added a temporary command to test the individual function and still nothing happened. No errors or warnings came of it and there was no parachute and gravity was still normal.

Stupid question, but is the resource even started? :roll:

And otherwise, try putting outputChatBox("workingChute activated") after function workingChute(key,keyState). Just to see if the function is executed.

EDIT: Just to make it a bit easier to understand...

function workingChute(key,keyState) 
outputChatBox("workingChute activated") 
weapon = getPlayerWeapon(getLocalPlayer()) 
if (weapon == 46) then 
........ 

Link to comment

If you're having trouble with a script, the best thing to do would be to ask here, especially when you already have a topic opened.

On another note, I'd like to suggest that you use "fire" in bindKey, instead of mouse click. That way it won't fuck up if people have re-mapped their controls.

Link to comment
On another note, I'd like to suggest that you use "fire" in bindKey, instead of mouse click. That way it won't fuck up if people have re-mapped their controls.

I guess that's the entire point... I guess if someone would map "fire" button differently, you wouldn't want to force someone to fire by using the mouse? Imagine someone being forced to use LMB while he always uses CTRL. :P

Anyway, any result from the message?

Link to comment

You may be interested in this resource worked on by me and Jax:

http://dan.bastage.net/mta/parachute.zip

Its unfinished, and doesnt work exactly like SP but its pretty cool. Note this was made before we got animations, but you could most likely easily add them.

edit: It used to work a lot better. Let me try fixing it up

edit2: If you're on 1.0, try this version:

Link removed

For some reason getElementRotation returns the inverse of set

Link to comment

I've been working on it some more since last post since i god caught up with it.

I added animations to the chute now, it looks a lot more polished. Its also partially synced. I might spend tomorrow trying to sync it fully. After that sky diving needs adding. Here's that version:

http://dan.bastage.net/mta/parachute_1.0.zip

Note since it uses animations and such it requires the use of 1.0.

Link to comment
Just so you know, i've been working (with the help of some faithful testers on IRC) on a complete version which includes skydiving and is much improved, but for 1.0 only. Its almost complete and imo its looking pretty good.

i'll release it as soon as im done.

By the way i wanted to comment on your script after seeing it yesterday, i think that the skydiving is too fast, i mean so is the SP's skydiving exaggerated but yours just is too fast, i mean i know its not finished and im not trying to offend you or something like that, but in my opinion you should take much longer to touch the ground while skydiving.

Link to comment

Hey Talidan, I tested that script, and It didn't exactly work right. I am using DP2.X if you are wondering, and I chose the correct script. The parachute will open, but every time a frame is rendered, it gives a warning for getElementRotation saying its a nil value. My fall speed isn't slowed. The parachute will go away when you hit water or land though so that works. How can I make it slow me down?

Edited by Guest
Link to comment

The first one Talidan posted should work, at least according to the wiki it should. All the functions it uses are compatible with DP2.x. It could just be one of those times where things just refuse to work though. I always seem to have functions not work for no reason. Is it possible to use setGravity instead of changing the velocity of the player?

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