Jump to content

Por que a função não é chamada?


Recommended Posts

Alguém consegue me responder pq a function finish n é chamada?

function markerb1()
    if CurrentMarker >= 2 then 
        destroyElement(marker)
        destroyElement(blip)
    end 

    if CurrentMarker == 2 then --42 = ultima
        outputChatBox("Você terminou, entre na auto-escola para ver sua avaliação.", getRootElement(), 0, 255, 0) 
        health = getElementHealth(car)
        fnh = createMarker(-2026.83, -114.85, 1034, "cylinder", 1.0, _,_,_,_, getRootElement())
        setElementInterior(fnh, 3)
        destroyElement(car)
        addEventHandler("onMarkerHit", fnh, finish)
    else
        marker = createMarker(markersb[CurrentMarker][1], markersb[CurrentMarker][2], markersb[CurrentMarker][3], "checkpoint", 5.0, 255, 0, 0, 90, getRootElement())
        blip = createBlipAttachedTo(marker, _, _, _, _, _, _, _, _, getRootElement())
        CurrentMarker = CurrentMarker + 1 
    end
end

function finish(hitElement, matchingDimension)
    if health >= 900 then
        outputChatBox("Você aprovado, agora você possui habilitação tipo B.", getRootElement(), 0, 255, 0)
        account = getPlayerAccount(hitElement)
        setAccountData(account, "habilitacao.tipob", true) 
    else
        outputChatBox("Você foi reprovado, tente novamente.", getRootElement(), 255, 0, 0)
    end
    started = false 
end

Ele chega a me mostrar a mensagem de que terminou, e cria a marker dentro da auto-escola, mas qnd eu passo nela, nada acontece, já troquei o onMarkerHit pelo onPlayerMarkerHit, mas anyway, não funcionou

Edited by Lord Henry
Link to comment
function markerb1()
    if CurrentMarker >= 2 then 
        destroyElement(marker)
        destroyElement(blip)
    end 

    if CurrentMarker == 2 then --42 = ultima
        outputChatBox("Você terminou, entre na auto-escola para ver sua avaliação.", getRootElement(), 0, 255, 0) 
        health = getElementHealth(car)
        fnh = createMarker(-2026.83, -114.85, 1034, "cylinder", 1.0, _,_,_,_, getRootElement())
        setElementInterior(fnh, 3)
        destroyElement(car)
        addEventHandler("onMarkerHit", fnh, finish)
    else
        marker = createMarker(markersb[CurrentMarker][1], markersb[CurrentMarker][2], markersb[CurrentMarker][3], "checkpoint", 5.0, 255, 0, 0, 90, getRootElement())
        blip = createBlipAttachedTo(marker, _, _, _, _, _, _, _, _, getRootElement())
        CurrentMarker = CurrentMarker + 1 
    end
end

function finish(hitElement, matchingDimension)
    if health >= 900 then
        outputChatBox("Você aprovado, agora você possui habilitação tipo B.", getRootElement(), 0, 255, 0)
    	if ( getElementType ( hitElement ) == 'player' ) then 
        	account = getPlayerAccount(hitElement)
      elseif ( getElementType ( hitElement ) == 'vehicle' ) then 
      		account = getPlayerAccount(getVehicleOccupant ( hitElement ))
      	end 
        setAccountData(account, "habilitacao.tipob", true) 
    else
        outputChatBox("Você foi reprovado, tente novamente.", getRootElement(), 255, 0, 0)
    end
    started = false 
end

and you need check from player not in guest account

Edited by Infinity-War
  • Like 1
Link to comment
  • Other Languages Moderators
1 hour ago, SrPattif said:

Outra coisa é que você está solicitando uma int chamada health, mas ela não está declarada na função finish...

Ele declarou ela como sendo variável global na linha 9.

  • Like 2
Link to comment
3 hours ago, SrPattif said:

Digite /debugscript 3 no chat e veja se aparece algum erro...

 

Outra coisa é que você está solicitando uma int chamada health, mas ela não está declarada na função finish...

Então, oq me intriga é não apresentar nenhum erro, nem no debugscript, nem no console, e a variável healh é global 

Link to comment
3 hours ago, Infinity-War said:

function markerb1()
    if CurrentMarker >= 2 then 
        destroyElement(marker)
        destroyElement(blip)
    end 

    if CurrentMarker == 2 then --42 = ultima
        outputChatBox("Você terminou, entre na auto-escola para ver sua avaliação.", getRootElement(), 0, 255, 0) 
        health = getElementHealth(car)
        fnh = createMarker(-2026.83, -114.85, 1034, "cylinder", 1.0, _,_,_,_, getRootElement())
        setElementInterior(fnh, 3)
        destroyElement(car)
        addEventHandler("onMarkerHit", fnh, finish)
    else
        marker = createMarker(markersb[CurrentMarker][1], markersb[CurrentMarker][2], markersb[CurrentMarker][3], "checkpoint", 5.0, 255, 0, 0, 90, getRootElement())
        blip = createBlipAttachedTo(marker, _, _, _, _, _, _, _, _, getRootElement())
        CurrentMarker = CurrentMarker + 1 
    end
end

function finish(hitElement, matchingDimension)
    if health >= 900 then
        outputChatBox("Você aprovado, agora você possui habilitação tipo B.", getRootElement(), 0, 255, 0)
    	if ( getElementType ( hitElement ) == 'player' ) then 
        	account = getPlayerAccount(hitElement)
      elseif ( getElementType ( hitElement ) == 'vehicle' ) then 
      		account = getPlayerAccount(getVehicleOccupant ( hitElement ))
      	end 
        setAccountData(account, "habilitacao.tipob", true) 
    else
        outputChatBox("Você foi reprovado, tente novamente.", getRootElement(), 255, 0, 0)
    end
    started = false 
end

and you need check from player not in guest account

Still don't working

14 minutes ago, Infinity-War said:

@PeeQ.
values in server for all players .
values in client for one player .

yeah, i see, i will change later, but, i need test first 

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