#DaMiAnO Posted February 26, 2012 Share Posted February 26, 2012 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
Kenix Posted February 26, 2012 Share Posted February 26, 2012 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
drk Posted February 26, 2012 Share Posted February 26, 2012 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? Link to comment
Kenix Posted February 26, 2012 Share Posted February 26, 2012 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? dxDrawText not return element.And you need draw text only in render. Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 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
drk Posted February 26, 2012 Share Posted February 26, 2012 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
Kenix Posted February 26, 2012 Share Posted February 26, 2012 #DaMiAnO,Show your meta.xml If you use my code you need type /repair and you can use bind 2. Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 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
drk Posted February 26, 2012 Share Posted February 26, 2012 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 Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 Can you make, if player have 2500 or more, then he can use repair (takeplayermoney + repair), else player dont have 2500, then vehicle cant be repair. Link to comment
Kenix Posted February 26, 2012 Share Posted February 26, 2012 (edited) 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 February 26, 2012 by Guest Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 (edited) Working, my bad. Edited February 26, 2012 by Guest Link to comment
Kenix Posted February 26, 2012 Share Posted February 26, 2012 You lol? I tested now it working .. Maybe you not have money? Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 Last request. Can you make it, than player can use this bind every 5 sec? Link to comment
Kenix Posted February 26, 2012 Share Posted February 26, 2012 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
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 You can add simple Outputmsg, where i can replace to my msg's (if not have 2500 and wait 5 secounds). Link to comment
Kenix Posted February 26, 2012 Share Posted February 26, 2012 You lol? I do not need for you to write all the code you have to write yourself. This impudence I just help. All functions: Client side https://wiki.multitheftauto.com/wiki/Cli ... _Functions Server side https://wiki.multitheftauto.com/wiki/Ser ... _Functions Find the right is not difficult. Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 Ye i know, but when i add my msg's, script have a errors. Link to comment
#DaMiAnO Posted February 26, 2012 Author Share Posted February 26, 2012 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 ) Link to comment
Castillo Posted February 26, 2012 Share Posted February 26, 2012 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
Kenix Posted February 26, 2012 Share Posted February 26, 2012 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
drk Posted February 27, 2012 Share Posted February 27, 2012 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 Link to comment
Kenix Posted February 27, 2012 Share Posted February 27, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now