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: 25
Na forum: 3438 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: 4428 dni
Posty: 3410

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: 25
Na forum: 3438 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

--[[
AutorzyMKL,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( keykeyState )
    if keyState == 'down' then
        for kv in ipairs getElementsByType'colshape'resourceRoot ) ) do
            local dom=getElementData(v,"dom")
            if tonumber(dom.wlascicielthen
                createBlipAttachedTov322255,0,0,255,100,500 );
            else
                createBlipAttachedTov312255,0,0,255,100,500 );
            end
        end
    else
        for kv in ipairsgetElementsByType'blip'getResourceRootElement() ) ) do
            destroyElement(v)
        end
    end

end)

local screenWscreenH guiGetScreenSize()
local sxsy 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.410.500.150.04"1"true)  
guiSetVisible(editfalse)
guiEditSetMaxLength(edit2)
guiSetAlpha(edit255)


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(infoscreenW 0.3053screenH 0.3086screenW 0.3644screenH 0.3805tocolor(255255255255), 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(dniscreenW 0.2619screenH 0.4178screenW 0.7097screenH 0.4922tocolor(255255255255), 1.30"default-bold""center""center"falsefalsefalsefalsefalse)
  dxDrawRectangle(screenW 0.3133screenH 0.5867screenW 0.1394screenH 0.0600tocolor(000170), false)
  dxDrawRectangle(screenW 0.5225screenH 0.5867screenW 0.1394screenH 0.0600tocolor(000170), false)
shadowText("Potwierd?"screenW 0.1876screenH 0.6167screenW 0.5778screenH 0.6200tocolor(255255255255), 1.80"default-bold""center""center"falsefalsefalsefalsefalse)
shadowText("Zamknij"screenW 0.4901screenH 0.6117screenW 0.7028screenH 0.6256tocolor(255255255255), 1.80"default-bold""center""center"falsefalsefalsefalsefalse)
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.7416screenH 0.3086screenW 0.2492screenH 0.3805tocolor(255255255255), false)
  --shadowText(nazwascreenW 0.7416screenH 0.0067screenW 0.7097screenH 0.6244tocolor(255255255255), 1.00"default-bold""center""center"falsefalsefalsefalsefalse) 
  shadowText("Numer lokalu: "..id.."\nW?a?ciciel lokalu: Urz?d San Fierro\nWynaj?ty przez: "..info.."\nCena wynajmu za dobe: "..cena.." $"screenW 0.9206screenH 0.0289screenW 0.8097screenH 0.8022tocolor(255255255255), 1.30"default-bold""center""center"falsefalsefalsefalsefalse)
  dxDrawRectangle(screenW 0.7515screenH 0.5333screenW 0.1094screenH 0.0600tocolor(000170), false)
  dxDrawRectangle(screenW 0.8715screenH 0.5333screenW 0.1094screenH 0.0600tocolor(000170), 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.6635screenH 0.2133screenW 0.9493screenH 0.9167tocolor(255255255255), 1.20"default-bold""center""center"falsefalsefalsefalsefalse)
  shadowText(bnapisscreenW 0.9055screenH 0.2133screenW 0.9493screenH 0.9167tocolor(255255255255), 1.20"default-bold""center""center"falsefalsefalsefalsefalse)
  if ustawienia.wlasciciel == getElementData(localPlayer"player:uid"then
  dxDrawRectangle(screenW 0.8124screenH 0.6133screenW 0.1094screenH 0.0600tocolor(000170), false)  
  shadowText("Wyprowad? si?"screenW 0.9394screenH 0.3733screenW 0.7972screenH 0.9167tocolor(255255255255), 1.30"default-bold""center""center"falsefalsefalsefalsefalse)
  end
end



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

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

addEventHandler("onClientMarkerHit"resourceRoot, function(hit)
  if hit == vehicle then return end
  if hit ~= localPlayer then return end
  if getElementDimension(source) ~= getElementDimension(hitthen return end
  local wdom getElementData(source"wdom")
  if not wdom then return end
  triggerServerEvent("tdDomu"hitwdom.xwdom.ywdom.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"rootgui)
  if guiGetVisible(edit) == true then
    removeEventHandler("onClientRender"rootguiKupno)
    guiSetVisible(editfalse)
  end
end)

server

--[[
AutorAsper
Edytowa?: Malentas
SkryptSystem domow
]]

-- Rendering --

-- System dom?--

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 else id 255 id2 0 id3 0 end
        --local wejscie createPickup(v.wejscie[1], v.wejscie[2], v.wejscie[3], 3id00)
        local wejscie createMarker(v.wejscie[1], v.wejscie[2], v.wejscie[3]-1"corona"1idid2id30)
        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 == 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.250,120,2400)
        setElementData(wyjscie"custom_marker"true)
        setElementData(wyjscie"wdom", {
        ["x"]=v.wejscie[1],
        ["y"]=v.wejscie[2],
        ["z"]=v.wejscie[3],
        })
        setElementInterior(wyjsciev.int)
        setElementDimension(wyjsciev.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"rmt,realTime.hourrealTime.minuterealTime.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(refreshDomy30*600000)

addCommandHandler("dom", function(g_c, ...)
    if ... and and exports['dutyadmin']:getAdmin(plr,4then
        local xygetElementPosition(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(iddnikoszt)
    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=?"dbidgetPlayerName(client), dniid)
    --setPlayerMoney(clienthajs-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(xyzintdim)
    if int and dim then
        setElementInterior(clientint)
        setElementDimension(clientdim)
    else
        setElementDimension(client0)
        setElementInterior(client0)
    end
    setElementPosition(clientxyz)
end)


Postaw piwo autorowi tego posta
 

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


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

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: 25
Na forum: 3438 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 » PSSM Domy 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