AhmadRS Posted March 28, 2021 Share Posted March 28, 2021 I tried to do it but it doesn't shoot local hunter = createVehicle(425,x,y,z) local ped = createPed(0,x,y,z) warpPedIntoVehicle(ped, hunter) setPedAnalogControlState(ped, "Vehicle_fire") Link to comment
SpecT Posted March 28, 2021 Share Posted March 28, 2021 (edited) Hello and welcome to the Forums! If you want the ped to shoot with a weapon (if this is what you want) you should use the control named "fire" instead of "Vehicle_fire". Edit: Nevermind... didn't read the whole script. Sorry! Edited March 28, 2021 by SpecT Link to comment
AhmadRS Posted March 28, 2021 Author Share Posted March 28, 2021 (edited) 3 minutes ago, SpecT said: Hello and welcome to the Forums! If you want the ped to shoot with a weapon (if this is what you want) you should use the control named "fire" instead of "Vehicle_fire". No bro I want the ped to shoot from the the hunter (missiles). Not from his own weapon Edited March 28, 2021 by AhmadRS Link to comment
Monument Posted March 28, 2021 Share Posted March 28, 2021 3 hours ago, AhmadRS said: I tried to do it but it doesn't shoot local hunter = createVehicle(425,x,y,z) local ped = createPed(0,x,y,z) warpPedIntoVehicle(ped, hunter) setPedAnalogControlState(ped, "Vehicle_fire") try use vehicle_fire instead of Vehicle_fire Link to comment
AhmadRS Posted March 28, 2021 Author Share Posted March 28, 2021 1 minute ago, Monument said: try use vehicle_fire instead of Vehicle_fire I have just tried it.. Nope Link to comment
DiSaMe Posted March 28, 2021 Share Posted March 28, 2021 setPedAnalogControlState takes a third argument, which is a number between 0 (no effect) to 1 (full effect). For the control to take full effect, it should be like this: setPedAnalogControlState(ped, "vehicle_fire", 1) But I don't know if it's even valid to use analog control state for vehicle_fire, because you can either be shooting or not, there's no "in-between". For this reason, maybe it makes more sense to use setPedControlState: setPedControlState(ped, "vehicle_fire", true) Link to comment
AhmadRS Posted March 28, 2021 Author Share Posted March 28, 2021 18 minutes ago, CrystalMV said: setPedAnalogControlState takes a third argument, which is a number between 0 (no effect) to 1 (full effect). For the control to take full effect, it should be like this: setPedAnalogControlState(ped, "vehicle_fire", 1) But I don't know if it's even valid to use analog control state for vehicle_fire, because you can either be shooting or not, there's no "in-between". For this reason, maybe it makes more sense to use setPedControlState: setPedControlState(ped, "vehicle_fire", true) yep , i fixed the 3rd argument.. but it doesn't work as well. Besides, setPedControlState(ped, "vehicle_fire", true) only works for the player, not for ped.. That's what i have read on the wiki Link to comment
DiSaMe Posted March 28, 2021 Share Posted March 28, 2021 (edited) 30 minutes ago, AhmadRS said: Besides, setPedControlState(ped, "vehicle_fire", true) only works for the player, not for ped.. That's what i have read on the wiki No, the wiki says setPedControlState was made to work for the local player as well (in addition to peds, because previously it only worked for peds). It was setControlState that only worked for players, and because setPedControlState now works for both player and peds, setControlState has been deprecated on the client side. Anyway, if that still doesn't work, I guess the ped has not been streamed in yet when the function gets called. Another thing I just realized that needs to be taken into account is that when you hold the fire control, you only shoot missiles once. Not repeatedly. In order to keep shooting repeatedly, you need to press it repeatedly. The same holds true for peds, you need to keep switching the control state between true and false. A timer can do this: local hunter = createVehicle(425,x,y,z) local ped = createPed(0,x,y,z) warpPedIntoVehicle(ped, hunter) local function toggleFireControl() local old_state = getPedControlState(ped, "vehicle_fire") setPedControlState(ped, "vehicle_fire", not old_state) end setTimer(toggleFireControl, 100, 0) Edited March 28, 2021 by CrystalMV Link to comment
AhmadRS Posted March 28, 2021 Author Share Posted March 28, 2021 2 hours ago, CrystalMV said: No, the wiki says setPedControlState was made to work for the local player as well (in addition to peds, because previously it only worked for peds). It was setControlState that only worked for players, and because setPedControlState now works for both player and peds, setControlState has been deprecated on the client side. Anyway, if that still doesn't work, I guess the ped has not been streamed in yet when the function gets called. Another thing I just realized that needs to be taken into account is that when you hold the fire control, you only shoot missiles once. Not repeatedly. In order to keep shooting repeatedly, you need to press it repeatedly. The same holds true for peds, you need to keep switching the control state between true and false. A timer can do this: local hunter = createVehicle(425,x,y,z) local ped = createPed(0,x,y,z) warpPedIntoVehicle(ped, hunter) local function toggleFireControl() local old_state = getPedControlState(ped, "vehicle_fire") setPedControlState(ped, "vehicle_fire", not old_state) end setTimer(toggleFireControl, 100, 0) Well, thank you for the amazing explanation.. I think that shooting missiles is not possible using peds because i have tried your code and it did not work for ped, but i replaced the ped with the local player and it worked. Also , i have tried another controls like acceleration and it worked for ped. While vehicle_fire did not work. Anyway , thank you so much for helping me to realize that. 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