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: 4134 dni
Posty: 445
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1033

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 screenWscreenH guiGetScreenSize()

addEventHandler("onClientRender",root,function()
    if getPedOccupiedVehicle(localPlayerthen
        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"
            speedxspeedyspeedz getElementVelocity (getPedOccupiedVehicle(localPlayer))
            actualspeed = (speedx^speedy^speedz^2)^(0.5) 
            kmh actualspeed 180
                        dxDrawRectangle(screenW 0.7625screenH 0.6433screenW 0.2138screenH 0.3300tocolor(000207), false)
                        dxDrawText(getVehicleName(getPedOccupiedVehicle(localPlayer)), screenW 0.7688screenH 0.6433screenW 0.8588screenH 0.6683tocolor(1952070207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Publiczny"screenW 0.9213screenH 0.6450screenW 0.9812screenH 0.6683tocolor(1952070207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Pr?dko??:"screenW 0.7800screenH 0.6783screenW 0.8462screenH 0.7017tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Przebieg:"screenW 0.7800screenH 0.7100screenW 0.8488screenH 0.7317tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Paliwo:"screenW 0.7800screenH 0.7417screenW 0.8512screenH 0.7650tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(paliwo).."L"screenW 0.8413screenH 0.7417screenW 0.8700screenH 0.7683tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(przebieg).." km"screenW 0.8562screenH 0.7100screenW 0.8875screenH 0.7317tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(kmh).."km/h"screenW 0.8588screenH 0.6783screenW 0.8875screenH 0.7000tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("W?a?ciciel:"screenW 0.7800screenH 0.7750screenW 0.8462screenH 0.7983tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(getElementData (getPedOccupiedVehicle (localPlayer), "car_owner") or "Publiczny"screenW 0.8588screenH 0.7733screenW 0.9075screenH 0.7983tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
        end
    end
end)

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

         if getElementHealth(pojazd) <= 600 then
            obraz_silnik guiCreateStaticImage(0.900.860.050.04"silnik.png"true)    
         else
         end
         if getVehicleLightState(pojazdand and and 3) == 0 then
            obraz_swiatla guiCreateStaticImage(0.770.920.050.04"swiatla.png"true)
         else 
         end
         if getVehicleDoorOpenRatio(pojazd0) >= 0.1 or getVehicleDoorOpenRatio(pojazd1) >= 0.1 or getVehicleDoorOpenRatio(pojazd2) >= 0.1 or getVehicleDoorOpenRatio(pojazd3) >= 0.1 or getVehicleDoorOpenRatio(pojazd4) >= 0.1 or getVehicleDoorOpenRatio(pojazd5) >= 0.1 then
            obraz_drzwi guiCreateStaticImage(0.840.920.040.04"drzwi.png"true)
         else 
         end
         if getVehicleEngineState(pojazd) == false then
            obraz_akumulator guiCreateStaticImage(0.910.920.050.04"akumulator.png"true)
         else 
         end
         if getElementData(pojazd"pojazd_paliwo") <= 15 then
            obraz_paliwo guiCreateStaticImage(0.770.860.050.04"paliwo.png"true)
         else 
         end
         if isElementFrozen (pojazd) == true then
            obraz_reczny guiCreateStaticImage(0.840.860.040.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: 6718 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: 4134 dni
Posty: 445
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1033

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 screenWscreenH guiGetScreenSize()

addEventHandler("onClientRender",root,function()
    if getPedOccupiedVehicle(localPlayerthen
        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"
            speedxspeedyspeedz getElementVelocity (getPedOccupiedVehicle(localPlayer))
            actualspeed = (speedx^speedy^speedz^2)^(0.5) 
            kmh actualspeed 180
                        dxDrawRectangle(screenW 0.7625screenH 0.6433screenW 0.2138screenH 0.3300tocolor(000207), false)
                        dxDrawText(getVehicleName(getPedOccupiedVehicle(localPlayer)), screenW 0.7688screenH 0.6433screenW 0.8588screenH 0.6683tocolor(1952070207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(getElementData(getPedOccupiedVehicle(localPlayer),"car_id") or "Publiczny"screenW 0.9213screenH 0.6450screenW 0.9812screenH 0.6683tocolor(1952070207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Pr?dko??:"screenW 0.7800screenH 0.6783screenW 0.8462screenH 0.7017tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Przebieg:"screenW 0.7800screenH 0.7100screenW 0.8488screenH 0.7317tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("Paliwo:"screenW 0.7800screenH 0.7417screenW 0.8512screenH 0.7650tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(paliwo).."L"screenW 0.8413screenH 0.7417screenW 0.8700screenH 0.7683tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(przebieg).." km"screenW 0.8562screenH 0.7100screenW 0.8875screenH 0.7317tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(math.floor(kmh).."km/h"screenW 0.8588screenH 0.6783screenW 0.8875screenH 0.7000tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText("W?a?ciciel:"screenW 0.7800screenH 0.7750screenW 0.8462screenH 0.7983tocolor(52080207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
                        dxDrawText(getElementData (getPedOccupiedVehicle (localPlayer), "car_owner") or "Publiczny"screenW 0.8588screenH 0.7733screenW 0.9075screenH 0.7983tocolor(20800207), 1.00"default-bold""left""top"falsefalsefalsefalsefalse)
        end
    end
end)

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

         if getElementHealth(pojazd) <= 600 then
            obraz_silnik guiCreateStaticImage(0.900.860.050.04"silnik1.png"true)    
         else
         end
         if getVehicleLightState(pojazdand and and 3) == 0 then
            obraz_swiatla guiCreateStaticImage(0.770.920.050.04"swiatla1.png"true)
         else 
         end
         if getVehicleDoorOpenRatio(pojazd0) >= 0.1 or getVehicleDoorOpenRatio(pojazd1) >= 0.1 or getVehicleDoorOpenRatio(pojazd2) >= 0.1 or getVehicleDoorOpenRatio(pojazd3) >= 0.1 or getVehicleDoorOpenRatio(pojazd4) >= 0.1 or getVehicleDoorOpenRatio(pojazd5) >= 0.1 then
            obraz_drzwi guiCreateStaticImage(0.840.920.040.04"drzwi1.png"true)
         else 
         end
         if getVehicleEngineState(pojazd) == false then
            obraz_akumulator guiCreateStaticImage(0.910.920.050.04"akumulator1.png"true)
         else 
         end
         if getElementData(pojazd"pojazd_paliwo") <= 15 then
            obraz_paliwo guiCreateStaticImage(0.770.860.050.04"paliwo1.png"true)
         else 
         end
         if isElementFrozen (pojazd) == true then
            obraz_reczny guiCreateStaticImage(0.840.860.040.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 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