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

Wysłany: 2019-06-30, 19:08


Pyrek24







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

Piwa: 10

Respekt: 50

Witajcie, ot?? ogarn??em sb domy z PSSM. Wszystko git, w sql si? pi?knie ?adnie tworzy, lecz gdy wchodz? nie ma interioru. Zauwa?y?em tabel? rpg_interiors, lecz ona jest pusta. Pomo?e kto? ?

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-30, 19:26


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Mo?esz wykorzysta? domy?lne interiory albo zrobi? sobie samemu tak? baz? interiorow. By?a jaka? w XyzzyRP, mo?esz tam lukn??.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-30, 21:08


Pyrek24







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

Piwa: 10

Respekt: 50

My?la?em and tym ale nwm jak to zrobi? :L. Co? doradzisz?
kod
client

--[[
Autorzy: MKL,MALENTAS,ASPEREK
]]

function shadowText(text,x,y,w,h,color,size,font,xx,yy)
    dxDrawText(text,x+1,y+1,w+1,h+1,tocolor(0,0,0),size,font,xx,yy,false)
    dxDrawText(text,x,y,w,h,color,size,font,xx,yy,false)
end

bindKey( 'i', 'both', function( key, keyState )
    if keyState == 'down' then
        for k, v in ipairs ( getElementsByType( 'colshape', resourceRoot ) ) do
            local dom=getElementData(v,"dom")
            if tonumber(dom.wlasciciel) then
                createBlipAttachedTo( v, 32, 2, 255,0,0,255,100,500 );
            else
                createBlipAttachedTo( v, 31, 2, 255,0,0,255,100,500 );
            end
        end
    else
        for k, v in ipairs( getElementsByType( 'blip', getResourceRootElement() ) ) do
            destroyElement(v)
        end
    end

end)

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

