Jump to content

Help me :( in my script pls.


PyArroz

Recommended Posts

Posted

I´m creating this script :) 

This script mimics the operation of the machine Gun of Valkyrie helicopter 

is this : 

restrictedTo = 488

 
 bindKey ( "o", "down",  function ( thePlayer, seat)
 local vehicle = getPedOccupiedVehicle ( localPlayer )
 if ( vehicle and getElementModel (vehicle)  == restrictedTo ) then
 x,y,z = getElementPosition(getLocalPlayer())
 if not createProjectile(getLocalPlayer(), 19, x, y, z - 5, 1, nil, nil, nil, nil, -1, -1, -1, 0) then
 end
 end
 end
 )

 

but only the passengers can use the mg , the driver cannot >:( 

can you help me? 

only the passenger can use the mg  but it's not like that.

Posted

So you want to restrict the command to passengers only? If so, here's the code:

 

bindKey ( "o", "down",  function ( thePlayer, seat)
    local vehicle = getPedOccupiedVehicle ( localPlayer )
    if ( vehicle and getElementModel (vehicle) == restrictedTo and getPedOccupiedVehicle (localPlayer) ~= 0) then -- seat 0 -> driver
    x,y,z = getElementPosition(getLocalPlayer())
    if not createProjectile(getLocalPlayer(), 19, x, y, z - 5, 1, nil, nil, nil, nil, -1, -1, -1, 0) then
        end
    end
end)

I changed line 3 so it checks if the player is not the driver. 

  • Like 1
Posted

getPedOccupiedVehicle returns the vehicle element or false - not the seat. To get the seat you need to use getPedOccupiedVehicleSeat.

Also, you're not using bindKey properly. You're using the client-sided version which returns the key pressed and then the state. So in this case, thePlayer would return "o" and seat would return "down" or "up".

  • Like 2

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Yea, sorry, my bad, was meant to use getPedOccupiedVehicleSeat (localPlayer) ~= 0

 

He has thePlayer and seat there for no reason, he is not actually using it in the code anyway.

  • Like 1

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