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

Wysłany: 2019-01-11, 11:34


DylemaT929

Nikt






Wiek: 28
Na forum: 4182 dni
Posty: 340
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

Postanowi?em ulepszy? troch? salon i chcia?em go zrobi? w gui. Wszystko jest okej dop?ki nie podejd? do informacji pojazd?w. Kiedy nadaj? to informacje do gui niestety mam b??dy.


client gui

addEventHandler("onClientColShapeHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if isPedInVehicle(hit) then return end
    local veh = getElementData(source, "komis:slot")
    if not veh then return end
    local desc = getElementData(veh, "vehicle:desc")
    if not desc then return end
    addEventHandler("onClientRender", root, salony)
    informacje_pojazdy = desc
    showCursor(true)
end)



serwer

function createKomisVehicle(slot)
    if #getElementsWithinColShape(komis_shapes[slot]) > 0 then setTimer(createKomisVehicle, 250, 1, slot) return end

    vehicles[slot] = {}

    vehicles[slot].mileage = math.random(slots[slot].dmin, slots[slot].dmax)
    vehicles[slot].price = slots[slot].price

    vehicles[slot].veh = createVehicle(slots[slot].model, slots[slot][1], slots[slot][2], slots[slot][3], 0, 0, slots[slot][4])
    setElementFrozen(vehicles[slot].veh, true)
    setVehicleDamageProof(vehicles[slot].veh, true)
    setVehicleLocked(vehicles[slot].veh, true)

    setElementData(komis_shapes[slot], "komis:veh", vehicles[slot].veh)
    setElementData(komis_shapes[slot], "komis:slot", slot)
    setElementData(vehicles[slot].veh, "komis:veh", true)
    setElementData(vehicles[slot].veh, "salonowe", true)
    setVehicleOverrideLights ( vehicles[slot].veh, 2 )
    setVehicleColor(vehicles[slot].veh, 0,122,255)
    setVehicleHeadLightColor(vehicles[slot].veh, 255, 255, 255)

    if slots[slot].gdzie == "cygan" then
    vehicles[slot].poj = math.random(1,2)
    vehicles[slot].gdzie = "cygan"
    elseif slots[slot].gdzie == "zwykly" then
    vehicles[slot].poj = math.random(2,3)
    vehicles[slot].gdzie = "zwykly"
    elseif slots[slot].gdzie == "sportowy" then
    vehicles[slot].poj = math.random(3,4)
    vehicles[slot].gdzie = "sportowy"
    end

        if vehicles[slot].poj == 1 then
    vehicles[slot].poj2 = 1.2
    elseif vehicles[slot].poj == 2 then
    vehicles[slot].poj2 = 1.6
    elseif vehicles[slot].poj == 3 then
    vehicles[slot].poj2 = 1.8
    elseif vehicles[slot].poj == 4 then
    vehicles[slot].poj2 = 2.0
    elseif vehicles[slot].poj == 5 then
    vehicles[slot].poj2 = 2.2
    elseif vehicles[slot].poj == 6 then
    vehicles[slot].poj2 = 2.5
    elseif vehicles[slot].poj == 7 then
    vehicles[slot].poj2 = 2.6
    elseif vehicles[slot].poj == 8 then
    vehicles[slot].poj2 = 2.7
    elseif vehicles[slot].poj == 9 then
    vehicles[slot].poj2 = 2.8
    elseif vehicles[slot].poj == 10 then
    vehicles[slot].poj2 = 2.9
    elseif vehicles[slot].poj == 11 then
    vehicles[slot].poj2 = 3.0
    elseif vehicles[slot].poj == 12 then
    vehicles[slot].poj2 = 3.1
    local desc = "Pojazd: "..getVehicleName(vehicles[slot].veh).."\nPrzebieg: "..vehicles[slot].mileage.." km\nCena: "..slots[slot].price.." PLN\nPojemno??: "..vehicles[slot].poj2.." dm³\nRodzaj paliwa: Benzyna\n Pojemno?? Baku: 50 L\nJe?eli chcesz zakupi? pojazd kliknij przycisk zakup"
    setElementData(veh, "vehicle:desc", desc)
    --setElementData(vehicles[slot].veh, "vehicle:desc", "---------\nPojazd: "..getVehicleName(vehicles[slot].veh).."\nKoszt: "..slots[slot].price.." PLN\nPrzebieg: "..vehicles[slot].mileage.." km\nPojemno?? Silnika: "..vehicles[slot].poj2.." cm3\nRodzaj paliwa: "..vehicles[slot].rodzaj.."\nPojemno?? Baku: 100 L\nZainteresowa? ci? ten pojazd? /kuppojazd\n---------")
