Jump to content

Evento onMarkerHit não é chamado. Por que será?


Recommended Posts

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
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

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

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...