Jump to content

[LUA] Help with carhop script


Recommended Posts

 

For those who don't know carhopping is opening an unlocked car and looting it (taking change and whatnot valuables people leave in their car), but not taking the car.

/spawn spawns an unlocked baitCar

when you enter any vehicle and that vehicle is a bait car, the player will freeze for 15 seconds, player will force exit, a message will say "Looting..." and a small amount of cash is handed to the player. My problem is the getPedOccupiedVehicle, it's getting the vehicle element instead of the player and im wondering why

--NPC CARS
function createBaitCar(player,command)
	baitCar = createVehicle(551, 2321, -1951 , 14,0,0,90)
	baitCarChance = 1
	
	if baitCarChance == 1 then
		setVehicleLocked(baitCar, false)
		outputChatBox("Created unlocked bait car.",player)
	elseif baitCarChance > 1 then
		setVehicleLocked(baitCar, true)
		outputChatBox("Created locked bait car.",player)
	end
	
end

function carHop(vehicle,player)
	hoppedCar = getPedOccupiedVehicle(player)
	if hoppedCar == baitCar then
    	outputChatBox("Looting...")
    end
end

addCommandHandler("spawn", createBaitCar )
addEventHandler("onPlayerVehicleEnter", getRootElement(), carHop)
Edited by ReeferMadness
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...