Bonsai Posted August 3, 2010 Posted August 3, 2010 Hey Guys, I tried to disable the secondary Weapon in Hunter {Minigun), but it doesnt work. It shall disable secondary Weapon, when the Player hits a Hunter Pickup. I got this code from wiki, but its not made for Race Mode. function disableFireForHunter ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 425 ) then -- if they entered a hunter toggleControl ( "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( "vehicle_secondary_fire", true ) -- enable their fire key end end addEventHandler ( "onClientPlayerEnterVehicle", getLocalPlayer(), disableFireForHunter) I changed it so that it should actually work, when the Player hits Vehicle Change Pickup. function disableFireForHunter ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 425 ) then -- if they entered a hunter toggleControl ( "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( "vehicle_secondary_fire", true ) -- enable their fire key end setTimer(disableFireForHunter, 1000, 0) end addEventHandler ( "onClientResourceStart", getLocalPlayer(), disableFireForHunter ) Maybe someone knows a solution for this problem.
KagerA Posted August 3, 2010 Posted August 3, 2010 1st of all: You placed setTimer inside "himself". Your script starts a new timer every second. And also, how is this func get the player's vehicle? try smth like that: setTimer(disableFireForHunter, 1000, -1) function disableFireForHunter () local theVehicle = getPedOccupiedVehicle(getLocalPlayer()); if ( getElementModel ( theVehicle ) == 425 ) then -- if they entered a hunter toggleControl ( "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( "vehicle_secondary_fire", true ) -- enable their fire key end end
Bonsai Posted August 3, 2010 Author Posted August 3, 2010 Yeah, I did that because there is no "OnClientVehicleChange". And I want the function to check that always, and not just at map start. EDIT: Whats -1?
KagerA Posted August 3, 2010 Posted August 3, 2010 what is "-1"? it is the infinite timer, setTimer(func,1000,0) and setTimer(func,1000,-1) - they are the same)
Bonsai Posted August 3, 2010 Author Posted August 3, 2010 Alright, I tested yours, but nothing happened. The Weapon is still useable.
KagerA Posted August 3, 2010 Posted August 3, 2010 oh, yeap, just a small error >_<. "setTimer" must be after his function, like this: function disableFireForHunter () outputChatBox("test"); local theVehicle = getPedOccupiedVehicle(getLocalPlayer()); if getElementModel ( theVehicle ) == 425 then toggleControl ( "vehicle_secondary_fire", false ) else toggleControl ( "vehicle_secondary_fire", true ) end end setTimer(disableFireForHunter, 1000, -1) P.S - just tested it, it works! P.P.S - remove the outputChatBox("test"); =3
dzek (varez) Posted August 3, 2010 Posted August 3, 2010 WTF? leave these timers alone!! function disableFireForHunter ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 425 ) then -- if they entered a hunter toggleControl ( "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( "vehicle_secondary_fire", true ) -- enable their fire key end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), disableFireForHunter) the only problem is that onClientPlayerEnterVehicle event not exist, it's onClientPlayerVehicleEnter there was bug in wiki, and i fixed it
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