Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2015-11-15, 16:15


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Witam. Uda?o mi si? z niewielk? pomoc? zrobi? te kontrolki ale mam jeszcze 2 problemy. Ot?? po wej?ciu do auta FPS spadaj? mi do 10 (po wyj?ciu te?). Dopiero po restarcie skryptu jest OK. Drugi jest taki ?e np. pokazuje si? je?li mam wy??czony silnik, ale jak w??cze to ona nie znika. Mo?e to kto? poprawi? bo ja ju? nie wiem o co chodzi ;(

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender",root,function()
    if getPedOccupiedVehicle(localPlayer) then
        if getVehicleController(getPedOccupiedVehicle(localPlayer))==localPlayer then
            local paliwo=getElementData(getPedOccupiedVehicle(localPlayer),"pojazd_paliwo") or "Brak"
            local przebieg=getElementData(getPedOccupiedVehicle(localPlayer),"pojazd_przebieg") or "Brak"
            local id=getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Brak"
            speedx, speedy, speedz = getElementVelocity (getPedOccupiedVehicle(localPlayer))
            actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) 
            kmh = actualspeed * 180
                        dxDrawRectangle(screenW * 0.7625, screenH * 0.6433, screenW * 0.2138, screenH * 0.3300, tocolor(0, 0, 0, 207), false)
                        dxDrawText(getVehicleName(getPedOccupiedVehicle(localPlayer)), screenW * 0.7688, screenH * 0.6433, screenW * 0.8588, screenH * 0.6683, tocolor(195, 207, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Publiczny", screenW * 0.9213, screenH * 0.6450, screenW * 0.9812, screenH * 0.6683, tocolor(195, 207, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Pr?dko??:", screenW * 0.7800, screenH * 0.6783, screenW * 0.8462, screenH * 0.7017, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Przebieg:", screenW * 0.7800, screenH * 0.7100, screenW * 0.8488, screenH * 0.7317, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Paliwo:", screenW * 0.7800, screenH * 0.7417, screenW * 0.8512, screenH * 0.7650, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(paliwo).."L", screenW * 0.8413, screenH * 0.7417, screenW * 0.8700, screenH * 0.7683, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(przebieg).." km", screenW * 0.8562, screenH * 0.7100, screenW * 0.8875, screenH * 0.7317, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(kmh).."km/h", screenW * 0.8588, screenH * 0.6783, screenW * 0.8875, screenH * 0.7000, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("W?a?ciciel:", screenW * 0.7800, screenH * 0.7750, screenW * 0.8462, screenH * 0.7983, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(getElementData (getPedOccupiedVehicle (localPlayer), "car_owner") or "Publiczny", screenW * 0.8588, screenH * 0.7733, screenW * 0.9075, screenH * 0.7983, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        end
    end
end)

function srututututu()
if not isPedInVehicle(localPlayer) then return end
pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end

         if getElementHealth(pojazd) <= 600 then
            obraz_silnik = guiCreateStaticImage(0.90, 0.86, 0.05, 0.04, "silnik.png", true)    
         else
         end
         if getVehicleLightState(pojazd, 0 and 1 and 2 and 3) == 0 then
            obraz_swiatla = guiCreateStaticImage(0.77, 0.92, 0.05, 0.04, "swiatla.png", true)
         else 
         end
         if getVehicleDoorOpenRatio(pojazd, 0) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 1) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 2) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 3) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 4) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 5) >= 0.1 then
            obraz_drzwi = guiCreateStaticImage(0.84, 0.92, 0.04, 0.04, "drzwi.png", true)
         else 
         end
         if getVehicleEngineState(pojazd) == false then
            obraz_akumulator = guiCreateStaticImage(0.91, 0.92, 0.05, 0.04, "akumulator.png", true)
         else 
         end
         if getElementData(pojazd, "pojazd_paliwo") <= 15 then
            obraz_paliwo = guiCreateStaticImage(0.77, 0.86, 0.05, 0.04, "paliwo.png", true)
         else 
         end
         if isElementFrozen (pojazd) == true then
            obraz_reczny = guiCreateStaticImage(0.84, 0.86, 0.04, 0.04, "reczny.png", true)
         else 
         end
end
addEventHandler("onClientRender", getRootElement (), srututututu)


Podpis



GTAO Member: 2015-08-23, 14:26

Ostatnio zmieniony przez jg2aviva1 2015-11-15, 18:07, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-11-15, 17:59


KukiX







Wiek: 34
Na forum: 6859 dni
Posty: 567

Piwa: 17560

Respekt: 160
Respekt: 160Respekt: 160

