TorNix~|nR Posted July 29, 2018 Share Posted July 29, 2018 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
SycroX Posted July 29, 2018 Share Posted July 29, 2018 (edited) 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 July 29, 2018 by #َxLysandeR Link to comment
TorNix~|nR Posted July 29, 2018 Author Share Posted July 29, 2018 Thank you so much jaazak allah <3 Link to comment
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