Karoleq Posted December 17, 2016 Posted December 17, 2016 (edited) Hello, i am trying to make a script that makes shooting not possible in MTA, but when if isPedAiming it makes it possible again. If you guys know what i mean. Lets just say that i am trying to make weapon shooting system just like on Grafuroam or SAAF server, something like you need to aim first then you can start shooting, and if you are not aiming first you cant. The problem is: i dont know so much about scripting and my script doesnt work, heres the code: please help me function toggleControl(weapon) toggleControl(thePlayer,"fire",false) if isPedAiming then toggleControl(thePlayer,"fire",true) end end addEventHandler ( "onClientResourceStart", getLocalPlayer(), toggleControl ) Edited December 17, 2016 by Karoleq
ViRuZGamiing Posted December 17, 2016 Posted December 17, 2016 your function name is the same as an MTA existing function 'toggleControl' use something different
idarrr Posted December 20, 2016 Posted December 20, 2016 (edited) local localPlayer = getLocalPlayer() function togglePlayerControl(weapon) toggleControl("fire", false) if isPedAiming(localPlayer) then toggleControl("fire", true) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(), togglePlayerControl) Edited December 20, 2016 by idarrr 1
Mega9 Posted December 20, 2016 Posted December 20, 2016 There is no reason to define localPlayer in your code as it is already predefined by MTA, using localPlayer in any of your client scripts will work just as well as getLocalPlayer. 1
Karoleq2 Posted December 27, 2016 Posted December 27, 2016 idarrr it works, player cannot shoot when he is not aiming but, he still cannot shoot when he is aiming. btw i made new account yes.
iPrestege Posted December 27, 2016 Posted December 27, 2016 You have to use the source code of isPedAiming useful function.
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