end





Tutaj jest problem

local desc = getElementData(veh, "vehicle:desc")
    if not desc then return end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 12:18


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Problem jest tutaj:
setElementData(komis_shapes[slot], "komis:slot", slot)

Zapisujesz liczb? (tak wyczyta?em z kodu) a p??niej odczytujesz z tej liczby elementDat? (ju? po stronie klienta).

Zr?b co? takiego:
setElementData(komis_shapes[slot], "komis:slot", vehicles[slot].veh)

lub zapisuj opis pojazdu bezpo?rednio w elementDacie colShape.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 13:48


DylemaT929

Nikt






Wiek: 28
Na forum: 4182 dni
Posty: 340
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

"Wilq" napisał/a:

Problem jest tutaj:
setElementData(komis_shapes[slot], "komis:slot", slot)

Zapisujesz liczb? (tak wyczyta?em z kodu) a p??niej odczytujesz z tej liczby elementDat? (ju? po stronie klienta).

Zr?b co? takiego:
setElementData(komis_shapes[slot], "komis:slot", vehicles[slot].veh)

lub zapisuj opis pojazdu bezpo?rednio w elementDacie colShape.


Zrobi?em tak. Teraz jest problem taki ?e nic si? nie pokazuje. Teraz wcale gui si? nie pokazuje


client

local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end

local informacje_pojazdy = ""

function salony()
    dxDrawRectangle(screenW * 0.3602, screenH * 0.3236, screenW * 0.2766, screenH * 0.5514, tocolor(0, 0, 0, 137), false)
    --dxDrawText(informacje_pojazdy, screenW * 0.3797, screenH * 0.3583, screenW * 0.6148, screenH * 0.8111, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
    if btn == "left" and state == "down" then
        if isMouseIn(screenW * 0.51, screenH * 0.68, screenW * 0.102, screenH * 0.044) and info ~= "" then
              showCursor(false)
              removeEventHandler("onClientRender", root, salony)
              informacje_pojazdy = ""
          elseif isMouseIn(screenW * 0.39, screenH * 0.68, screenW * 0.102, screenH * 0.044) and info ~= "" then
              triggerServerEvent("kup:pojazd", localPlayer)
              showCursor(false)
              removeEventHandler("onClientRender", root, salony)
              informacje_pojazdy = ""
          end
      end
end)

addEventHandler("onClientColShapeHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if isPedInVehicle(hit) then return end
    local veh = getElementData(source, "komis:veh")
    if not veh then return end
    local desc = getElementData(veh, "vehicle:desc")
    if not desc then return end
    addEventHandler("onClientRender", root, salony)
    informacje_pojazdy = desc
    showCursor(true)
end)


serwer


--[[
    Komisy samochodowe
    @author value <value2k@gmail.com>
    @Edit: DylemaT929 :)
    Nie masz prawa u?y? tego kodu bez mojej zgody
]]
createBlip(-930.47, -537.42, 26.05, 55,2,0,0,0,0,0,275) --- cygan
createBlip(-1663.96, 1212.86, 21.16, 55,2,0,0,0,0,0,275) --- pojazdy sportowe
createBlip(-1950.92, 279.76, 47.70, 55,2,0,0,0,0,0,275) --- pojazdy zwykle

