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

Wysłany: 2018-11-24, 17:21


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Siema tutaj macie kod:

addEventHandler("onResourceStart", resourceRoot, function()
    local q = exports.DB2:pobierzTabeleWynikow("SELECT * FROM domy")
    for i,v in ipairs(q) do
        v.wejscie = split(v.wejscie, ",")
        if v.nwlasciciel:len() < 3 then id = 1273 else id = 1272 end
        local wejscie = createPickup(v.wejscie[1], v.wejscie[2], v.wejscie[3], 3, id, 0, 0)
        local cwejscie = createColSphere(v.wejscie[1], v.wejscie[2], v.wejscie[3], 1)
        local wlasciciel = false
        local nwlascciiel = false
        if id == 1273 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], "arrow", 1, 0, 0, 255)
        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.DB2:pobierzTabeleWynikow("SELECT * FROM domy")
    for i,v in ipairs(q) do
    local qq = exports.DB2:pobierzTabeleWynikow("SELECT * FROM domy WHERE id=?", v.id)
    local t = getRealTime()
    local r = t.year
    local m = t.month
    local t = t.monthday
    r = r+1900
    m = m+1
    if t < 10 then
        t = "0"..t
    end
    local data = r.."-"..m.."-"..t
    if qq[1].data == data then
        exports.DB2:pobierzTabeleWynikow("UPDATE domy SET wlasciciel=0, nwlasciciel=?, data=? WHERE id=?", "", "0000-00-00", q[1].id)
        restartResource(getThisResource())
    end
    end
end
setTimer(refreshDomy, 3600000, 0)

addCommandHandler("dom", function(g, _, c, ...)
    if ... and c and getElementData(g, "player:admin") then
        local x, y, z = getElementPosition(g)
        local n = table.concat({...}, " ")
        outputChatBox("Dom na "..x..":"..y..":"..z.." nazwa "..n.." za cene "..string.format("%1.2f", c).." PLN", g)
        local wejscie = x..","..y..","..z
        exports.DB2:pobierzTabeleWynikow("INSERT INTO domy SET wlasciciel=0, nwlasciciel=?, nazwa=?, data=?, wejscie=?, wyjscie=?, tpw=?, cena=?", "", n, "0000-00-00", wejscie, "318.61, 1114.48, 1083.88", "318.39, 1116.68, 1083.88", c)
        restartResource(getThisResource())
    end
end)


addEvent("zDom", true)
addEventHandler("zDom", root, function(id)
    exports.DB2:pobierzTabeleWynikow("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 uid = getPlayerDBID(client)
    local hajs = getPlayerMoney(client)
    koszt = dni*koszt
    koszt = string.format("%1.2f", koszt)
    if tonumber(koszt) > hajs then
        exports["jb-notyfikacje"]:addNotification("Nie sta? ci? na zakup tego domu, potrzebujesz "..koszt.." $.", client)
        return
    end
    local r = exports.DB2:pobierzTabeleWynikow("UPDATE domy SET wlasciciel=?,nwlasciciel=?,data=IF(data>NOW(),data,NOW())+INTERVAL ? DAY WHERE id=?", uid, getPlayerName(client), dni, id)
    --setElementData(client, hajs-koszt)
    takePlayerMoney(client, koszt)
    exports["jb-notyfikacje"]:addNotification("Zakupi?e?/przed?u?y?e? mieszkanie o id "..id.." na ilo?? dni "..dni.." za cene "..koszt.." $.", 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)


Za pomo? daje :piwo:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:29


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jakie? errory pod /debugscript 3?
Skrypt DB2 w??czony i wprowadzone s? tam dane MySQL?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:38


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Wilq, Nic nie ma w db3 db2 podpi?te

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:42


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Domy z bazy danych tworz? si? poprawnie?
Masz elementDat? "player:admin"?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:43


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Wilq, Mam

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:49


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Spr?buj doda? ustawianie r?wnie? interioru domku w tej komendzie, aktualnie jej brakuje - ale czy to jest powodem, ?e dom si? nie tworzy nie jestem pewny w 100%.
W bazie zobacz czy masz kolumn? 'int', o kt?rej napisa?em wy?ej.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:52


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Wilq, Tak jest taka kulumna

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:52


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

No, to dodawaj ustawianie tego interioru w komendzie 'dom'.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:53


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Wilq, Ale nawet bez tego nie dodaje si? dom

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:56


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

No to w?a?nie spr?buj doda? i zobacz czy to pomo?e...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 17:57


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Wilq, Nie wiem jak doda? ten interior pomo?esz

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 18:17


Query

SyndicateMTA






Wiek: 24
Na forum: 3213 dni
Posty: 319
Nick w MP: Query

Piwa: 5238

Respekt: 141
Respekt: 141

AkossPL, znaj?c OGRPG to nie masz uzupe?nionej tabelki lss_interiory . Domki zapisuja sie w bazie ale nie pokazuja wiec nie masz tabelki lss_interiory

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 18:23


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

darecky02, Mam tabele

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-24, 18:54


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Dodajesz do wywo?ania akcji do MySQL dopisek 'int=?' i p??niej podajesz odpowiednie ID.

Przyk?ad poni?ej:

addCommandHandler("dom", function(g, _, c, ...)
    if ... and c and getElementData(g, "player:admin") then
        local x, y, z = getElementPosition(g)
        local n = table.concat({...}, " ")
        outputChatBox("Dom na "..x..":"..y..":"..z.." nazwa "..n.." za cene "..string.format("%1.2f", c).." PLN", g)
        local wejscie = x..","..y..","..z
local liczba=math.random(1,15)
        exports.DB2:pobierzTabeleWynikow("INSERT INTO domy SET wlasciciel=0, nwlasciciel=?, nazwa=?, data=?, wejscie=?, wyjscie=?, int=?, tpw=?, cena=?", "", n, "0000-00-00", wejscie, "318.61, 1114.48, 1083.88", liczba, "318.39, 1116.68, 1083.88", c)
        restartResource(getThisResource())
    end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: nie :: mogę :: domów :: tworzyć
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