Jump to content

Repair Vehicle.


#DaMiAnO

Recommended Posts

Hi, i have this code, but not working. /debugscript 3 show no errors and warnings.

local screenWidth, screenHeight = guiGetScreenSize() 
  
function repairVehicle() 
local theVehicle = getPedOccupiedVehicle(source) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        setTimer(RemoveDrawText, 3000, 1, repair) 
    else 
    repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    setTimer(RemoveDrawText, 3000, 1, repair2) 
    end 
end 
  
function RemoveDrawText(repair, repair2) 
    destroyElement(repair) 
    destroyElement(repair2) 
end 
  
function bindKeyForRepair(source) 
    bindKey(source, "2", "down", repairVehicle) 
end 
addCommandHandler("repair", bindKeyForRepair) 

Link to comment

Client

local screenWidth, screenHeight = guiGetScreenSize( ) 
  
local timer 
  
local function draw( ) 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText( "Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) 
    end  
end 
  
function repairVehicle( ) 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        fixVehicle( theVehicle ) 
    end  
end 
  
function bindKeyForRepair( ) 
    bindKey(  "2", "down", repairVehicle ) 
    addEventHandler( 'onClientRender',root,draw ) 
    timer = setTimer( 
        function( ) 
            removeEventHandler( 'onClientRender',root,draw ) 
            unbindKey(  "2", "down", repairVehicle ) 
        end, 
    3000, 
    1 )  
end 
addCommandHandler( "repair", bindKeyForRepair ) 
  
  

Analysis of the code

local screenWidth, screenHeight = guiGetScreenSize() 
  
function repairVehicle() 
local theVehicle = getPedOccupiedVehicle(source) -- source is source in event ( you need use localPlayer in this situation ) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        setTimer(RemoveDrawText, 3000, 1, repair) 
    else 
    repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    setTimer(RemoveDrawText, 3000, 1, repair2) 
    end 
end 
  
function RemoveDrawText(repair, repair2) 
    destroyElement(repair) 
    destroyElement(repair2) 
end 
  
function bindKeyForRepair(source) -- source argument only in server side 
    bindKey(source, "2", "down", repairVehicle) -- source argument only in server side 
end 
addCommandHandler("repair", bindKeyForRepair) 

dxDrawText not return element.

And you need draw text only in render.

Link to comment
Hi, i have this code, but not working. /debugscript 3 show no errors and warnings.
local screenWidth, screenHeight = guiGetScreenSize() 
  
function repairVehicle() 
local theVehicle = getPedOccupiedVehicle(source) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        setTimer(RemoveDrawText, 3000, 1, repair) 
    else 
    repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    setTimer(RemoveDrawText, 3000, 1, repair2) 
    end 
end 
  
function RemoveDrawText(repair, repair2) 
    destroyElement(repair) 
    destroyElement(repair2) 
end 
  
function bindKeyForRepair(source) 
    bindKey(source, "2", "down", repairVehicle) 
end 
addCommandHandler("repair", bindKeyForRepair) 

dxDrawText must be in onClientRender event because it needs to be rendered every time.

Client-side:

local screenWidth, screenHeight = guiGetScreenSize() 
local visible = false 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey('f2','down', 
    function() 
        if visible then 
            removeEventHandler('onClientRender',root,repairVehicle) 
        else 
            addEventHandler('onClientRender',root,repairVehicle) 
            setTimer( 
                function() 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1) 
        end 
    end 
) 
  

Why add command to bind key to repair the vehicle? :S

Link to comment
Hi, i have this code, but not working. /debugscript 3 show no errors and warnings.
local screenWidth, screenHeight = guiGetScreenSize() 
  
function repairVehicle() 
local theVehicle = getPedOccupiedVehicle(source) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        setTimer(RemoveDrawText, 3000, 1, repair) 
    else 
    repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    setTimer(RemoveDrawText, 3000, 1, repair2) 
    end 
end 
  
function RemoveDrawText(repair, repair2) 
    destroyElement(repair) 
    destroyElement(repair2) 
end 
  
function bindKeyForRepair(source) 
    bindKey(source, "2", "down", repairVehicle) 
end 
addCommandHandler("repair", bindKeyForRepair) 

dxDrawText must be in onClientRender event because it needs to be rendered every time.

Client-side:

local screenWidth, screenHeight = guiGetScreenSize() 
local visible = false 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey('f2','down', 
    function() 
        if visible then 
            removeEventHandler('onClientRender',root,repairVehicle) 
        else 
            addEventHandler('onClientRender',root,repairVehicle) 
            setTimer( 
                function() 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1) 
        end 
    end 
) 
  

Why add command to bind key to repair the vehicle? :S

dxDrawText not return element.

And you need draw text only in render.

Link to comment
Client
local screenWidth, screenHeight = guiGetScreenSize( ) 
  
local timer 
  
local function draw( ) 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText( "Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) 
    end  
end 
  
function repairVehicle( ) 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        fixVehicle( theVehicle ) 
    end  
end 
  
function bindKeyForRepair( ) 
    bindKey(  "2", "down", repairVehicle ) 
    addEventHandler( 'onClientRender',root,draw ) 
    timer = setTimer( 
        function( ) 
            removeEventHandler( 'onClientRender',root,draw ) 
            unbindKey(  "2", "down", repairVehicle ) 
        end, 
    3000, 
    1 )  
end 
addCommandHandler( "repair", bindKeyForRepair ) 
  
  

Analysis of the code

local screenWidth, screenHeight = guiGetScreenSize() 
  
function repairVehicle() 
local theVehicle = getPedOccupiedVehicle(source) -- source is source in event ( you need use localPlayer in this situation ) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        setTimer(RemoveDrawText, 3000, 1, repair) 
    else 
    repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    setTimer(RemoveDrawText, 3000, 1, repair2) 
    end 
end 
  
function RemoveDrawText(repair, repair2) 
    destroyElement(repair) 
    destroyElement(repair2) 
end 
  
function bindKeyForRepair(source) -- source argument only in server side 
    bindKey(source, "2", "down", repairVehicle) -- source argument only in server side 
end 
addCommandHandler("repair", bindKeyForRepair) 

dxDrawText not return element.

And you need draw text only in render.

Not working. ;P

Link to comment

Test mine.

local screenWidth, screenHeight = guiGetScreenSize() 
local visible = false 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey('f2','down', 
    function() 
        if visible then 
            removeEventHandler('onClientRender',root,repairVehicle) 
        else 
            addEventHandler('onClientRender',root,repairVehicle) 
            setTimer( 
                function() 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1) 
        end 
    end 
) 

Only press F2.

If don't work see in debugscript.

Remember, it's client-side!

Link to comment
Test mine.
local screenWidth, screenHeight = guiGetScreenSize() 
local visible = false 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey('f2','down', 
    function() 
        if visible then 
            removeEventHandler('onClientRender',root,repairVehicle) 
        else 
            addEventHandler('onClientRender',root,repairVehicle) 
            setTimer( 
                function() 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1) 
        end 
    end 
) 

Only press F2.

If don't work see in debugscript.

Remember, it's client-side!

Working, thanks!

Topic can be closed.

Link to comment
Test mine.
local screenWidth, screenHeight = guiGetScreenSize() 
local visible = false 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey('f2','down', 
    function() 
        if visible then 
            removeEventHandler('onClientRender',root,repairVehicle) 
        else 
            addEventHandler('onClientRender',root,repairVehicle) 
            setTimer( 
                function() 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1) 
        end 
    end 
) 

Only press F2.

If don't work see in debugscript.

Remember, it's client-side!

Working, thanks!

Topic can be closed.

You're welcome :D

Link to comment
local screenWidth, screenHeight = guiGetScreenSize( ) 
local timer 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey( 'F2','down', 
    function( ) 
        if getPlayerMoney( ) >= 2500 then 
            takePlayerMoney( 2500 ) 
            if isTimer( timer ) then 
                return 
            end 
            local theVehicle = getPedOccupiedVehicle( localPlayer ) 
            if theVehicle then 
                fixVehicle( theVehicle ) 
            end 
            addEventHandler('onClientRender',root,repairVehicle) 
            timer = setTimer( 
                function( ) 
                    removeEventHandler('onClientRender',root,repairVehicle) 
                end, 
            3000,1 ) 
        end  
    end 
) 

...

function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if(theVehicle) then 
        fixVehicle(theVehicle) 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 

Good job fix car in render! :/

Edited by Guest
Link to comment
local screenWidth, screenHeight = guiGetScreenSize( ) 
local timer,state 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements 
    end 
end 
  
bindKey( 'F2','down', 
    function( ) 
        if not state then 
            if getPlayerMoney( ) >= 2500 then 
                takePlayerMoney( 2500 ) 
                if isTimer( timer ) then 
                    return 
                end 
                local theVehicle = getPedOccupiedVehicle( localPlayer ) 
                if theVehicle then 
                    fixVehicle( theVehicle ) 
                end 
                addEventHandler( 'onClientRender',root,repairVehicle ) 
                state = true 
                timer = setTimer( 
                    function( ) 
                        removeEventHandler( 'onClientRender',root,repairVehicle ) 
                        state = false 
                    end, 
                5000,1 ) 
            end  
        end  
    end 
) 

Link to comment
local screenWidth, screenHeight = guiGetScreenSize() 
local timer, state 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    end 
end 
  
bindKey( '2','down', 
    function() 
        if not state then 
            if getPlayerMoney() >= 2500 then 
                takePlayerMoney(2500) 
                else 
                dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
                end 
                if isTimer(timer) then 
                    return 
                end 
                local theVehicle = getPedOccupiedVehicle( localPlayer ) 
                if theVehicle then 
                    fixVehicle( theVehicle ) 
                end 
                addEventHandler( 'onClientRender',root,repairVehicle ) 
                state = true 
                timer = setTimer( 
                    function() 
                        dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
                        removeEventHandler( 'onClientRender',root,repairVehicle ) 
                        state = false 
                    end, 
                5000,1 ) 
            end 
        end  
    end 
end 
) 

15phfmb.png

Link to comment
local screenWidth, screenHeight = guiGetScreenSize() 
local timer, state 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    end 
end 
  
function drawNoMoneyText() 
    dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
end 
  
function drawAnotherText() 
    dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
end 
  
bindKey( '2','down', 
    function() 
        if (not state) then 
            if (getPlayerMoney() >= 2500) then 
                takePlayerMoney(2500) 
            else 
                addEventHandler("onClientRender",root,drawNoMoneyText) 
            end 
            if isTimer(timer) then 
                return 
            end 
            local theVehicle = getPedOccupiedVehicle( localPlayer ) 
            if theVehicle then 
                fixVehicle( theVehicle ) 
            end 
            addEventHandler( 'onClientRender',root,repairVehicle ) 
            state = true 
            timer = setTimer( 
            function() 
                addEventHandler("onClientRender",root,drawAnotherText) 
                removeEventHandler( 'onClientRender',root,repairVehicle ) 
                state = false 
            end, 
            5000,1 ) 
        end 
    end 
) 

Link to comment

local screenWidth, screenHeight = guiGetScreenSize() 

local timer, state

 

function repairVehicle()

    local theVehicle = getPedOccupiedVehicle( localPlayer )

    if theVehicle then

        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false)

    else

        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false)

    end

end

 

bindKey( '2','down',

    function( )

        if not state then

            if getPlayerMoney() >= 2500 then

                takePlayerMoney(2500)

            else

                dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false)

            end

            if isTimer(timer) then

                return

            end

            local theVehicle = getPedOccupiedVehicle( localPlayer )

            if theVehicle then

                fixVehicle( theVehicle )

            end

            addEventHandler( 'onClientRender',root,repairVehicle )

            state = true

            timer = setTimer(

                function()

                    dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false)

                    removeEventHandler( 'onClientRender',root,repairVehicle )

                    state = false

                end,

            5000,1 )

        end

    end

)

Link to comment
local screenWidth, screenHeight = guiGetScreenSize() 
local timer, state 
  
function repairVehicle() 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    if theVehicle then 
        dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    else 
        dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    end 
end 
  
bindKey( '2','down', 
    function( ) 
        if not state then 
            if getPlayerMoney() >= 2500 then 
                takePlayerMoney(2500) 
            else 
                dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
            end 
            if isTimer(timer) then 
                return 
            end 
            local theVehicle = getPedOccupiedVehicle( localPlayer ) 
            if theVehicle then 
                fixVehicle( theVehicle ) 
            end 
            addEventHandler( 'onClientRender',root,repairVehicle ) 
            state = true 
            timer = setTimer( 
                function() 
                    dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
                    removeEventHandler( 'onClientRender',root,repairVehicle ) 
                    state = false 
                end, 
            5000,1 ) 
        end 
    end  
) 

            timer = setTimer( 
                function() 
                    dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
                    removeEventHandler( 'onClientRender',root,repairVehicle ) 
                    state = false 
                end, 
            5000,1 ) 