Bo event onClientRender wykorzystuje si? praktycznie tylko do funkcji dx np. dxDrawText do wy?wietlania napis?w.
Funkcje, kt?re umieszczasz w evencie onClientRender wykonuj? si? oko?o 30-60 razy na sekund?.
Po zobaczeniu tego co tu poda?e? to si? nie dziwie ?e s? spadki FPS?w.
Musisz zapozna? si? ze wszystkimi eventami jakie s? w MTA i jak najrzadziej korzysta? z takich rozwi?za?, a najlepiej w og?le.
W tym przypadku skorzystaj z event?w onClientVehicleEnter i onClientVehicleExit.
https://wiki.multitheftauto.com/wiki/OnClientVehicleEnter
https://wiki.multitheftauto.com/wiki/OnClientVehicleExit

Podpis
Moje skrypty MTA:
¤PlayDM
¤Mini-Games v0.2
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-11-15, 18:05


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Dobra, DestroY mi podpowiedzia? ?eybym zmieni? na dxDrawImage ale teraz to w og?le nic nie ma:

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender",root,function()
    if getPedOccupiedVehicle(localPlayer) then
        if getVehicleController(getPedOccupiedVehicle(localPlayer))==localPlayer then
            local paliwo=getElementData(getPedOccupiedVehicle(localPlayer),"pojazd_paliwo") or "Brak"
            local przebieg=getElementData(getPedOccupiedVehicle(localPlayer),"pojazd_przebieg") or "Brak"
            local id=getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Brak"
            speedx, speedy, speedz = getElementVelocity (getPedOccupiedVehicle(localPlayer))
            actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) 
            kmh = actualspeed * 180
                        dxDrawRectangle(screenW * 0.7625, screenH * 0.6433, screenW * 0.2138, screenH * 0.3300, tocolor(0, 0, 0, 207), false)
                        dxDrawText(getVehicleName(getPedOccupiedVehicle(localPlayer)), screenW * 0.7688, screenH * 0.6433, screenW * 0.8588, screenH * 0.6683, tocolor(195, 207, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Publiczny", screenW * 0.9213, screenH * 0.6450, screenW * 0.9812, screenH * 0.6683, tocolor(195, 207, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Pr?dko??:", screenW * 0.7800, screenH * 0.6783, screenW * 0.8462, screenH * 0.7017, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Przebieg:", screenW * 0.7800, screenH * 0.7100, screenW * 0.8488, screenH * 0.7317, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("Paliwo:", screenW * 0.7800, screenH * 0.7417, screenW * 0.8512, screenH * 0.7650, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(paliwo).."L", screenW * 0.8413, screenH * 0.7417, screenW * 0.8700, screenH * 0.7683, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(przebieg).." km", screenW * 0.8562, screenH * 0.7100, screenW * 0.8875, screenH * 0.7317, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(math.floor(kmh).."km/h", screenW * 0.8588, screenH * 0.6783, screenW * 0.8875, screenH * 0.7000, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText("W?a?ciciel:", screenW * 0.7800, screenH * 0.7750, screenW * 0.8462, screenH * 0.7983, tocolor(5, 208, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
                        dxDrawText(getElementData (getPedOccupiedVehicle (localPlayer), "car_owner") or "Publiczny", screenW * 0.8588, screenH * 0.7733, screenW * 0.9075, screenH * 0.7983, tocolor(208, 0, 0, 207), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        end
    end
end)

function srututututu()
if not isPedInVehicle(localPlayer) then return end
pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end

         if getElementHealth(pojazd) <= 600 then
            obraz_silnik = guiCreateStaticImage(0.90, 0.86, 0.05, 0.04, "silnik1.png", true)    
         else
         end
         if getVehicleLightState(pojazd, 0 and 1 and 2 and 3) == 0 then
            obraz_swiatla = guiCreateStaticImage(0.77, 0.92, 0.05, 0.04, "swiatla1.png", true)
         else 
         end
         if getVehicleDoorOpenRatio(pojazd, 0) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 1) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 2) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 3) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 4) >= 0.1 or getVehicleDoorOpenRatio(pojazd, 5) >= 0.1 then
            obraz_drzwi = guiCreateStaticImage(0.84, 0.92, 0.04, 0.04, "drzwi1.png", true)
         else 
         end
         if getVehicleEngineState(pojazd) == false then
            obraz_akumulator = guiCreateStaticImage(0.91, 0.92, 0.05, 0.04, "akumulator1.png", true)
         else 
         end
         if getElementData(pojazd, "pojazd_paliwo") <= 15 then
            obraz_paliwo = guiCreateStaticImage(0.77, 0.86, 0.05, 0.04, "paliwo1.png", true)
         else 
         end
         if isElementFrozen (pojazd) == true then
            obraz_reczny = guiCreateStaticImage(0.84, 0.86, 0.04, 0.04, "reczny1.png", true)
         else 
         end
end
addEventHandler("onClientRender", getRootElement (), srututututu)


Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Tagi: dxdrawimage
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » dxDrawImage Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku