Snippet: Using your car indicators

Share your gamemodes and snippets here
Post Reply
JamesConway
Posts: 1
Joined: Wed Dec 12, 2018 8:30 pm

Snippet: Using your car indicators

Post by JamesConway » Wed Dec 12, 2018 8:32 pm

Code: Select all

function playerKeyPress(playerId, virtualKey, isKeyUp)
    local vehicleId = isPlayerInAnyVehicle(playerId)
    if(isKeyUp) then
        if(vehicleId > 0) then
            if(virtualKey == 0x45) then
                local toggled = getVehicleIndicator(vehicleId, 1)
                setVehicleIndicator(vehicleId, 1, not toggled)
            elseif(virtualKey == 0x51) then
                local toggled = getVehicleIndicator(vehicleId, 0)
                setVehicleIndicator(vehicleId, 0, not toggled)
            end
        end
    end
end
registerEvent("playerKeyPress", "onPlayerKeyPress")

function playerSpawnCredentials(playerid)
    setPlayerHooks(playerid)
end
registerEvent("playerSpawnCredentials", "onPlayerCredential")

function setPlayerHooks(playerId)
    setPlayerKeyHook(playerId, 0x45, true) -- E
    setPlayerKeyHook(playerId, 0x51, true) -- Q
end
This snippet should allow you to use your car indicators with the keyboard button Q and E.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests