Bryton Posted June 1, 2021 Share Posted June 1, 2021 Below is a simple code that allows all vehicles to fire missiles. How can we adjust this to make only 1 vehicle (Infernus: id 411) fire missiles. local shootTimer = nil function shoot() local vehicle = getPedOccupiedVehicle(localPlayer) if not isElement(vehicle) then return end if(not isTimer(shootTimer))then local posX, posY, posZ = getElementPosition(vehicle) shootTimer = setTimer(function()end, 5000, 1) createProjectile(vehicle, 19, posX, posY, posZ, 1.0) end end bindKey("vehicle_fire", "down", shoot) bindKey("vehicle_secondary_fire", "down", shoot) Link to comment
SpecT Posted June 1, 2021 Share Posted June 1, 2021 (edited) Welcome to the Forums! To do that you will need to use getElementModel function to get vehicle's model ID. Like this: local shootTimer = nil function shoot() local vehicle = getPedOccupiedVehicle(localPlayer) -- stop if "vehicle" is not an element or if its not infernus (411) if not isElement(vehicle) or getElementModel(vehicle) ~= 411 then return end if(not isTimer(shootTimer))then local posX, posY, posZ = getElementPosition(vehicle) shootTimer = setTimer(function()end, 5000, 1) createProjectile(vehicle, 19, posX, posY, posZ, 1.0) end end bindKey("vehicle_fire", "down", shoot) bindKey("vehicle_secondary_fire", "down", shoot) Edited June 1, 2021 by SpecT 1 Link to comment
Bryton Posted June 1, 2021 Author Share Posted June 1, 2021 Works like a charm! many thanks SpecT. 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