I am developing a car control plugin for GTA IV and everything is working except the lock/unlock doors feature.
Despite using the Player.LastVehicle
handle, the code only works while the player is in the car. How can I get the code to work when the player is inside or outside the car?
Here's what I have so far:
'Lock/Unlock
If e.Key = Keys.OemPipe AndAlso e.Control Then
'Lock Codes: 1 - Unlocked; 2 - Locked (Player & NPCs); 3 - Locked (Player); 4 - Locked (Player, Inside); 7 - Locked (Can Break Into)
If DoorLock = False Then
Player.LastVehicle.HazardLightsOn = True
Wait(1000)
Player.LastVehicle.HazardLightsOn = False
Native.Function.Call("LOCK_CAR_DOORS", Player.LastVehicle, 2)
DoorLock = True
Game.DisplayText("Vehicle Locked")
Else
Player.LastVehicle.HazardLightsOn = True
Wait(2000)
Player.LastVehicle.HazardLightsOn = False
Native.Function.Call("LOCK_CAR_DOORS", Player.LastVehicle, 1)
DoorLock = False
Game.DisplayText("Vehicle Unlocked")
End If
End If