local vehicles = {}
local komis_shapes = {}
local slots = {
   
    -- Salon LV Motory
    {-1953.35, 306.55, 40.64, 537.4, 0.0, 179.6, model=521, dmax=0, dmin=0, price=math.random(25000,26000), gdzie="motory"}, -- FCR 900
    {-1956.45, 306.28, 40.64, 537.4, 0.0, 179.8, model=581, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- BF
    {-1952.58, 300.26, 40.59, 89.1, 0.0, 91.0, model=463, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- Freeway
    {-1952.72, 295.79, 40.59, 89.1, 0.0, 88.4, model=471, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- QuadBike
    {-1952.91, 291.28, 40.59, 89.1, 0.0, 91.0, model=461, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- PCJ


    -- Cygan 
    {-957.26, -517.70, 25.61, 310.5, 0.0, 330.10, model=410, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Manana
    {-936.33, -510.96, 25.84, 300.0, 360.0, 325.3, model=458, dmax=99343, dmin=97323, price=math.random(17500,18000), gdzie="cygan"}, -- Solair
    {-931.80, -496.03, 25.95, 215.2, 360.0, 194.0, model=478, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Walton
    {-931.05, -538.50, 26.05, 0.1, 0.0, 3.8, model=418, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Moonbeam
    {-918.00, -533.21, 25.77, 382.0, 360.0, 26.9, model=543, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Sadler
    {-945.68, -531.82, 25.86, 310.5, 0.0, 329.9, model=540, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Vincent

    -- Salon LV Sportowy
    {-1662.96, 1221.65, 13.26, 230, 0, 0, model=429, dmax=0, dmin=0, price=math.random(65000,66000), gdzie="sportowy"}, -- Banshee
    {-1649.00, 1207.89, 13.34,65, 0.0, 0.0, model=560, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Sultan
    {-1649.99, 1207.60, 20.78,65, 0.0, 0.0, model=541, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Bullet
    {-1663.46, 1221.50, 20.86,230, 0.0, 0.0, model=451, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Turismo
    {-1665.56, 1206.14, 20.98, 310.8, 360.0, 306.6, model=480, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Comet
    {-1673.03, 1206.35, 13.38, 310.8, 360.0, 300.6, model=506, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Super GT

    -- Salon LV zwykly
    {-1946.15, 257.67, 40.83, 56.0, 0.0, 43.5, model=492, dmax=0, dmin=0, price=math.random(65000,66000), gdzie="zwykly"}, -- Greenwood
    {-1954.08, 257.70, 40.93, 360.0, 360.0, 359.9, model=421, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Washington
    {-1946.13, 273.40, 40.82, 89.1, 0.0, 88.9, model=526, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Fortune
    {-1945.99, 265.42, 40.82, 89.1, 359.8, 91.5, model=426, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Premier
    {-1959.99, 304.17, 35.35, 537.4, 359.8, 180.5, model=405, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sentinel
    {-1955.37, 304.21, 35.35, 537.4, 0.0, 179.4, model=445, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Admiral
    {-1945.77, 273.34, 35.29, 89.1, 360.0, 89.7, model=550, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sunrise
    {-1946.16, 268.81, 35.29, 89.1, 360.0, 89.8, model=436, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Previon
    {-1946.12, 264.12, 35.29, 89.1, 359.8, 91.2+0.5, model=579, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Huntley
    {-1945.96, 259.78, 35.29, 89.1, 0.0, 90.8, model=475, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sabre
    {-1953.90, 254.63, 35.21, 89.1, 0.0, 88.1, model=536, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Blade
    {-1962.48, 258.35, 35.27, 0.0, 0.0, 0.0, model=419, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Esperanto
    {-1962.46, 271.82, 35.27, 0.0, 0.0, 0.0, model=602, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Alpha
    {-1962.38, 285.31, 35.27, 0.0, 0.0, 0.0, model=527, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Cadrona

}

addEventHandler("onResourceStart", resourceRoot, function ()
    for i,v in ipairs(slots) do
        komis_shapes[i] = createColSphere(v[1], v[2], v[3], 3)
        setElementData(komis_shapes[i], "i", i)
        createKomisVehicle(i)
    end
end)

addEvent("kup:pojazd", true)
addEventHandler("kup:pojazd", resourceRoot, function ()
local gracz = source
    local shape = isPlayerInVehicleColShape(gracz)
    if not shape then return end
    local veh = getElementData(shape, "komis:veh")
    if not veh then return end
    local slot = getElementData(shape, "komis:slot")

    local price = vehicles[slot].price
    local money = getPlayerMoney(gracz)
    if price > money then
        triggerClientEvent(gracz, "onClientAddNotification", gracz, "* Nie sta? ci? na kupno tego pojazdu. Id? zar?b na pracach dorywczych i wr?c p??niej!", 'error', 255,255,255,true)    
        return
    end
    takePlayerMoney(gracz, price)

    local x,y,z = getElementPosition(veh)
    local rx,ry,rz = getElementRotation(veh)
    local i = getElementInterior(veh)
    local d = getElementDimension(veh)
    local pos = x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..", "..i..", "..d

    local r1,g1,b1, r2,g2,b2, r3,g3,b3, r4,g4,b4 = getVehicleColor(veh, true)
    local color = r1..", "..g1..", "..b1..", "..r2..", "..g2..", "..b2

    local owner = getElementData(gracz, "player:sid")
    local model = getElementModel(veh)
    local dist = vehicles[slot].mileage
    local poj = vehicles[slot].poj
    local gdzie = vehicles[slot].gdzie

    destroyElement(veh)
    setElementData(shape, "komis:veh", false)
    setElementData(shape, "salonowe", false)

    local q, num, id = exports["pystories-db"]:dbGet("INSERT INTO pystories_vehicles SET pos=?, fuel=15, mileage=?, ownedPlayer=?, parking=1, pojemnosc_silnika=?, color=?, model=?", pos, dist, owner, poj, color, model)
    if q then
        createKomisVehicle(slot)
        triggerClientEvent(gracz, "onClientAddNotification", gracz,"Gratulacje! Zakupi?e? sw?j pierwszy lub kolejny pojazd na serwerze! Pojazd zosta? przeniesiony do przechowywalni")
        setElementData(gracz, "vehicle:desc", false)
        setElementData(gracz, "vehicle:mileage", vehicles[slot].mileage)
        setElementData(gracz, "vehicle:poj", vehicles[slot].poj2)
    else
        triggerClientEvent(gracz, "onClientAddNotification", gracz, "Wyst?pi? problem z kupnem pojazdu! Zg?o? to administracji serwera!", 'info', 255,255,255,true)    
    end
end)

function createKomisVehicle(slot)
    if #getElementsWithinColShape(komis_shapes[slot]) > 0 then setTimer(createKomisVehicle, 250, 1, slot) return end

    vehicles[slot] = {}

    vehicles[slot].mileage = math.random(slots[slot].dmin, slots[slot].dmax)
    vehicles[slot].price = slots[slot].price

    vehicles[slot].veh = createVehicle(slots[slot].model, slots[slot][1], slots[slot][2], slots[slot][3], 0, 0, slots[slot][4])
    setElementFrozen(vehicles[slot].veh, true)
    setVehicleDamageProof(vehicles[slot].veh, true)
    setVehicleLocked(vehicles[slot].veh, true)

    setElementData(komis_shapes[slot], "komis:veh", vehicles[slot].veh)
    setElementData(komis_shapes[slot], "komis:slot", vehicles[slot].veh)
    setElementData(vehicles[slot].veh, "komis:veh", true)
    setElementData(vehicles[slot].veh, "salonowe", true)
    setVehicleOverrideLights ( vehicles[slot].veh, 2 )
    setVehicleColor(vehicles[slot].veh, 0,122,255)
    setVehicleHeadLightColor(vehicles[slot].veh, 255, 255, 255)

    if slots[slot].gdzie == "cygan" then
    vehicles[slot].poj = math.random(1,2)
    vehicles[slot].gdzie = "cygan"
    elseif slots[slot].gdzie == "zwykly" then
    vehicles[slot].poj = math.random(2,3)
    vehicles[slot].gdzie = "zwykly"
    elseif slots[slot].gdzie == "sportowy" then
    vehicles[slot].poj = math.random(3,4)
    vehicles[slot].gdzie = "sportowy"
    end

        if vehicles[slot].poj == 1 then
    vehicles[slot].poj2 = 1.2
    elseif vehicles[slot].poj == 2 then
    vehicles[slot].poj2 = 1.6
    elseif vehicles[slot].poj == 3 then
    vehicles[slot].poj2 = 1.8
    elseif vehicles[slot].poj == 4 then
    vehicles[slot].poj2 = 2.0
    elseif vehicles[slot].poj == 5 then
    vehicles[slot].poj2 = 2.2
    elseif vehicles[slot].poj == 6 then
    vehicles[slot].poj2 = 2.5
    elseif vehicles[slot].poj == 7 then
    vehicles[slot].poj2 = 2.6
    elseif vehicles[slot].poj == 8 then
    vehicles[slot].poj2 = 2.7
    elseif vehicles[slot].poj == 9 then
    vehicles[slot].poj2 = 2.8
    elseif vehicles[slot].poj == 10 then
    vehicles[slot].poj2 = 2.9
    elseif vehicles[slot].poj == 11 then
    vehicles[slot].poj2 = 3.0
    elseif vehicles[slot].poj == 12 then
    vehicles[slot].poj2 = 3.1
    local desc = "Pojazd: "..getVehicleName(vehicles[slot].veh).."\nPrzebieg: "..vehicles[slot].mileage.." km\nCena: "..slots[slot].price.." PLN\nPojemno??: "..vehicles[slot].poj2.." dm&#179;\nRodzaj paliwa: Benzyna\n Pojemno?? Baku: 50 L\nJe?eli chcesz zakupi? pojazd kliknij przycisk zakup"
    setElementData(veh, "vehicle:desc", desc)
    --setElementData(vehicles[slot].veh, "vehicle:desc", "---------\nPojazd: "..getVehicleName(vehicles[slot].veh).."\nKoszt: "..slots[slot].price.." PLN\nPrzebieg: "..vehicles[slot].mileage.." km\nPojemno?? Silnika: "..vehicles[slot].poj2.." cm3\nRodzaj paliwa: "..vehicles[slot].rodzaj.."\nPojemno?? Baku: 100 L\nZainteresowa? ci? ten pojazd? /kuppojazd\n---------")
end

function isPlayerInVehicleColShape(player)
    for i,v in ipairs(komis_shapes) do
        if isElementWithinColShape(player, v) then return v end
    end
    return false
end
end


Dam ca?y kod client i serwer

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 16:42


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Ju? widz?, tutaj:
setElementData(veh, "vehicle:desc", desc)

jest z?a zmienna pojazdu.

Chyba to, daj zna? jaki efekt po zmianie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 16:51


DylemaT929

Nikt






Wiek: 28
Na forum: 4182 dni
Posty: 340
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

"Wilq" napisał/a:

Ju? widz?, tutaj:
setElementData(veh, "vehicle:desc", desc)

jest z?a zmienna pojazdu.

Chyba to, daj zna? jaki efekt po zmianie.


Troch? nie zrozumia?em. Po stronie clienta czy serwera? i co mam z tym zrobi?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 17:52


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Ustawiasz elementDat? z?emu elementowi, strona server.

Tak powinno wygl?da?:
setElementData(vehicles[slot].veh, "vehicle:desc", desc)


Powinno dzia?a?, je?li "vehicles[slot].veh" to poprawne wskazanie pojazdu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 18:26


DylemaT929

Nikt






Wiek: 28
Na forum: 4182 dni
Posty: 340
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

"Wilq" napisał/a:

Ustawiasz elementDat? z?emu elementowi, strona server.

Tak powinno wygl?da?:
setElementData(vehicles[slot].veh, "vehicle:desc", desc)


Powinno dzia?a?, je?li "vehicles[slot].veh" to poprawne wskazanie pojazdu.



Og?lnie ?adnego b??du nie ma i jak podchodz? do auta nie wyskakuje ?adne gui.

Teraz gdy podchodz? do auta. Jest ma?y lag jakby mia?o gui wyskoczy? a potem ju? go nie ma. W sensie nic nie wyskakuje

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 20:17


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

function salony()
    dxDrawRectangle(screenW * 0.3602, screenH * 0.3236, screenW * 0.2766, screenH * 0.5514, tocolor(0, 0, 0, 137), false)
    --dxDrawText(informacje_pojazdy, screenW * 0.3797, screenH * 0.3583, screenW * 0.6148, screenH * 0.8111, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end


Tekst si? nie wy?wietli, jest zakomentowany.
Popraw to i wy?lij server oraz client.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-11, 21:28


DylemaT929

Nikt






Wiek: 28
Na forum: 4182 dni
Posty: 340
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

"Wilq" napisał/a:

function salony()
    dxDrawRectangle(screenW * 0.3602, screenH * 0.3236, screenW * 0.2766, screenH * 0.5514, tocolor(0, 0, 0, 137), false)
    --dxDrawText(informacje_pojazdy, screenW * 0.3797, screenH * 0.3583, screenW * 0.6148, screenH * 0.8111, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end


Tekst si? nie wy?wietli, jest zakomentowany.
Popraw to i wy?lij server oraz client.


client

local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end

local informacje_pojazdy = ""

function salony()
    dxDrawRectangle(screenW * 0.3602, screenH * 0.3236, screenW * 0.2766, screenH * 0.5514, tocolor(0, 0, 0, 137), false)
    dxDrawText(informacje_pojazdy, screenW * 0.3797, screenH * 0.3583, screenW * 0.6148, screenH * 0.8111, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(btn, state)
    if btn == "left" and state == "down" then
        if isMouseIn(screenW * 0.51, screenH * 0.68, screenW * 0.102, screenH * 0.044) and info ~= "" then
              showCursor(false)
              removeEventHandler("onClientRender", root, salony)
              informacje_pojazdy = ""
          elseif isMouseIn(screenW * 0.39, screenH * 0.68, screenW * 0.102, screenH * 0.044) and info ~= "" then
              triggerServerEvent("kup:pojazd", localPlayer)
              showCursor(false)
              removeEventHandler("onClientRender", root, salony)
              informacje_pojazdy = ""
          end
      end
end)

addEventHandler("onClientColShapeHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if isPedInVehicle(hit) then return end
    local veh = getElementData(source, "komis:veh")
    if not veh then return end
    local desc = getElementData(veh, "vehicle:desc")
    if not desc then return end
    addEventHandler("onClientRender", root, salony)
    informacje_pojazdy = desc
    showCursor(true)
end)


serwer

--[[
    Komisy samochodowe
    @author value <value2k@gmail.com>
    @Edit: DylemaT929 :)
    Nie masz prawa u?y? tego kodu bez mojej zgody
]]
createBlip(-930.47, -537.42, 26.05, 55,2,0,0,0,0,0,275) --- cygan
createBlip(-1663.96, 1212.86, 21.16, 55,2,0,0,0,0,0,275) --- pojazdy sportowe
createBlip(-1950.92, 279.76, 47.70, 55,2,0,0,0,0,0,275) --- pojazdy zwykle

local vehicles = {}
local komis_shapes = {}
local slots = {
   
    -- Salon LV Motory
    {-1953.35, 306.55, 40.64, 537.4, 0.0, 179.6, model=521, dmax=0, dmin=0, price=math.random(25000,26000), gdzie="motory"}, -- FCR 900
    {-1956.45, 306.28, 40.64, 537.4, 0.0, 179.8, model=581, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- BF
    {-1952.58, 300.26, 40.59, 89.1, 0.0, 91.0, model=463, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- Freeway
    {-1952.72, 295.79, 40.59, 89.1, 0.0, 88.4, model=471, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- QuadBike
    {-1952.91, 291.28, 40.59, 89.1, 0.0, 91.0, model=461, dmax=0, dmin=0, price=math.random(20000,21000), gdzie="motory"}, -- PCJ


    -- Cygan 
    {-957.26, -517.70, 25.61, 310.5, 0.0, 330.10, model=410, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Manana
    {-936.33, -510.96, 25.84, 300.0, 360.0, 325.3, model=458, dmax=99343, dmin=97323, price=math.random(17500,18000), gdzie="cygan"}, -- Solair
    {-931.80, -496.03, 25.95, 215.2, 360.0, 194.0, model=478, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Walton
    {-931.05, -538.50, 26.05, 0.1, 0.0, 3.8, model=418, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Moonbeam
    {-918.00, -533.21, 25.77, 382.0, 360.0, 26.9, model=543, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Sadler
    {-945.68, -531.82, 25.86, 310.5, 0.0, 329.9, model=540, dmax=99343, dmin=97323, price=math.random(12500,13000), gdzie="cygan"}, -- Vincent

    -- Salon LV Sportowy
    {-1662.96, 1221.65, 13.26, 230, 0, 0, model=429, dmax=0, dmin=0, price=math.random(65000,66000), gdzie="sportowy"}, -- Banshee
    {-1649.00, 1207.89, 13.34,65, 0.0, 0.0, model=560, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Sultan
    {-1649.99, 1207.60, 20.78,65, 0.0, 0.0, model=541, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Bullet
    {-1663.46, 1221.50, 20.86,230, 0.0, 0.0, model=451, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Turismo
    {-1665.56, 1206.14, 20.98, 310.8, 360.0, 306.6, model=480, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Comet
    {-1673.03, 1206.35, 13.38, 310.8, 360.0, 300.6, model=506, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="sportowy"}, -- Super GT

    -- Salon LV zwykly
    {-1946.15, 257.67, 40.83, 56.0, 0.0, 43.5, model=492, dmax=0, dmin=0, price=math.random(65000,66000), gdzie="zwykly"}, -- Greenwood
    {-1954.08, 257.70, 40.93, 360.0, 360.0, 359.9, model=421, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Washington
    {-1946.13, 273.40, 40.82, 89.1, 0.0, 88.9, model=526, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Fortune
    {-1945.99, 265.42, 40.82, 89.1, 359.8, 91.5, model=426, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Premier
    {-1959.99, 304.17, 35.35, 537.4, 359.8, 180.5, model=405, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sentinel
    {-1955.37, 304.21, 35.35, 537.4, 0.0, 179.4, model=445, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Admiral
    {-1945.77, 273.34, 35.29, 89.1, 360.0, 89.7, model=550, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sunrise
    {-1946.16, 268.81, 35.29, 89.1, 360.0, 89.8, model=436, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Previon
    {-1946.12, 264.12, 35.29, 89.1, 359.8, 91.2+0.5, model=579, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Huntley
    {-1945.96, 259.78, 35.29, 89.1, 0.0, 90.8, model=475, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Sabre
    {-1953.90, 254.63, 35.21, 89.1, 0.0, 88.1, model=536, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Blade
    {-1962.48, 258.35, 35.27, 0.0, 0.0, 0.0, model=419, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Esperanto
    {-1962.46, 271.82, 35.27, 0.0, 0.0, 0.0, model=602, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Alpha
    {-1962.38, 285.31, 35.27, 0.0, 0.0, 0.0, model=527, dmax=0, dmin=0, price=math.random(47500,48200), gdzie="zwykly"}, -- Cadrona

}

addEventHandler("onResourceStart", resourceRoot, function ()
    for i,v in ipairs(slots) do
        komis_shapes[i] = createColSphere(v[1], v[2], v[3], 3)
        setElementData(komis_shapes[i], "i", i)
        createKomisVehicle(i)
    end
end)

addEvent("kup:pojazd", true)
addEventHandler("kup:pojazd", resourceRoot, function ()
local gracz = source
    local shape = isPlayerInVehicleColShape(gracz)
    if not shape then return end
    local veh = getElementData(shape, "komis:veh")
    if not veh then return end
    local slot = getElementData(shape, "komis:slot")

    local price = vehicles[slot].price
    local money = getPlayerMoney(gracz)
    if price > money then
        triggerClientEvent(gracz, "onClientAddNotification", gracz, "* Nie sta? ci? na kupno tego pojazdu. Id? zar?b na pracach dorywczych i wr?c p??niej!", 'error', 255,255,255,true)    
        return
    end
    takePlayerMoney(gracz, price)

    local x,y,z = getElementPosition(veh)
    local rx,ry,rz = getElementRotation(veh)
    local i = getElementInterior(veh)
    local d = getElementDimension(veh)
    local pos = x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..", "..i..", "..d

    local r1,g1,b1, r2,g2,b2, r3,g3,b3, r4,g4,b4 = getVehicleColor(veh, true)
    local color = r1..", "..g1..", "..b1..", "..r2..", "..g2..", "..b2

    local owner = getElementData(gracz, "player:sid")
    local model = getElementModel(veh)
    local dist = vehicles[slot].mileage
    local poj = vehicles[slot].poj
    local gdzie = vehicles[slot].gdzie

    destroyElement(veh)
    setElementData(shape, "komis:veh", false)
    setElementData(shape, "salonowe", false)

    local q, num, id = exports["pystories-db"]:dbGet("INSERT INTO pystories_vehicles SET pos=?, fuel=15, mileage=?, ownedPlayer=?, parking=1, pojemnosc_silnika=?, color=?, model=?", pos, dist, owner, poj, color, model)
    if q then
        createKomisVehicle(slot)
        triggerClientEvent(gracz, "onClientAddNotification", gracz,"Gratulacje! Zakupi?e? sw?j pierwszy lub kolejny pojazd na serwerze! Pojazd zosta? przeniesiony do przechowywalni")
        setElementData(gracz, "vehicle:desc", false)
        setElementData(gracz, "vehicle:mileage", vehicles[slot].mileage)
        setElementData(gracz, "vehicle:poj", vehicles[slot].poj2)
    else
        triggerClientEvent(gracz, "onClientAddNotification", gracz, "Wyst?pi? problem z kupnem pojazdu! Zg?o? to administracji serwera!", 'info', 255,255,255,true)    
    end
end)

function createKomisVehicle(slot)
    if #getElementsWithinColShape(komis_shapes[slot]) > 0 then setTimer(createKomisVehicle, 250, 1, slot) return end

    vehicles[slot] = {}

    vehicles[slot].mileage = math.random(slots[slot].dmin, slots[slot].dmax)
    vehicles[slot].price = slots[slot].price

    vehicles[slot].veh = createVehicle(slots[slot].model, slots[slot][1], slots[slot][2], slots[slot][3], 0, 0, slots[slot][4])
    setElementFrozen(vehicles[slot].veh, true)
    setVehicleDamageProof(vehicles[slot].veh, true)
    setVehicleLocked(vehicles[slot].veh, true)

    setElementData(komis_shapes[slot], "komis:veh", vehicles[slot].veh)
    setElementData(komis_shapes[slot], "komis:slot", slot)
    setElementData(vehicles[slot].veh, "komis:veh", true)
    setElementData(vehicles[slot].veh, "salonowe", true)
    setVehicleOverrideLights ( vehicles[slot].veh, 2 )
    setVehicleColor(vehicles[slot].veh, 0,122,255)
    setVehicleHeadLightColor(vehicles[slot].veh, 255, 255, 255)

    if slots[slot].gdzie == "cygan" then
    vehicles[slot].poj = math.random(1,2)
    vehicles[slot].gdzie = "cygan"
    elseif slots[slot].gdzie == "zwykly" then
    vehicles[slot].poj = math.random(2,3)
    vehicles[slot].gdzie = "zwykly"
    elseif slots[slot].gdzie == "sportowy" then
    vehicles[slot].poj = math.random(3,4)
    vehicles[slot].gdzie = "sportowy"
    end

        if vehicles[slot].poj == 1 then
    vehicles[slot].poj2 = 1.2
    elseif vehicles[slot].poj == 2 then
    vehicles[slot].poj2 = 1.6
    elseif vehicles[slot].poj == 3 then
    vehicles[slot].poj2 = 1.8
    elseif vehicles[slot].poj == 4 then
    vehicles[slot].poj2 = 2.0
    elseif vehicles[slot].poj == 5 then
    vehicles[slot].poj2 = 2.2
    elseif vehicles[slot].poj == 6 then
    vehicles[slot].poj2 = 2.5
    elseif vehicles[slot].poj == 7 then
    vehicles[slot].poj2 = 2.6
    elseif vehicles[slot].poj == 8 then
    vehicles[slot].poj2 = 2.7
    elseif vehicles[slot].poj == 9 then
    vehicles[slot].poj2 = 2.8
    elseif vehicles[slot].poj == 10 then
    vehicles[slot].poj2 = 2.9
    elseif vehicles[slot].poj == 11 then
    vehicles[slot].poj2 = 3.0
    elseif vehicles[slot].poj == 12 then
    vehicles[slot].poj2 = 3.1
    local desc = "Pojazd: "..getVehicleName(vehicles[slot].veh).."\nPrzebieg: "..vehicles[slot].mileage.." km\nCena: "..slots[slot].price.." PLN\nPojemno??: "..vehicles[slot].poj2.." dm&#179;\nRodzaj paliwa: Benzyna\n Pojemno?? Baku: 50 L\nJe?eli chcesz zakupi? pojazd kliknij przycisk zakup"
    setElementData(vehicles[slot].veh, "vehicle:desc", desc)
    --setElementData(vehicles[slot].veh, "vehicle:desc", "---------\nPojazd: "..getVehicleName(vehicles[slot].veh).."\nKoszt: "..slots[slot].price.." PLN\nPrzebieg: "..vehicles[slot].mileage.." km\nPojemno?? Silnika: "..vehicles[slot].poj2.." cm3\nRodzaj paliwa: "..vehicles[slot].rodzaj.."\nPojemno?? Baku: 100 L\nZainteresowa? ci? ten pojazd? /kuppojazd\n---------")
end

function isPlayerInVehicleColShape(player)
    for i,v in ipairs(komis_shapes) do
        if isElementWithinColShape(player, v) then return v end
    end
    return false
end
end


Postaw piwo autorowi tego posta
 

 
Tagi: gui :: salon
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