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

Wysłany: 2019-07-07, 02:15


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3200 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Siema
Przychodz? do was z pytaniem jak zrobi? aby po przekroczeniu pr?dko?ci w aucie np. 70km/h wykonywa?o dan? funkcj? jak? chce zrobi??
Ma kto? jaki? pomys??

Za pomoc daje ka?demu :piwo: oraz R*

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-07, 16:19


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Przyk?ad kodu z mojego serwera :


speedx, speedy, speedz = getElementVelocity ( getPedOccupiedVehicle(hit) )
                    actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
                    kmh = actualspeed * 180
                    if tonumber(math.floor(kmh))>tonumber(getElementData(source,"predkosc")) then

--tu dana akcja


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-08, 06:48


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3200 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

A jak to przerobi? aby dzia?a?o u mnie?
Nwm czy potrzebne ale mo?e si? przyda?, kod licznika z mojego serwera:

sx, sy = guiGetScreenSize(  )
me = localPlayer

addEventHandler( "onClientRender", root, function()
    veh = getPedOccupiedVehicle( me )
    if not veh then return end
    speed = getElementSpeed( veh, "km/h" )
    fuel = getElementData( veh, "vehicle:fuel" ) if not fuel then setElementData( veh, "vehicle:fuel", 100 ) fuel = 100 end
    mileage = getElementData( veh, "vehicle:mileage" ) if not mileage then setElementData( veh, "vehicle:mileage", 100 ) mileage = 100 end
    dxDrawImage( sx - 350, sy - 105, 350, 105, "licznik.png" )
    x, y = sx - 268, sy - 8
    dxDrawText( math.floor(speed) .. "km", x, y - 16, x, y - 16, tocolor( 255, 110, 1, 255 ), 1.5, "default-bold", "center", "center" )
    x, y = sx - 156, sy - 8
    dxDrawText( round(fuel, 1) .. "l", x, y - 16, x, y - 16, tocolor( 255, 110, 1, 255 ), 1.5, "default-bold", "center", "center" )
    x, y = sx - 53, sy - 8
    dxDrawText( round(mileage, 1) .. "km", x, y - 16, x, y - 16, tocolor( 255, 110, 1, 255 ), 1.5, "default-bold", "center", "center" )
end )

function getElementSpeed(theElement, unit)
    local elementType = getElementType(theElement)
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end 


Nie chce tego dawa? do tego kodu ale chce ?eby to dzia?a?o bo teraz nie dzia?a

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-08, 07:04


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Yy normalnie?
if?tonumber(math.floor(speed)) > 70 then
--kod


Postaw piwo autorowi tego posta
 

 
Tagi: prędkość
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