Andres99907 Posted October 8, 2016 Share Posted October 8, 2016 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. Link to comment
iPrestege Posted October 8, 2016 Share Posted October 8, 2016 Your code is makes no sense in here from what i see also please use Code editor to post a code and select Lua. 2 Link to comment
pa3ck Posted October 8, 2016 Share Posted October 8, 2016 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. 1 Link to comment
Dealman Posted October 8, 2016 Share Posted October 8, 2016 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". 2 Link to comment
pa3ck Posted October 8, 2016 Share Posted October 8, 2016 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. 1 Link to comment
Popular Post Walid Posted October 8, 2016 Popular Post Share Posted October 8, 2016 local restrictedTo = {[488]=true} function functionName() if isPedInVehicle(localPlayer) then local vehicle = getPedOccupiedVehicle (localPlayer) local model = getElementModel(vehicle) local seat = getPedOccupiedVehicleSeat(localPlayer) if (restrictedTo[model] and seat ~= 0) then local x,y,z = getElementPosition(localPlayer) createProjectile(localPlayer, 19, x, y, z + 2, 1, nil, nil, nil, nil, -1, -1, -1, 0) end end end bindKey ("o", "down",functionName) 4 Link to comment
Andres99907 Posted October 8, 2016 Author Share Posted October 8, 2016 Good job guys! i invite you to my my server of gta online style party with my friends... yeah! 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now