Xwad Posted April 29, 2015 Share Posted April 29, 2015 Hi i made a script that makes possible when i press alt in the helicopter the it will shoot a rocket but its not working:/ function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if getElementModel(source) == 497 then local vX, vY, vZ = getElementPosition(source) createProjectile(vehicle, 19, x, y, z) end end bindKey("alt", "down", shootProjectile) setTimer ( shootProjectile, 1000, 1, "Reloading" ) Link to comment
John Smith Posted April 29, 2015 Share Posted April 29, 2015 change local vX,vY...etc with local x,y,z = getElementPosition(vehicle) Link to comment
Walid Posted April 29, 2015 Share Posted April 29, 2015 Replace source with vehicle here: Link to comment
Xwad Posted April 29, 2015 Author Share Posted April 29, 2015 not working:( function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if getElementModel(vehicle) == 497 then local x,y,z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end bindKey("alt", "down", shootProjectile) setTimer ( shootProjectile, 1000, 1, "Reloading" ) Link to comment
John Smith Posted April 29, 2015 Share Posted April 29, 2015 Are you clicking left alt key? For left alt key, use 'lalt' Link to comment
Xwad Posted April 29, 2015 Author Share Posted April 29, 2015 Tahnks now its working with lalt:D but the timer is still not working. Link to comment
Walid Posted April 29, 2015 Share Posted April 29, 2015 Tahnks now its working with lalt:D but the timer is still not working. i think you don't need setTimer here. Link to comment
John Smith Posted April 29, 2015 Share Posted April 29, 2015 Add this line before bindKey addCommandHandler("Reloading",shootProjectile) Though idk why u need timer Link to comment
Walid Posted April 29, 2015 Share Posted April 29, 2015 Add this line before bindKey addCommandHandler("Reloading",shootProjectile) Though idk why u need timer Why he need to use addCommanHandler() , he already use bindKey Example: function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if getElementModel(vehicle) == 497 then local x,y,z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end bindKey("lalt", "down", shootProjectile) bindKey("ralt", "down", shootProjectile) Link to comment
Xwad Posted April 29, 2015 Author Share Posted April 29, 2015 I want to set 4 sec time betwen the projectile shoots. Link to comment
John Smith Posted April 29, 2015 Share Posted April 29, 2015 local reloadTime = 4000 -- in miliseconds function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then if getElementModel(vehicle) == 497 then if not getElementData(localPlayer,"shoot") then local x,y,z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) setElementData(localPlayer,"shoot",true) local p = localPlayer setTimer(function() setElementData(p,"shoot",false) end,reloadTime,1) end end end end bindKey("lalt", "down", shootProjectile) Link to comment
Walid Posted April 29, 2015 Share Posted April 29, 2015 I want to set 4 sec time betwen the projectile shoots. local antiSpamAds = {} function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then if getElementModel(vehicle) == 497 then if isTimer(antiSpamAds[localPlayer]) then return end local x,y,z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) antiSpamAds[localPlayer] = setTimer(function() end, 4000, 1) end end end bindKey("lalt", "down", shootProjectile) bindKey("ralt", "down", shootProjectile) Link to comment
John Smith Posted April 29, 2015 Share Posted April 29, 2015 Walid, your code does exactly the same thing as mine. Link to comment
Walid Posted April 29, 2015 Share Posted April 29, 2015 Walid, your code does exactly the same thing as mine. Yeh i know sorry bro i didn't see your code . Link to comment
Xwad Posted April 29, 2015 Author Share Posted April 29, 2015 Working now 100% tahnks:D! 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