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

Wysłany: 2019-03-15, 21:44


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? mam skrypt, na gie?d?, lecz chcia?bym by pokazywa?o " getVehicleUpgrades", tylko nie wiem jak to wklei? do skryptu pomo?e kto? ?
kod po stronie clienta, gdzie jest s? informacje o poje?dzie:

local marker=createMarker(-1908.58,-858.81,32.02-0.5, "cylinder", 6.5, 0, 0, 0, 155)
local cuboid=createColCuboid(-1909.1134033203, -972.04620361328, 31.2734375, 42, 227.75, 2)
createBlip(-1893.80,-860.08,32.02, 43,25,0,0,0,0,0,275)

local wstep=false
local podatek=0

local text=createElement("text")
setElementPosition(text,-1908.58,-858.81,32.02+1.3)
setElementData(text,"name","Gie?da\nUstawianie ceny.")



function getPlayerName2(plr)
if not plr then return end
return getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
end

local wm={}
wm.window=guiCreateWindow(0.74, 0.33, 0.25, 0.50, "Gielda", true)
guiWindowSetSizable(wm.window, false)
guiWindowSetMovable(wm.window, false)
guiSetVisible(wm.window, false)
wm.label=guiCreateLabel(0.06, 0.07, 0.89, 0.07, "Wpisz cen? kt?ra ma widnie? na poje?dzie.", true, wm.window)
guiLabelSetHorizontalAlign(wm.label, "center", false)
guiLabelSetVerticalAlign(wm.label, "center")
wm.label2=guiCreateLabel(0.06, 0.21, 0.89, 0.07, "Po odj?ciu podatku cena wyniesie: 0 $", true, wm.window)
guiLabelSetHorizontalAlign(wm.label2, "center", false)
guiLabelSetVerticalAlign(wm.label2, "center") 
wm.edit=guiCreateEdit(0.06, 0.40, 0.91, 0.10, "", true, wm.window)
wm.submit2=guiCreateButton(0.06, 0.55, 0.90, 0.16, "Zgadzam si?", true, wm.window)
wm.submit=guiCreateButton(0.06, 0.75, 0.90, 0.20, "Akceptuj", true, wm.window)

addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    local spawn=getElementData(veh,"vehicle:id")
    if not spawn then return end
    if getElementHealth(veh) < 980 then
        outputChatBox("* Posiadasz zbyt uszkodzony pojazd, id? go napraw.", 255, 0, 0)
        return
    end
    if getElementData(veh,"vehicle:ownedPlayer") ~= getElementData(localPlayer,"player:uid") then return end
    showCursor(true,false)
    guiSetVisible(wm.window, true)
    guiSetVisible(wm.label2, false)
    guiSetVisible(wm.submit2, false)
    guiSetInputMode("no_binds_when_editing")
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function(el,md)
    if el~=localPlayer then return end
    if not wstep then return end
    showCursor(false)
    guiSetVisible(wm.window, false)
end)

addEventHandler("onClientGUIClick", resourceRoot, function()
    if not wstep then return end
    local cena=tonumber(guiGetText(wm.edit))
    if not cena or cena < 1 or cena ~= math.floor(cena) or cena > 500000000 then
        outputChatBox("* Podano nieprawid?ow? cen?.")
        return
    end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    if not getElementData(veh,"vehicle:id") then return end
    if source == wm.submit then
        --podatek=math.floor(cena/2)
        guiSetVisible(wm.submit2, true)
        guiSetVisible(wm.label2, true)
        guiSetText(wm.label2, "Akceptujesz podan? cen?? "..cena.." $")
    end
    if source == wm.submit2 then
--    local desc=string.format("Pojazd: %s\nCena: %d PLN\nPrzebieg: %dkm\nSprzedaj?cy: %s\nStatus sprzedaj?cego: Dostepny", getVehicleName(veh), tonumber(cena), getElementData(veh,"vehicle:mileage"), getPlayerName2(localPlayer))
    setElementData(veh,"vehicle:desc",false)
    setElementData(veh,"vehicle:gielda",true)
    setElementData(veh,"vehicle:nazwa:G",getVehicleName(veh))
    setElementData(veh,"vehicle:owner:G",getPlayerName(localPlayer):gsub("#%x%x%x%x%x%x",""),true)
    setElementData(veh,"vehicle:owner:UID",getElementData(localPlayer,"player:uid"))
    setElementData(veh,"vehicle:cena:G",tonumber(cena))
    setElementData(veh,"vehicle:id:G",getElementData(veh, "vehicle:id"))
    guiSetVisible(wm.window, false)
    showCursor(false)
    end
end)

function znajdzprzezuid(uid)
    if not uid then return end
    for _,p in pairs(getElementsByType('player'),root,false) do
        if getElementData(p,"player:uid") and getElementData(p,"player:uid") == uid then return p end
    end
    return false
end
gielda = {}

function RGBToHex(red, green, blue, alpha)
    if ( (red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255) ) ) then
        return nil
    end
    if ( alpha ) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end


local function aktualizujdane()
if not isElementWithinColShape(localPlayer,cuboid) then return end
for i,v in ipairs(getElementsByType("vehicle",root,true)) do
    if getElementData(v, "vehicle:gielda",true) then
    if getElementData(v, "vehicle:id") == getElementData(v, "vehicle:id:G") then
    local online=znajdzprzezuid(getElementData(v,"vehicle:owner:UID"))
    if online then jest="#00FF00Online" else jest="#FF0000Offline" end
        --local Pojemnosc = getElementData(v,"Pojemnosc:silnika") or "Zwykla"
        zawieszenie = getElementData(v,"Zawieszenie:Pneumatyczne")
        if zawieszenie == 'Tak' then
        Zawie = "Zawieszenie pneumatyczne,"
    else
        Zawie = ""
    end
        lpg = getElementData(v,"Zamontowane:LPG")
        if lpg == 'Tak' then
        gaz = "LPG, "
    else
        gaz = ""
    end
        drzwi = getElementData(v,"vehicle:drzwidogury")
        if drzwi == 'Tak' then
        Drzwii = "Drzwi otwieraj?ce si? do g?ry,"
    else
        Drzwii = ""
    end
        licznik = getElementData(v,"licznik:kolor")
        if licznik == 'CiemnyNiebieski' then
        licznik1 = "Pod?wietlenie licznika Ciemno-Niebieskie,"
    else
        licznik1 = ""
    end
        if licznik == 'Zolty' then
        licznik2 = "Pod?wietlenie licznika ??lt?,"
    else
        licznik2 = ""
    end
        if licznik == 'Czerwony' then
        licznik3 = "Pod?wietlenie licznika Czerwone,"
    else
        licznik3 = ""
    end
        if licznik == 'Fioletowy' then
        licznik4 = "Pod?wietlenie licznika Fioletowe,"
    else
        licznik4 = ""
    end
     if licznik == 'Turkusowy' then
        licznik5 = "Pod?wietlenie licznika Turkusow?,"
    else
        licznik5 = ""
    end
     if licznik == 'Rozowy' then
        licznik6 = "Pod?wietlenie licznika Ro?ow?,"
    else
        licznik6 = ""
    end
     if licznik == 'CiemnyCzerwony' then
        licznik7 = "Pod?wietlenie licznika Ciemno-Czerwone,"
    else
        licznik7 = ""
    end
     if licznik == 'CiemnyZielony' then
        licznik8 = "Pod?wietlenie licznika Ciemno-Zielone,"
    else
        licznik8 = ""
    end
     if licznik == 'Zloty' then
        licznik9 = "Pod?wietlenie licznika Z?ote,"
    else
        licznik9 = ""
    end
     if licznik == 'Neonowe' then
        licznik10 = "Pod?wietlenie licznika Neonowe,"
    else
        licznik10 = ""
    end
     if licznik == 'JasnyNiebieski' then
        licznik11 = "Pod?wietlenie licznika Jasno-Niebieskie,"
    else
        licznik11 = ""
    end
     if licznik == 'Pomaranczowy' then
        licznik12 = "Pod?wietlenie licznika Pomara?czowe,"
    else
        licznik12 = ""
    end
     if licznik == 'Zielony' then
        licznik13 = "Pod?wietlenie licznika Zielone,"
    else
        licznik13 = ""
    end
        local Dodatki = string.format(""..Zawie..""..gaz..""..Drzwii..""..licznik1..""..licznik2..""..licznik3..""..licznik4..""..licznik5..""..licznik6..""..licznik7..""..licznik8..""..licznik9..""..licznik10..""..licznik11..""..licznik12..""..licznik13.."")
    local desc=string.format("Pojazd: %s\n\nCena: %d $\nPrzebieg: %dkm\nSprzedaj?cy: %s\nDodatki: "..Dodatki.."\n\nStatus: %s", getElementData(v, "vehicle:nazwa:G"),tonumber(getElementData(v, "vehicle:cena:G")), getElementData(v,"vehicle:mileage"), getElementData(v,"vehicle:owner:G"), jest)
    gielda[v] = desc
    end
    end
    end
end



if not vopisFont then vopisFont = "default-bold"; vopisrozmiar=1.0 end

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
    if
        type( sEventName ) == 'string' and
        isElement( pElementAttachedTo ) and
        type( func ) == 'function'
    then
        local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
        if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
            for i, v in ipairs( aAttachedFunctions ) do
                if v == func then
                    return true
                end
            end
        end
    end
    return false
end

timerke = nil
aktualizujdane()

function renderinge()
if not isElementWithinColShape(localPlayer,cuboid) then return end
    local rootx, rooty, rootz = getCameraMatrix()
    for i,vehicle in ipairs(getElementsByType("vehicle",root,true)) do
        local x,y,z=getElementPosition(vehicle)
        local sx,sy=getScreenFromWorldPosition(x,y,z)
        if sx and sy then
            local desc=gielda[vehicle]
            if desc then
                local distance=getDistanceBetweenPoints3D(rootx,rooty,rootz,x,y,z)
                if distance <= 25 then
                    if isLineOfSightClear( rootx,rooty,rootz, x,y,z, true, true, false, true, false, true, true,vehicle ) then
                        dxDrawText(desc:gsub("#%x%x%x%x%x%x",""), sx, sy, sx, sy, tocolor(0, 0, 0, 255), vopisrozmiar-0.01, vopisFont, "center", "center")
                        dxDrawText(desc, sx, sy, sx, sy, tocolor(255, 255, 255, 255), vopisrozmiar, vopisFont, "center", "center",false,false,false,true)
                    end
                end
            end
        end
    end
end
addEventHandler("onClientColShapeHit",cuboid,function(el,md)
if not md then return end
if el ~= localPlayer then return end
if isEventHandlerAdded("onClientRender",root,renderinge) then
removeEventHandler("onClientRender",root,renderinge)
end
addEventHandler("onClientRender",root, renderinge)
timerke = setTimer(aktualizujdane,3000,0)
end)


addEventHandler("onClientColShapeLeave",cuboid,function(el,md)
if not md then return end
if el ~= localPlayer then return end
if isEventHandlerAdded("onClientRender",root,renderinge) then
removeEventHandler("onClientRender",root,renderinge)
end
--if isTimer(timerke) then killTimer(timerke) end
end)
addEventHandler("onClientColShapeHit", cuboid, function(el,md)
    if not md or el ~= localPlayer then return end
    if wstep then return end
    wstep=true
end)

addEventHandler("onClientColShapeLeave", cuboid, function(el,md)
    if getElementData(el,"vehicle:gielda") then gielda[el] = false end
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(el)
    if veh then
    --setElementData(veh,"vehicle:desc",false)
    setElementData(veh, "vehicle:gielda",false)
    end
end)




Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-15, 22:36


Hades.

Łiiiiiiiiii






Wiek: 22
Na forum: 4840 dni
Posty: 372
Nick w MP: Hades

Piwa: 3218

Respekt: 337,8
Respekt: 337,8Respekt: 337,8Respekt: 337,8


local function aktualizujdane()
    if not isElementWithinColShape(localPlayer,cuboid) then return end
    for i,v in ipairs(getElementsByType("vehicle",root,true)) do
        if getElementData(v, "vehicle:gielda",true) then
        if getElementData(v, "vehicle:id") == getElementData(v, "vehicle:id:G") then
        local online=znajdzprzezuid(getElementData(v,"vehicle:owner:UID"))
        if online then jest="#00FF00Online" else jest="#FF0000Offline" end
            --local Pojemnosc = getElementData(v,"Pojemnosc:silnika") or "Zwykla"
            zawieszenie = getElementData(v,"Zawieszenie:Pneumatyczne")
            if zawieszenie == 'Tak' then
            Zawie = "Zawieszenie pneumatyczne,"
        else
            Zawie = ""
        end
            lpg = getElementData(v,"Zamontowane:LPG")
            if lpg == 'Tak' then
            gaz = "LPG, "
        else
            gaz = ""
        end
            drzwi = getElementData(v,"vehicle:drzwidogury")
            if drzwi == 'Tak' then
            Drzwii = "Drzwi otwieraj?ce si? do g?ry,"
        else
            Drzwii = ""
        end
            licznik = getElementData(v,"licznik:kolor")
            if licznik == 'CiemnyNiebieski' then
            licznik1 = "Pod?wietlenie licznika Ciemno-Niebieskie,"
        else
            licznik1 = ""
        end
            if licznik == 'Zolty' then
            licznik2 = "Pod?wietlenie licznika ??lt?,"
        else
            licznik2 = ""
        end
            if licznik == 'Czerwony' then
            licznik3 = "Pod?wietlenie licznika Czerwone,"
        else
            licznik3 = ""
        end
            if licznik == 'Fioletowy' then
            licznik4 = "Pod?wietlenie licznika Fioletowe,"
        else
            licznik4 = ""
        end
         if licznik == 'Turkusowy' then
            licznik5 = "Pod?wietlenie licznika Turkusow?,"
        else
            licznik5 = ""
        end
         if licznik == 'Rozowy' then
            licznik6 = "Pod?wietlenie licznika Ro?ow?,"
        else
            licznik6 = ""
        end
         if licznik == 'CiemnyCzerwony' then
            licznik7 = "Pod?wietlenie licznika Ciemno-Czerwone,"
        else
            licznik7 = ""
        end
         if licznik == 'CiemnyZielony' then
            licznik8 = "Pod?wietlenie licznika Ciemno-Zielone,"
        else
            licznik8 = ""
        end
         if licznik == 'Zloty' then
            licznik9 = "Pod?wietlenie licznika Z?ote,"
        else
            licznik9 = ""
        end
         if licznik == 'Neonowe' then
            licznik10 = "Pod?wietlenie licznika Neonowe,"
        else
            licznik10 = ""
        end
         if licznik == 'JasnyNiebieski' then
            licznik11 = "Pod?wietlenie licznika Jasno-Niebieskie,"
        else
            licznik11 = ""
        end
         if licznik == 'Pomaranczowy' then
            licznik12 = "Pod?wietlenie licznika Pomara?czowe,"
        else
            licznik12 = ""
        end
         if licznik == 'Zielony' then
            licznik13 = "Pod?wietlenie licznika Zielone,"
        else
            licznik13 = ""
        end
        local tune = getVehicleUpgrades(v)
        tune = table.concat(tune, ",")
        if #tune == 0 then return "brak" end
        local Dodatki = string.format(""..Zawie..""..gaz..""..Drzwii..""..licznik1..""..licznik2..""..licznik3..""..licznik4..""..licznik5..""..licznik6..""..licznik7..""..licznik8..""..licznik9..""..licznik10..""..licznik11..""..licznik12..""..licznik13.." Tuning: "..tune.."")
        local desc=string.format("Pojazd: %s\n\nCena: %d $\nPrzebieg: %dkm\nSprzedaj?cy: %s\nDodatki: "..Dodatki.."\n\nStatus: %s", getElementData(v, "vehicle:nazwa:G"),tonumber(getElementData(v, "vehicle:cena:G")), getElementData(v,"vehicle:mileage"), getElementData(v,"vehicle:owner:G"), jest)
        gielda[v] = desc
        end
        end
        end
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-16, 08:36


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Okey, a da si? zamiast ID tune, napisa? nazw? tune a nie ID?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-16, 21:36


Ciastuuś

As-salamu alaykum






Wiek: 27
Na forum: 3212 dni
Posty: 800
Nick w MP: Ciastuuś

Piwa: 4304

Respekt: 640
Respekt: 640Respekt: 640

"Pyrek24" napisał/a:

Okey, a da si? zamiast ID tune, napisa? nazw? tune a nie ID?



Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleUpgradeSlotName


Podpis
As-salamu alaykum
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-17, 12:41


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Ciastu? umia?by? mi to do kodu wporwadzi?, i? jak podmieni?em to getVehicleUpgrades na to getVehicleUpgradeSlotName to mam taki b??d

db3
https://imgur.com/YCBjik1

Postaw piwo autorowi tego posta
 

 
Tagi: giełda
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