Jump to content

How to turn Secondary Weapon off


Bonsai

Recommended Posts

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.

Link to comment

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

Link to comment

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

Link to comment

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

Link to comment

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...