hi, this is my script, first marker works good, but the second(for destruction) dont work, only the outputChatBox, the marker is on the map, but dont work
Edit: on console shows this error:
WARNING: Oficina-Mecanica\spawn.Lua:22: Bad argument @ 'destroyElement' [Expected element at argument 1, got nil]
WARNING: Oficina-Mecanica\spawn.Lua:21: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got vehicle]
local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50)
local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50)
veh = {}
function Vehicle1 ( hitPlayer, getPlayerVehicle )
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
if isElement(Veh1) then
destroyElement(Veh1)
end
local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270)
warpPedIntoVehicle ( hitPlayer, Veh1 )
else
outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0)
end
end
addEventHandler( "onMarkerHit", Marker1, Vehicle1)
function Vehicle2(player)
if isElementWithinMarker(player, Marker2) then
if isPedInVehicle(player) == true then
destroyElement(veh[player])
veh[player] = nil
else
outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0)
end
end
end
addEventHandler("onMarkerHit", Marker2, Vehicle2)
sorry for my bad english