Jump to content

Antiveh


Recommended Posts

Hello guys I have a problem in this script, it said line: 9 Expected function at argument 3, got nil, any help please?

local colPositions = {
	{96.24, 1808.96, 230, 150},
}

local createdCols = {}

for i, k in pairs(colPositions) do
	local tCol = createColRectangle(k[1], k[2], k[3], k[4]) -- Creating the col at the position with the fix width and height.
	addEventHandler("onColShapeHit", tCol, destroyTheVehicles) -- Adding the "onColShapeHit" event to the created col.
	table.insert(createdCols, tCol) -- Adding the created col to the "createdCols" table.
end

function cancelEnter(thePlayer)
	for i, k in pairs(createdCols) do -- Looping through the created cols.
		if isElementWithinColShape(thePlayer, k) then -- Checking if the player is inside one.
			destroyElement(source) -- If he is.
			outputChatBox("Vehicles are not allowed here!", thePlayer, 255, 0, 0)
			break
		end
	end
end
addEventHandler("onVehicleStartEnter", root, cancelEnter)

function destroyTheVehicles(player)
	if getElementType(player) == "player" and isPedInVehicle(player) then
		local vehicle = getPedOccupiedVehicle(player)
		removePedFromVehicle(player)
		respawnVehicle(vehicle)
		outputChatBox("Vehicles are not allowed here!", player, 255, 0, 0)
	end
end

 

Link to comment
19 minutes ago, TorNix~|nR said:

Hello guys I have a problem in this script, it said line: 9 Expected function at argument 3, got nil, any help please?

 

u've to learn how to sort the codes

 

local colPositions = {
	{96.24, 1808.96, 230, 150},
}
local createdCols = {}

function destroyTheVehicles(player)
	if getElementType(player) == "player" and isPedInVehicle(player) then
		local vehicle = getPedOccupiedVehicle(player)
		removePedFromVehicle(player)
		respawnVehicle(vehicle)
		outputChatBox("Vehicles are not allowed here!", player, 255, 0, 0)
	end
end

for i, k in pairs(colPositions) do
	local tCol = createColRectangle(k[1], k[2], k[3], k[4]) -- Creating the col at the position with the fix width and height.
	addEventHandler("onColShapeHit", tCol, destroyTheVehicles) -- Adding the "onColShapeHit" event to the created col.
	table.insert(createdCols, tCol) -- Adding the created col to the "createdCols" table.
end

function cancelEnter(thePlayer)
	for i, k in pairs(createdCols) do -- Looping through the created cols.
		if isElementWithinColShape(thePlayer, k) then -- Checking if the player is inside one.
			destroyElement(source) -- If he is.
			outputChatBox("Vehicles are not allowed here!", thePlayer, 255, 0, 0)
			break
		end
	end
end
addEventHandler("onVehicleStartEnter", root, cancelEnter)
Edited by #َxLysandeR
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...