function mysz(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 ustawienia = nil
local panel = false

local edit = guiCreateEdit(0.41, 0.50, 0.15, 0.04, "1", true)  
guiSetVisible(edit, false)
guiEditSetMaxLength(edit, 2)
guiSetAlpha(edit, 255)


function guiKupno()
  local info = "Panel wynajmu lokalu"
  if ustawienia.wlasciciel == getElementData(localPlayer, "player:uid") then
    info = "Panel przedluzania czasu wynajmu lokalu"
  end
  exports["buttons"]:createCustomWindow(info, screenW * 0.3053, screenH * 0.3086, screenW * 0.3644, screenH * 0.3805, tocolor(255, 255, 255, 255), false)
  local dni = "Ilo?? dni"
  if ustawienia.wlasciciel == getElementData(localPlayer, "player:uid") then
    dni = "Ilo?? dni\n(( Lokal jest wynaj?ty do "..ustawienia.data.." ))"
  end
  shadowText(dni, screenW * 0.2619, screenH * 0.4178, screenW * 0.7097, screenH * 0.4922, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, false, false, false)
  dxDrawRectangle(screenW * 0.3133, screenH * 0.5867, screenW * 0.1394, screenH * 0.0600, tocolor(0, 0, 0, 170), false)
  dxDrawRectangle(screenW * 0.5225, screenH * 0.5867, screenW * 0.1394, screenH * 0.0600, tocolor(0, 0, 0, 170), false)
shadowText("Potwierd?", screenW * 0.1876, screenH * 0.6167, screenW * 0.5778, screenH * 0.6200, tocolor(255, 255, 255, 255), 1.80, "default-bold", "center", "center", false, false, false, false, false)
shadowText("Zamknij", screenW * 0.4901, screenH * 0.6117, screenW * 0.7028, screenH * 0.6256, tocolor(255, 255, 255, 255), 1.80, "default-bold", "center", "center", false, false, false, false, false)
end

function gui()
  local nazwa = ustawienia.nazwa
  local wlasciciel = ustawienia.nwlasciciel
  local cena = ustawienia.cena
  local id = ustawienia.id
  local info = wlasciciel:gsub("#%x%x%x%x%x%x","")
  if wlasciciel == "" then
    info = "nikogo!"
  end
  exports["buttons"]:createCustomWindow("", screenW * 0.7416, screenH * 0.3086, screenW * 0.2492, screenH * 0.3805, tocolor(255, 255, 255, 255), false)
  --shadowText(nazwa, screenW * 0.7416, screenH * 0.0067, screenW * 0.7097, screenH * 0.6244, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) 
  shadowText("Numer lokalu: "..id.."\nW?a?ciciel lokalu: Urz?d San Fierro\nWynaj?ty przez: "..info.."\nCena wynajmu za dobe: "..cena.." $", screenW * 0.9206, screenH * 0.0289, screenW * 0.8097, screenH * 0.8022, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, false, false, false)
  dxDrawRectangle(screenW * 0.7515, screenH * 0.5333, screenW * 0.1094, screenH * 0.0600, tocolor(0, 0, 0, 170), false)
  dxDrawRectangle(screenW * 0.8715, screenH * 0.5333, screenW * 0.1094, screenH * 0.0600, tocolor(0, 0, 0, 170), false)
  local bnapis = ""
  if ustawienia.wlasciciel ~= "brak" and ustawienia.wlasciciel ~= getElementData(localPlayer, "player:uid") then
    bnapis = "Lokal jest ju? \nwynaj?ty"
  elseif ustawienia.wlasciciel == "brak" then
    bnapis = "Wynajmij lokal"
  elseif ustawienia.wlasciciel ~= "brak" and ustawienia.wlasciciel == getElementData(localPlayer, "player:uid") then
    bnapis = "Przed?u? wa?no?? \nwynajmu"
  end
  shadowText("Zobacz od ?rodka", screenW * 0.6635, screenH * 0.2133, screenW * 0.9493, screenH * 0.9167, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
  shadowText(bnapis, screenW * 0.9055, screenH * 0.2133, screenW * 0.9493, screenH * 0.9167, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
  if ustawienia.wlasciciel == getElementData(localPlayer, "player:uid") then
  dxDrawRectangle(screenW * 0.8124, screenH * 0.6133, screenW * 0.1094, screenH * 0.0600, tocolor(0, 0, 0, 170), false)  
  shadowText("Wyprowad? si?", screenW * 0.9394, screenH * 0.3733, screenW * 0.7972, screenH * 0.9167, tocolor(255, 255, 255, 255), 1.30, "default-bold", "center", "center", false, false, false, false, false)
  end
end



addEventHandler("onClientClick", root, function(b, s)
  if b ~= "state" and s ~= "down" then return end
  if mysz(screenW * 0.7515, screenH * 0.5333, screenW * 0.1094, screenH * 0.0600) and panel == true then
    triggerServerEvent("tdDomu", localPlayer, ustawienia.x, ustawienia.y, ustawienia.z, ustawienia.int, ustawienia.id)
  elseif mysz(screenW * 0.8124, screenH * 0.6133, screenW * 0.1094, screenH * 0.0600) and panel == true then  
    if ustawienia.wlascciel ~= "brak" and ustawienia.wlasciciel ~= getElementData(localPlayer, "player:uid") then return end
    triggerServerEvent("zDom", localPlayer, ustawienia.id)
            outputChatBox("* Pomy?lnie wyprowadzasz si? z lokalu o numerze "..ustawienia.id)
  elseif mysz(screenW * 0.8715, screenH * 0.5333, screenW * 0.1094, screenH * 0.0600) and panel == true then
    if ustawienia.wlasciciel ~= "brak" and ustawienia.wlasciciel ~= getElementData(localPlayer, "player:uid") then return end
    addEventHandler("onClientRender", root, guiKupno)
    guiSetVisible(edit, true)
  elseif mysz(screenW * 0.5225, screenH * 0.5867, screenW * 0.1394, screenH * 0.0600) and guiGetVisible(edit) == true then
    guiSetVisible(edit, false)
    removeEventHandler("onClientRender", root, guiKupno)
  elseif mysz(screenW * 0.3133, screenH * 0.5867, screenW * 0.1394, screenH * 0.0600) and guiGetVisible(edit) == true then
    local text = guiGetText(edit)
    if not tonumber(text) then return end
    if tonumber(text) < 1 then
              outputChatBox("* Ilo?? dni musi wynosi? wi?cej ni? zero!")
      return
    end
    triggerServerEvent("kDom", localPlayer, ustawienia.id, tonumber(text), ustawienia.cena)
  end
end)

addEventHandler("onClientColShapeHit", resourceRoot, function(hit)
  if hit == vehicle then return end
  if hit ~= localPlayer then return end
  if isPedInVehicle(localPlayer) then return end
  local dom = getElementData(source, "dom")
  if not dom then return end
  if panel == true then return end
  ustawienia = dom
  showCursor(true, false)
  panel = true
  addEventHandler("onClientRender", root, gui)
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
  if hit == vehicle then return end
  if hit ~= localPlayer then return end
  if getElementDimension(source) ~= getElementDimension(hit) then return end
  local wdom = getElementData(source, "wdom")
  if not wdom then return end
  triggerServerEvent("tdDomu", hit, wdom.x, wdom.y, wdom.z)
end)

addEventHandler("onClientColShapeLeave", resourceRoot, function(hit)
  if hit ~= localPlayer then return end
  local dom = getElementData(source, "dom")
  if not dom then return end
  ustawienia = false
  showCursor(false)
  panel = false
  removeEventHandler("onClientRender", root, gui)
  if guiGetVisible(edit) == true then
    removeEventHandler("onClientRender", root, guiKupno)
    guiSetVisible(edit, false)
  end
end)

server

--[[
Autor: Asper
Edytowa?: Malentas
Skrypt: System domow
]]

-- Rendering --

-- System dom?w --

addEventHandler("onResourceStart", resourceRoot, function()
    local q = exports["ogrpg-db"]:dbGet("SELECT * FROM domy")
    for i,v in ipairs(q) do
        v.wejscie = split(v.wejscie, ",")
        if v.nwlasciciel:len() < 3 then id = 0 id2 = 255 id3 = 0 else id = 255 id2 = 0 id3 = 0 end
        --local wejscie = createPickup(v.wejscie[1], v.wejscie[2], v.wejscie[3], 3, id, 0, 0)
        local wejscie = createMarker(v.wejscie[1], v.wejscie[2], v.wejscie[3]-1, "corona", 1, id, id2, id3, 0)
        local pickup = createPickup(v.wejscie[1], v.wejscie[2], v.wejscie[3],3,1272,0)
        setElementData(wejscie, "custom_marker", true)
        setElementData(wejscie, "kolorr", id)
        setElementData(wejscie, "kolorg", id2)
        setElementData(wejscie, "kolorb", id3)
        local cwejscie = createColSphere(v.wejscie[1], v.wejscie[2], v.wejscie[3], 1)
        local wlasciciel = false
        local nwlascciiel = false
        if id == 0 and id2 == 255 and id3 == 0 then
            wlasciciel = "brak"
            nwlasciciel = "brak"
        else
            wlasciciel = v.wlasciciel
            nwlasciciel = v.nwlasciciel
        end
        v.wyjscie = split(v.wyjscie, ",")
        v.tpw = split(v.tpw, ",")
        setElementData(cwejscie, "dom", {
        ["id"]=v.id,
        ["wlasciciel"]=wlasciciel,
        ["nwlasciciel"]=nwlasciciel,
        ["cena"]=v.cena,
        ["nazwa"]=v.nazwa,
        ["x"]=v.tpw[1],
        ["y"]=v.tpw[2],
        ["z"]=v.tpw[3],
        ["data"]=v.data,
        ["int"]=v.int,
        })
        local wyjscie = createMarker(v.wyjscie[1], v.wyjscie[2], v.wyjscie[3]-0.98, "corona", 1.2, 50,120,240, 0)
        setElementData(wyjscie, "custom_marker", true)
        setElementData(wyjscie, "wdom", {
        ["x"]=v.wejscie[1],
        ["y"]=v.wejscie[2],
        ["z"]=v.wejscie[3],
        })
        setElementInterior(wyjscie, v.int)
        setElementDimension(wyjscie, v.id)
    end
end)

function refreshDomy()
    local q = exports["ogrpg-db"]:dbGet("SELECT * FROM domy")
    for i,v in ipairs(q) do
    local qq = exports["ogrpg-db"]:dbGet("SELECT * FROM domy WHERE id=?", v.id)
    realTime=getRealTime()
    local r = realTime.year+1900
    local m = realTime.month+1
    local t = realTime.monthday
    local data=string.format("%04d-%02d-%02d %02d:%02d:%02d", r, m, t,realTime.hour, realTime.minute, realTime.second)
    if qq[1].data <= data then
        exports["ogrpg-db"]:dbSet("UPDATE domy SET wlasciciel=0, nwlasciciel=?, data=? WHERE id=?", "", "0000-00-00 00:00:00", qq[1].id)
        restartResource(getThisResource())
    end
    end
end
setTimer(refreshDomy, 30*60000, 0)

addCommandHandler("dom", function(g, _, c, ...)
    if ... and c and exports['dutyadmin']:getAdmin(plr,4) then
        local x, y, z = getElementPosition(g)
        local n = table.concat({...}, " ")
        outputChatBox("* Pomy?lnie utworzy?e? lokal na koordynatach "..x..", "..y..", "..z.." o nazwie "..n.." w cenie "..c.." $ za dobe!", g)
        exports["er-notyfikacje"]:showBox(g, "info", "Pomy?lnie utworzy?e? lokal na koordynatach "..x..", "..y..", "..z.." o nazwie "..n.." w cenie "..c.." $ za dobe!")
        local wejscie = x..","..y..","..z
        exports["ogrpg-db"]:dbSet("INSERT INTO domy SET wlasciciel=0, nwlasciciel=?, nazwa=?, data=?, wejscie=?, wyjscie=?, tpw=?, cena=?", "", n, "0000-00-00", wejscie, "1975.88, -1345.46, 174.85", "1973.84, -1345.28, 174.85", c)
        restartResource(getThisResource())
    end
end)

addEvent("zDom", true)
addEventHandler("zDom", root, function(id)
    exports["ogrpg-db"]:dbSet("UPDATE domy SET wlasciciel=0, nwlasciciel=?, data=? WHERE id=?", "", "0000-00-00", id)
    restartResource(getThisResource())
end)

local function getPlayerDBID(plr)
    local c=getElementData(plr,"player:uid")
    if not c then return nil end
    return tonumber(c)
end

addEvent("kDom", true)
addEventHandler("kDom", root, function(id, dni, koszt)
    if not id and not dni and not koszt then return end
    local dbid = getPlayerDBID(client)
    local hajs = getPlayerMoney(client)
    koszt = dni*koszt
    koszt = koszt
    if tonumber(koszt)*1000000 > hajs then
        outputChatBox("* Koszt wynajmu tego lokalu wynosi "..koszt.." $ za dobe!", client)
        return
    end
    local r = exports["ogrpg-db"]:dbSet("UPDATE domy SET wlasciciel=?,nwlasciciel=?,data=IF(data>NOW(),data,NOW())+INTERVAL ? DAY WHERE id=?", dbid, getPlayerName(client), dni, id)
    --setPlayerMoney(client, hajs-koszt)
    takePlayerMoney(client,koszt*1000000)
    outputChatBox("* Wynajem lokalu o numerze "..id.." na "..dni.." dni za cene "..koszt.." $ przebieg? pomy?lnie!", client)
    restartResource(getThisResource())
end)

addEvent("tdDomu", true)
addEventHandler("tdDomu", root, function(x, y, z, int, dim)
    if int and dim then
        setElementInterior(client, int)
        setElementDimension(client, dim)
    else
        setElementDimension(client, 0)
        setElementInterior(client, 0)
    end
    setElementPosition(client, x, y, z)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-30, 21:21


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Normalnie, setElementInterior i setElementPosition. Mo?esz sobie zrobi? tabelk? z pozycjami, zobacz tutaj:
https://wiki.multitheftauto.com/wiki/PL/Interior_IDs

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pyrek24
Wysłany: 2019-07-01, 16:45


Pyrek24







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

Piwa: 10

Respekt: 50

dzk. Temat do zamkni?cia.

Postaw piwo autorowi tego posta
 

 
Tagi: pssm :: domy
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