Stanley Sathler Posted May 20, 2015 Share Posted May 20, 2015 Pessoal, estou com uma função que deveria ser chamada após o jogador entrar em uma marca. A função whenVanIsDelivered(). Porém ela simplesmente não é chamada. local vanSpawnPoints = { --[[ {2485.7204, -1655.1574, 13.3279, 91.2174}, {666.8325, -546.3470, 16.3359, 88.0839}, {2866.3618, -898.2083, 10.9979, 358.1331}, {-1713.8564, 393.9782, 7.1796, 221.2050}, {-1537.4736, 1225.6967, 7.1875, 89.9169}, ]] {993.0109, 2088.0456, 10.7968, 178.2420}, } local vanDeliveryPoints = {{990.9379, 2051.0744, 10.8203}} local vanModel = 482 --Burrito local startCountdown = true local deliveryBlip = nil local deliveryMarker = createMarker(0,0,0) function createsVehicleOnMap() local n = math.random(#vanSpawnPoints) local vehicle = createVehicle(vanModel, vanSpawnPoints[n][1], vanSpawnPoints[n][2], vanSpawnPoints[n][3]+1, 0, 0, vanSpawnPoints[n][4]) if vehicle then outputChatBox("A van full of drugs has just spawned on the map. Go get it if you are looking for money.", getRootElement(), 255, 0, 0) createBlipAttachedTo(vehicle, 51) setElementData(vehicle, "deliveryVan", true) end end addEventHandler("onResourceStart", resourceRoot, createsVehicleOnMap) function whenPlayerEntersOnVan(whoEntered) if getElementData(source, "deliveryVan") == true then -- Now, we create the delivery point local n = math.random(#vanDeliveryPoints) -- Creating our delivery marker deliveryMarker = createMarker(vanDeliveryPoints[n][1], vanDeliveryPoints[n][2], vanDeliveryPoints[n][3]-1, "cylinder", 3, 255, 0, 0, 150, whoEntered) -- Creating our delivery blip deliveryBlip = createBlip(vanDeliveryPoints[n][1], vanDeliveryPoints[n][2], vanDeliveryPoints[n][3], 53) outputChatBox("The delivery point was marked with a flag on radar.", whoEntered, 255, 0, 0) end end addEventHandler("onVehicleEnter", resourceRoot, whenPlayerEntersOnVan) function whenPlayerExitFromVan(whoExit) if getElementData(source, "deliveryVan") == true then -- Destroy elements destroyElement(deliveryBlip) destroyElement(deliveryMarker) end end addEventHandler("onVehicleExit", resourceRoot, whenPlayerExitFromVan) function whenVanIsDelivered(hitElement) outputChatBox("Marcador atingido.") end addEventHandler("onMarkerHit", deliveryMarker, whenVanIsDelivered) Por que será, pessoal? Link to comment
Walid Posted May 20, 2015 Share Posted May 20, 2015 function whenVanIsDelivered(hitElement,matchDim) if (matchDim and isElement(hitElement) and getElementType(hitElement) == "player") then outputChatBox("Marcador atingido.",hitElement,0,255,0) end end addEventHandler("onMarkerHit", deliveryMarker, whenVanIsDelivered) Link to comment
n3wage Posted May 20, 2015 Share Posted May 20, 2015 Porque o evento foi adicionado apenas para a primeira marker criada, na linha 15, e não para a outra criada na linha 35, Assim deve funcionar: function whenVanIsDelivered(hitElement,matchDim) if ( source == deliveryMarker ) then outputChatBox("Marcador atingido.") end end addEventHandler("onMarkerHit", root, whenVanIsDelivered) Link to comment
Stanley Sathler Posted May 21, 2015 Author Share Posted May 21, 2015 n3wage, funcionou! Não havia me tocado nessa "hierarquia de importâncias". Obrigado mesmo, cara! Valeu também, Walid. 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