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

Wysłany: 2019-02-26, 21:20


adaskOO

Ten który patrzy






Wiek: 24
Na forum: 3732 dni
Posty: 249
Nick w MP: adaskOO

Piwa: 3168

Respekt: 280
Respekt: 280Respekt: 280Respekt: 280

Teraz zmagam si? z innym problemem.. U?ywam funkcji

Więcej informacji znajdziesz w Wikipedii MTA:

getElementSpeed

aby pobiera?o mi pr?dko?? elementu i problem polega na tym ?e jak wchodz? do pojazdu to wszystko gra ale jak wysiadam to wyskakuje error. Gdy zn?w wsi?d? wszystko gra gui licznik ale gdy zn?w wysi?d? error razi w oczy..
Kod:

ERROR: licznikLCD\cp_c.lua:8: Bad argument 1 @ getElementSpeed (element expected, got boolean)


client
linijka zaznaczona ponizej

-- https://wiki.multitheftauto.com/wiki/GetElementSpeed 
function getElementSpeed(theElementunit)
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") -- lTo jest ta linijka z errorem
    local elementType getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile""Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == or tonumber(unit) == or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end


Podpis

Zapraszam do współpracy :)
Discord: adaskOO#8255
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-26, 21:54


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

Element zwraca Ci false, nad getElementSpeed dodaj sprawdzanie czy ten element istnieje.

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-26, 21:54


Loop

Inspektor






Wiek: 27
Na forum: 4289 dni
Posty: 311
Nick w MP: Inspektor

Piwa: 201

Respekt: 130
Respekt: 130

Pokaz kod kt?ry si? wykonuje po wsiadaniu

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-27, 14:30


adaskOO

Ten który patrzy






Wiek: 24
Na forum: 3732 dni
Posty: 249
Nick w MP: adaskOO

Piwa: 3168

Respekt: 280
Respekt: 280Respekt: 280Respekt: 280

Loop,

function renderSpeedoMeter()
    ---- predkosc--
    local vehicle getPedOccupiedVehicle(getLocalPlayer())
    local speedkmh getElementSpeed(vehicle1)
    local roundedSpeedkmh math.floor(speedkmh) == speedkmh and speedkmh or string.format(speedkmh"%.1f")
    local speed "" .. roundedSpeedkmh .. ""
    local speedFormat math.floor(speed)

dxDrawText(""..speedFormat..""1071*w823*h1228*w860*htocolor(23658255), 1.00dxfont0_open"center""center"falsefalsefalsefalsefalse)
end

addEvent("SpeedON"true)
addEventHandler("SpeedON"root, function()
      addEventHandler("onClientRender"rootrenderSpeedoMeter)
end)

addEvent("SpeedOFF"true)
addEventHandler("SpeedOFF"root, function()
      removeEventHandler("onClientRender"rootrenderSpeedoMeter)
end)


Podpis

Zapraszam do współpracy :)
Discord: adaskOO#8255
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-27, 15:05


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3


local vehicle getPedOccupiedVehicle(getLocalPlayer())
if not isElement(vehiclethen 
    return 
end
local speedkmh getElementSpeed(vehicle1)


Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
adaskOO
Wysłany: 2019-02-27, 16:26


adaskOO

Ten który patrzy






Wiek: 24
Na forum: 3732 dni
Posty: 249
Nick w MP: adaskOO

Piwa: 3168

Respekt: 280
Respekt: 280Respekt: 280Respekt: 280

"Avenged" napisał/a:


local vehicle getPedOccupiedVehicle(getLocalPlayer())
if not isElement(vehiclethen 
    return 
end
local speedkmh getElementSpeed(vehicle1)


Dzi?kuje, dzia?a

Podpis

Zapraszam do współpracy :)
Discord: adaskOO#8255
Postaw piwo autorowi tego posta
 

 
Tagi: getelementspeed :: zły :: argument
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