isa_Khamdan Posted November 23, 2013 Posted November 23, 2013 Hello I am getting little problem with this code it tells me that there are bad arguments with the bind key but I am 100% sure that's it's correct but I don't know why it doesn't work function toggleFlashingLights ( thePlayer , key, keyState ) if getPlayerOccupiedVehicleSeat ( thePlayer ) == 0 then if vehicles[getPlayerOccupiedVehicle ( thePlayer )] then killTimer ( vehicles[getPlayerOccupiedVehicle ( thePlayer )] ) vehicles[getPlayerOccupiedVehicle ( thePlayer )] = nil else vehicles[getPlayerOccupiedVehicle ( thePlayer )] = setTimer ( toggleVehicleLights, 250, 0, getPlayerOccupiedVehicle ( thePlayer ) ) end end end addCommandHandler ( "flash", toggleFlashingLights ) bindKey ( thePlayer , "]", "down", toggleFlashingLights )
Castillo Posted November 23, 2013 Posted November 23, 2013 How can it be correct? "thePlayer" is not defined.
isa_Khamdan Posted November 23, 2013 Author Posted November 23, 2013 How can it be correct? "thePlayer" is not defined. Hmm , how can I define it since it's outside the function?
Castillo Posted November 23, 2013 Posted November 23, 2013 You must bind it when he player joins, and also when the resource start to every player.
isa_Khamdan Posted November 23, 2013 Author Posted November 23, 2013 like this? function toggleFlashingLights ( thePlayer , key, keyState ) if getPlayerOccupiedVehicleSeat ( thePlayer ) == 0 then if vehicles[getPlayerOccupiedVehicle ( thePlayer )] then killTimer ( vehicles[getPlayerOccupiedVehicle ( thePlayer )] ) vehicles[getPlayerOccupiedVehicle ( thePlayer )] = nil else vehicles[getPlayerOccupiedVehicle ( thePlayer )] = setTimer ( toggleVehicleLights, 250, 0, getPlayerOccupiedVehicle ( thePlayer ) ) end end end addCommandHandler ( "flash", toggleFlashingLights ) function bind () bindKey ( source , "]", "down", toggleFlashingLights ) end addEventHandler ( "onPlayerJoin", getRootElement(), bind )
isa_Khamdan Posted November 23, 2013 Author Posted November 23, 2013 so its working yet? Yes it's working fine now but how can I make it bind the key for all players not just the player who just joined.
TAPL Posted November 23, 2013 Posted November 23, 2013 so its working yet? Yes it's working fine now but how can I make it bind the key for all players not just the player who just joined. https://forum.multitheftauto.com/viewtopic.php?f=91&t=67756
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