Jump to content

toggleControl problem


Karoleq

Recommended Posts

Posted (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 by Karoleq
Posted (edited)
local localPlayer = getLocalPlayer()
function togglePlayerControl(weapon) 
	toggleControl("fire", false) 
	if isPedAiming(localPlayer) then
		toggleControl("fire", true) 
	end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), togglePlayerControl)

 

Edited by idarrr
  • Like 1
Posted

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.

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...