dxDrawText will not appear because you have to use onClientRender event :S

Link to comment

Yes i know i just fix SolidShake14 syntax error.

I see SolidShake14 again edit my post and delete this: SolidShake14 you have syntax error.

:/

local screenWidth, screenHeight = guiGetScreenSize( ) 
local  state, msg, info, warning 
local uTimers = { } 
  
function repairVehicle() 
    if msg then 
        local theVehicle = getPedOccupiedVehicle( localPlayer ) 
        if theVehicle then 
            dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        else 
            dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
        end 
    end 
    if info then 
        dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    end  
    if warning then 
        dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) 
    end 
end 
addEventHandler( 'onClientRender',root,repairVehicle ) 
  
bindKey( '2','down', 
    function( ) 
        if not state then 
            if getPlayerMoney() >= 2500 then 
                takePlayerMoney( 2500 ) 
            else 
                warning = true 
                if isTimer( uTimers[2] ) then 
                    killTimer( uTimers[2] ) 
                end 
                uTimers[2] = setTimer( 
                    function( ) 
                        warning = false 
                    end, 
                5000, 
                1 )  
                return 
            end 
            if isTimer( uTimers[1] ) then 
                return 
            end 
            local theVehicle = getPedOccupiedVehicle( localPlayer ) 
            if theVehicle then 
                fixVehicle( theVehicle ) 
            end 
            msg = true 
            info = true 
            state = true 
            uTimers[1] = setTimer( 
                function( ) 
                    info = false 
                    msg = false 
                    state = false 
                end, 
            5000,1 ) 
        end 
    end  
) 

SolidShake14 stop edit my posts!

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