Jump to content

Request info about getVehicleOccupants


Overkillz

Recommended Posts

Hey everyone, How are u ? I hope u are ok ^^

I will like to about getVehicleOccupants

I have made a Info radar, which is using

addEventHandler("onClientRender", root, 
function ( source ) 
    local playerVehicle = getPedOccupiedVehicle(localPlayer) 
    if playerVehicle then 
    dxDrawImage(posx,posy*1.25,height,height2, "data/radar/info.png",0,0,0,tocolor(255,255,255,255)) -- Info Imagen 
    end 
end) 

InfoRadar is showed when the player is in vehicle, dat works perfectly with 0 km/h, but

When a player has a hight velocity like 221 km/h and press enter, the radar still showing even if he is died.

There is some method fix it ?

I will like to do it if the player is died, don't show it, and the player is alive or training, then yes.

I hope u can help me.

Regards.

Link to comment

And what happens if a player is driving at 100 km/h and presses enter, and dies?

Is it still showing?

If so - Then make this event:

onClientPlayerWasted and at the beginning of its implementation put: if source == localPlayer (This makes sure the player that died was the same client)

Link to comment

Use your own functions to check if the player is in a vehicle. You can use this by manually checking when a player has fully entered the vehicle, and when the player has just started to exit the vehicle. This way you know if and when the player is actually inside of the vehicle. Just make sure to attach the exit stuff with your existing exit event, or otherwise your other statements may be ignored.

Link to comment
Use your own functions to check if the player is in a vehicle. You can use this by manually checking when a player has fully entered the vehicle, and when the player has just started to exit the vehicle. This way you know if and when the player is actually inside of the vehicle. Just make sure to attach the exit stuff with your existing exit event, or otherwise your other statements may be ignored.

Somethings to check about u suggested me ?

U mean like this

if state == "alive" or state == "training" then 

--show radar.

?

Link to comment

I don't understand your example.

addEventHandler( "onClientVehicleEnter", root, 
    function( player ) 
        if ( not isElement( player ) ) or ( getElementType( player ) ~= "player" ) then return end 
        setElementData( player, "player:vehicle.occupied", true, true ) 
    end 
) 
addEventHandler( "onClientVehicleStartExit", root, 
    function( player ) 
        if ( not isElement( player ) ) or ( getElementType( player ) ~= "player" ) then return end 
        setElementData( player, "player:vehicle.occupied", false, true ) 
    end 
) 
function isInVehicle( player ) 
    if ( isElement( player ) ) and ( getElementType( player ) == "player" ) and ( getElementData( player, "player:vehicle.occupied" ) ) then 
        return true 
    end 
    return false 
end 
addEventHandler( "onClientRender", root, 
    function( ) 
        if ( isInVehicle( localPlayer ) ) then 
            dxDrawImage( posx, posy * 1.25, height, height2, "data/radar/info.png", 0, 0, 0, tocolor( 255, 255, 255, 255 ) ) 
        end 
    end 
) 

Edited by Guest
Link to comment
I don't understand your example.
addEventHandler( "onClientVehicleEnter", root, 
    function( player ) 
        setElementData( player, "player:vehicle.occupied", true, true ) 
    end 
) 
addEventHandler( "onClientVehicleStartExit", root, 
    function( player ) 
        setElementData( player, "player:vehicle.occupied", false, true ) 
    end 
) 
function isInVehicle( player ) 
    if ( getElementData( player, "player:vehicle.occupied" ) ) then 
        return true 
    end 
    return false 
end 
addEventHandler( "onClientRender", root, 
    function( ) 
        if ( isInVehicle( localPlayer ) ) then 
            dxDrawImage( posx, posy * 1.25, height, height2, "data/radar/info.png", 0, 0, 0, tocolor( 255, 255, 255, 255 ) ) 
        end 
    end 
) 

Thanks, I found a method, anyway thanks for ur help.

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