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

Wysłany: 2020-07-02, 23:57


StifMaster







Wiek: 30
Na forum: 3525 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

Witajcie, posiadam problem z domkami. Podczas gdy w okienko wpisz? ilo?? dni na minusie to pieni?dze dodaj? si? do konta. Prosz? o pomoc :) Daj? zimne :piwo:
domy.lua
Kod:

domy={}
local function usunDom(id)
if isElement(domy[id].wyjscie) then destroyElement(domy[id].wyjscie) end
if isElement(domy[id].wejscie) then destroyElement(domy[id].wejscie) end
if isElement(domy[id].cs) then destroyElement(domy[id].cs) end
if isElement(domy[id].text) then destroyElement(domy[id].text) end
domy[id]=nil
end

function dodajDom(v,fast)

if not interiory[v.interiorid] then return false end
if domy[v.id] then
usunDom(v.id)
end
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?", v.ownerid)
if result and #result > 0 then
local r=result[1]
if r.login2 == false then
v.owner_nick = r.login
else
v.owner_nick = r.login2
end
else
if v.ownerid ~= false then
outputDebugString("B?ad domu ID domu#"..v.id)
end
v.owner_nick = "do wynaj?cia"
end
v.drzwi=split(v.drzwi,",")
for ii,vv in ipairs(v.drzwi) do v.drzwi[ii]=tonumber(vv) end
v.punkt_wyjscia=split(v.punkt_wyjscia,",")
for ii,vv in ipairs(v.punkt_wyjscia) do v.punkt_wyjscia[ii]=tonumber(vv) end
local pickupid=1272
if (not v.ownerid) then
pickupid=1273
end
v.wejscie=createPickup ( v.drzwi[1], v.drzwi[2], v.drzwi[3], 3, pickupid, 0)
v.cs=createColSphere(v.drzwi[1],v.drzwi[2],v.drzwi[3], 1)

if (not fast and v.ownerid) then
v.text=createElement("text")
setElementPosition(v.text, v.drzwi[1],v.drzwi[2],v.drzwi[3]+0.5)
setElementData(v.text,"text", (v.descr or "Dom").."\n"..v.owner_nick)
end
local interior_dimension=v.vwi or 1000+v.id
if v.lokator1 ~= "false" then
local lokator1db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?", v.lokator1)
if #lokator1db > 0 then
lokator1db=lokator1db[1]
if lokator1db.login2 then
lokator1=lokator1db.login2
else
lokator1=lokator1db.login
end
lokator1uid=lokator1db.id
else
lokator1=false
lokator1uid=false
end
end
if v.lokator2 ~= "false" then
local lokator2db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?", v.lokator2)
if #lokator2db > 0 then
lokator2db=lokator2db[1]
if lokator2db.login2 then
lokator2=lokator2db.login2
else
lokator2=lokator2db.login
end
lokator2uid=lokator2db.id
else
lokator2=false
lokator2uid=false
end
end
if v.lokator3 ~= "false" then
local lokator3db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?", v.lokator3)
if #lokator3db > 0 then
lokator3db=lokator3db[1]
if lokator3db.login2 then
lokator3=lokator3db.login2
else
lokator3=lokator3db.login
end
lokator3uid=lokator3db.id
else
lokator3=false
lokator3uid=false
end
end
setElementData(v.cs, "dom", {
["zamkniety"]=v.zamkniety>0 and true or false,
["id"]=v.id,
["koszt"]=v.koszt,
["ownerid"]=v.ownerid,
["owner_nick"]=v.owner_nick,
["descr"]=v.descr or "dom",
["dimension"]=interior_dimension,
["interior"]=interiory[v.interiorid].interior,
["interior_loc"]=interiory[v.interiorid].entrance,
["exit_loc"]=v.punkt_wyjscia,
["paidTo"]=v.paidTo,
["paidTo_dni"]=v.paidTo_dni,
["lokator1"]=lokator1,
["lokator1uid"]=lokator1uid,
["lokator2"]=lokator2,
["lokator2uid"]=lokator2uid,
["lokator3"]=lokator3,
["lokator3uid"]=lokator3uid,
})

v.wyjscie=createMarker(interiory[v.interiorid].exit[1], interiory[v.interiorid].exit[2], interiory[v.interiorid].exit[3], "arrow",1)
setElementDimension(v.wyjscie, interior_dimension)
setElementInterior(v.wyjscie, interiory[v.interiorid].interior)
setElementData(v.wyjscie,"tpto", v.punkt_wyjscia)

local dbid=v.id
v.id=nil
domy[dbid]=v

return true
end

function domyGetInfo(id)
return domy[id]
end

local function zaladujCzescDomow(procent,fast)
local tt=getTickCount()
i=0
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL")
local dbdomy
if fast then
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;")
else
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1;")
end
for __,v in ipairs(dbdomy) do
if math.random(0,100)<=procent then
if dodajDom(v,fast) then i=i+1 end
end
end
outputDebugString("Zaladowano domow: " .. i .. " w " .. (getTickCount()-tt) .. "ms")
end
addEventHandler("onResourceStart", resourceRoot, function()
zaladujCzescDomow(100,false)
end)

function zaladujZmienioneDomy()
local i=0
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1")
for __,v in ipairs(dbdomy) do

if dodajDom(v) then i=i+1 end
end
end

setTimer(zaladujZmienioneDomy, 10*1000, 0)

function domReload(id)
local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?", id)
if dbdom then
for i,v in ipairs(dbdom) do
return dodajDom(v)
end
end
return false
end

addEvent ( "SprawdzDom", true )
function SprawdzDom ( gracz )
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;")
for __,v in ipairs(dbdomy) do
local uid=tonumber(getElementData(gracz,"player:sid"))
local r=v.ownerid
v.drzwi=split(v.drzwi,",")
for ii,vv in ipairs(v.drzwi) do v.drzwi[ii]=tonumber(vv) end
if r then if r == uid then
setElementData(gracz,"player:house",true)
tak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]})
setElementData(gracz,"player:spawn",tak)
end end
end
for __,v in ipairs(dbdomy) do
local uid=tonumber(getElementData(gracz,"player:sid"))
v.drzwi=split(v.drzwi,",")
for ii,vv in ipairs(v.drzwi) do v.drzwi[ii]=tonumber(vv) end
setElementData(gracz,"player:house",true)
tak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]})
setElementData(gracz,"player:spawn",tak)
end
end
addEventHandler ( "SprawdzDom", root, SprawdzDom )

function kupdom(czas,domid)
local kasa=client:getMoney()
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?", domid)
if #q < 1 then
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0)
return
end
q=q[1]
if q.ownerid then
client:outputChat("Ten dom ma ju? w?a?ciciela!", 255, 0, 0)
return
end
koszt=q.koszt*czas
if kasa < koszt then
client:outputChat("Nie sta? Ci? na kupno tego domu! ("..koszt.." PLN)", 255, 0, 0)
return
end
takePlayerMoney(client, koszt)
exports["pystories-db"]:dbSet("update lss_domy set ownerid=?, paidTo=NOW()+INTERVAL ? DAY, lokator1=NULL, lokator2=NULL, lokator3=NULL where id=?", client:getData("player:sid"), czas, domid)
domReload(domid)
client:outputChat("Pomy?lnie zakupi?e? dom, pobrano z konta "..koszt.." PLN!", 0, 255, 0)
end
addEvent("DOMY:kup", true)
addEventHandler("DOMY:kup", root, kupdom)

function oplacdom(czas,domid)
local kasa=client:getMoney()
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?", domid)
if #q < 1 then
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0)
return
end
q=q[1]
if q.ownerid ~= client:getData("player:sid") then
client:outputChat("To nie jest tw?j dom!", 255, 0, 0)
return
end
koszt=q.koszt*czas
if kasa < koszt then
client:outputChat("Nie sta? Ci? na op?acenie tego domu! ("..koszt.." PLN)", 255, 0, 0)
return
end
takePlayerMoney(client, koszt)
exports["pystories-db"]:dbSet("update lss_domy set paidTo=paidTo+INTERVAL ? DAY where id=?", czas, domid)
domReload(domid)
client:outputChat("Pomy?lnie op?aci?e? dom na "..czas.." dni, pobrano z konta "..koszt.." PLN!", 0, 255, 0)
end
addEvent("DOMY:oplac", true)
addEventHandler("DOMY:oplac", root, oplacdom)

function dodajlokator(uid,domid)
local q2=exports["pystories-db"]:dbSet("select id from pystories_users where id=?", uid)
if #q2> 0 then
q=exports["pystories-db"]:dbSet("select lokator1,lokator2,lokator3 from lss_domy where id=?", domid)
if #q < 1 then client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0) return end
q=q[1]
if q.lokator1 and q.lokator2 and q.lokator3 then client:outputChat("Osi?gni?to limit 3 lokator?w na dom!", 255, 0, 0) return end
if not q.lokator1 then
exports["pystories-db"]:dbSet("update lss_domy set lokator1=? where id=?", uid, domid)
domReload(domid)
client:outputChat("Dodano nowego lokatora do domu.", 0, 255, 0)
return
end
if not q.lokator2 then
exports["pystories-db"]:dbSet("update lss_domy set lokator2=? where id=?", uid, domid)
domReload(domid)
client:outputChat("Dodano nowego lokatora do domu.", 0, 255, 0)
return
end
if not q.lokator3 then
exports["pystories-db"]:dbSet("update lss_domy set lokator3=? where id=?", uid, domid)
domReload(domid)
client:outputChat("Dodano nowego lokatora do domu.", 0, 255, 0)
return
end
else
client:outputChat("Nie ma konta z takim UID!", 255, 0, 0)
end
end
addEvent("DOM:lokator+", true)
addEventHandler("DOM:lokator+", root, dodajlokator)

function usunlokator(id,domid)
if id == 1 then
exports["pystories-db"]:dbSet("update lss_domy set lokator1=NULL where id=?", domid)
client:outputChat("Pomy?lnie usuni?to lokatora.", 0, 255, 0)
local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?", domid)
for i,v in ipairs(dbdom) do
dodajDom(v)
end
elseif id == 2 then
exports["pystories-db"]:dbSet("update lss_domy set lokator2=NULL where id=?", domid)
client:outputChat("Pomy?lnie usuni?to lokatora.", 0, 255, 0)
local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?", domid)
for i,v in ipairs(dbdom) do
dodajDom(v)
end
elseif id == 3 then
exports["pystories-db"]:dbSet("update lss_domy set lokator3=NULL where id=?", domid)
client:outputChat("Pomy?lnie usuni?to lokatora.", 0, 255, 0)
local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?", domid)
for i,v in ipairs(dbdom) do
dodajDom(v)
end
end
end
addEvent("DOM:lokator-", true)
addEventHandler("DOM:lokator-", root, usunlokator)

function zwolnijdom(domid)
exports["pystories-db"]:dbSet("update lss_domy set paidTo='2000-01-01 00:00:00' where id=?", domid)
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL")
domReload(domid)
client:outputChat("Pomy?lnie zwolniono dom.", 0, 255, 0)
end
addEvent("DOM:zwolnij", true)
addEventHandler("DOM:zwolnij", root, zwolnijdom)

addCommandHandler("mieszkanie",function(plr,cmd)
if exports['pystories-admins']:getAdmin(plr,4) then
local x,y,z = getElementPosition(plr)
local stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Mieszkanie", 0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),8,500000,1)
local q,_,id=exports["pystories-db"]:dbSet(stringe)
domReload(id)
end
end)

addCommandHandler("dom",function(plr,cmd)
if exports['pystories-admins']:getAdmin(plr,4) then
local x,y,z = getElementPosition(plr)
local stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Dom", 0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),221,500000,1)
local q,_,id=exports["pystories-db"]:dbSet(stringe)
domReload(id)
end
end)

addCommandHandler("willa",function(plr,cmd)
if exports['pystories-admins']:getAdmin(plr,4) then
local x,y,z = getElementPosition(plr)
local stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Willa", 0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),27,1000000,1)
local q,_,id=exports["pystories-db"]:dbSet(stringe)
domReload(id)
end
end)


domy_c.lua
Kod:

mojeW,mojeH = 1366, 768
sW,sH = guiGetScreenSize()
w, h = (sW/mojeW), (sH/mojeH)
sx,sy=guiGetScreenSize()
local dxfont0_1 = dxCreateFont(":dG-Fonty/1.ttf", 10)

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 dom=nil

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

function render()
if kupywanie then
dxDrawImage(189*w, 165*h, 583*w, 377*h, ":pystories-domy/kupno.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
if dom.ownerid then
dxDrawText("Op?acanie domu", 207*w, 281*h, 400*w, 299*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("OP?A?", 240*w, 461*h, 367*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
else
dxDrawText("Kupywanie domu", 207*w, 281*h, 400*w, 299*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("KUP", 240*w, 461*h, 367*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
end
dxDrawText("Koszt:", 252*w, 394*h, 357*w, 414*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("Czas wynajecia: ", 208*w, 321*h, 400*w, 340*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "top", false, false, false, false, false)
if isElement(editcost) then
cost=guiGetText(edittime)
if not tonumber(cost) then
cost=0
end
if string.len(tostring(cost)) < 1 then
cost=0
end
if tonumber(cost) < 1 then
cost=0
end
sscost=cost*dom.koszt
guiSetText(editcost, sscost.." PLN")
end
end
if not editing then

dxDrawImage(404*w, 208*h, 565*w, 347*h, ":pystories-domy/dom.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("Zarz?dzanie domem (ID: "..dom.id..")", 408*w, 281*h, 958*w, 298*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawRectangle(796*w, 435*h, 152*w, 42*h, tocolor(0, 0, 0, 200), false)
dxDrawText("Zamknij", 797*w, 435*h, 948*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawRectangle(606*w, 435*h, 152*w, 42*h, tocolor(0, 0, 0, 200), false)
dxDrawRectangle(419*w, 435*h, 152*w, 42*h, tocolor(0, 0, 0, 200), false)
if dom.ownerid then
dxDrawRectangle(434*w, 408*h, 127*w, 16*h, tocolor(0, 0, 0, 200), false)
dxDrawRectangle(618*w, 408*h, 127*w, 16*h, tocolor(0, 0, 0, 200), false)
dxDrawRectangle(808*w, 408*h, 127*w, 16*h, tocolor(0, 0, 0, 200), false)
dxDrawText("Zwolnij dom", 997*w, 407*h, 745*w, 424*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("Lokatorzy", 617*w, 407*h, 745*w, 424*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("Wejd?", 420*w, 435*h, 571*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("Op?a? dom", 607*w, 435*h, 758*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
if not dom.zamkniety then
dxDrawText("Zamknij dom", 433*w, 408*h, 559*w, 425*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
else
dxDrawText("Otw?rz dom", 433*w, 408*h, 559*w, 425*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
end
else
dxDrawText("Kup dom", 607*w, 435*h, 758*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("Zobacz dom", 420*w, 435*h, 571*w, 477*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
end
if dom.paidTo then
oplacony="Dom jest op?acony do "..dom.paidTo.." ("..dom.paidTo_dni.." dni)"
else
oplacony="Dom jest op?acony do - - (0 dni)."
end
dxDrawText("Koszt jednej doby wynosi: "..dom.koszt.." PLN\nW?a?ciciel: "..(dom.owner_nick or "do wynaj?cia").."\n"..oplacony.."", 434*w, 329*h, 933*w, 380*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
if isMouseIn(419*w, 435*h, 152*w, 42*h) then
dxDrawRectangle(420*w, 477*h, 151*w, 2*h, tocolor(255,79,10), false)
else
dxDrawRectangle(420*w, 477*h, 151*w, 2*h, tocolor(255, 255, 255, 200), false)
end
if isMouseIn(606*w, 435*h, 152*w, 42*h) then
dxDrawRectangle(607*w, 477*h, 151*w, 2*h, tocolor(255,79,10), false)
else
dxDrawRectangle(607*w, 477*h, 151*w, 2*h, tocolor(255, 255, 255, 200), false)
end
if isMouseIn(796*w, 435*h, 152*w, 42*h) then
dxDrawRectangle(797*w, 477*h, 151*w, 2*h, tocolor(255,79,10), false)
else
dxDrawRectangle(797*w, 477*h, 151*w, 2*h, tocolor(255, 255, 255, 200), false)
end
else
dxDrawRectangle(572*w, 260*h, 223*w, 215*h, tocolor(255,79,10), false)
dxDrawText("Lokatorzy", 572*w, 260*h, 795*w, 278*h, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
dxDrawText("1: "..(dom.lokator1 or "brak").."\n2: "..(dom.lokator2 or "brak").."\n3: "..(dom.lokator3 or "brak").."\nAby usun?? lokatora podaj numer\nwymieniony wy?ej, natomiast je?li\nchcesz doda? lokatora podaj jego sid", 573, 279, 795, 370, tocolor(255, 255, 255, 255), 1.00, dxfont0_1, "center", "center", false, false, false, false, false)
if isElement(edit) then
local text=guiGetText(edit)
guiSetText(edit, string.gsub(text, '[^0-9]', '' ))
end
end
end

addEventHandler("onClientColShapeHit", resourceRoot, function(el,md)
if el~=localPlayer or not md then return end
if getElementType(el) == "player" and not getPedOccupiedVehicle(el) then
local dom2=getElementData(source,"dom")
if not dom2 then return end
if dom then return end
dom=dom2
addEventHandler("onClientRender", root, render)
addEventHandler("onClientClick", root, click)
showCursor(true)
kupywanie=false
editing=false
end
end)

function czyGraczJestLokatorem()
if dom then
if dom.lokator1sid==localPlayer:getData("player:sid") or dom.lokator2sid==localPlayer:getData("player:sid") or dom.lokator3sid==localPlayer:getData("player:sid") then
return true
else
return false
end
end
end

function click(btn,state)
if btn=="left" and state=="down" then
if isMouseIn(419*w, 435*h, 152*w, 42*h) then
domWejscie()
elseif isMouseIn(796*w, 435*h, 152*w, 42*h) and not editing then
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
elseif isMouseIn(606*w, 435*h, 152*w, 42*h) and not editing then
if isElement(editcost) then
editcost:destroy()
edittime:destroy()
kupywanie=false
else
editcost = GuiEdit(250*w, 419*h, 107*w, 20*h, "0 PLN", false)
guiEditSetReadOnly(editcost, true)
edittime = GuiEdit(250*w, 350*h, 107*w, 20*h, "", false)
guiEditSetMaxLength(edittime, 2)
kupywanie=true
end
elseif isMouseIn(240*w, 461*h, 127*w, 16*h) and kupywanie and dom and not dom.ownerid and not editing then
triggerEvent('onClientAddNotification', localPlayer, 'Dom musi by? op?acony za minimum 1 PLN', 'info')
triggerServerEvent("DOMY:kup", localPlayer, guiGetText(edittime), dom.id)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
editcost:destroy()
edittime:destroy()
kupywanie=false
elseif isMouseIn(240*w, 461*h, 127*w, 16*h) and kupywanie and dom and dom.ownerid and not editing then
if dom.ownerid ~= localPlayer:getData("player:sid") then
triggerEvent('onClientAddNotification', localPlayer, 'Brak uprawnien!', 'info')
return
end
--triggerEvent('onClientAddNotification', localPlayer, 'Koszt domu nie mo?e by? mniejszy ni? 1 PLN', 'info')
triggerServerEvent("DOMY:oplac", localPlayer, guiGetText(edittime), dom.id)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
editcost:destroy()
edittime:destroy()
kupywanie=false
elseif isMouseIn(434*w, 408*h, 127*w, 16*h) and dom.ownerid and not editing then
if dom.ownerid ~= localPlayer:getData("player:sid") and not czyGraczJestLokatorem() then
triggerEvent('onClientAddNotification', localPlayer, 'Brak uprawnien!', 'info')
return
end
triggerServerEvent("onHouseChangeOptions", resourceRoot, dom.id, "zamkniety", not dom.zamkniety)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
elseif isMouseIn(808*w, 408*h, 127*w, 16*h) and dom.ownerid and not editing then
if dom.ownerid ~= localPlayer:getData("player:sid") then
triggerEvent('onClientAddNotification', localPlayer, 'Brak uprawnien!', 'info')
return
end
triggerServerEvent("DOM:zwolnij", localPlayer, dom.id)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
elseif isMouseIn(618*w, 408*h, 127*w, 16*h) and not editing and dom.ownerid then
if dom.ownerid ~= localPlayer:getData("player:sid") then
triggerEvent('onClientAddNotification', localPlayer, 'Brak uprawnien!', 'info')
return
end
editing=true
kupywanie=false
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
btn1 = GuiButton(589*w, 391*h, 41*w, 30*h, "Dodaj", false)
btn2 = GuiButton(739*w, 391*h, 41*w, 30*h, "Usu?", false)
btn3 = GuiButton(642*w, 443*h, 87*w, 25*h, "Powr?t", false)
edit = GuiEdit(640*w, 395*h, 89*w, 20*h, "", false)
addEventHandler("onClientGUIClick", btn3, function(btn)
if btn=="left" then
editing=false
btn1:destroy()
btn2:destroy()
btn3:destroy()
edit:destroy()
end
end)
addEventHandler("onClientGUIClick", btn1, function(btn)
if btn=="left" then
local text=guiGetText(edit)
if not tonumber(text) then return end
if dom.lokator1sid == text or dom.lokator2sid == text or dom.lokator3sid == text then
triggerEvent('onClientAddNotification', localPlayer, 'Jest juz zapisany ten lokator!', 'info')
return
end
if tonumber(text) == tonumber(localPlayer:getData("player:sid")) then
triggerEvent('onClientAddNotification', localPlayer, 'Nie mozesz dodac siebie!', 'info')
return
end
triggerServerEvent("DOM:lokator+", localPlayer, text, dom.id)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
end
end)
addEventHandler("onClientGUIClick", btn2, function(btn)
if btn=="left" then
local text=guiGetText(edit)
if not tonumber(text) then return end
if tonumber(text) ~= 1 and tonumber(text) ~= 2 and tonumber(text) ~= 3 then exports.noti:showBox("info","Musisz wybra? lokatora!") return end
triggerServerEvent("DOM:lokator-", localPlayer, tonumber(text), dom.id)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
end
end)
end
end
end

addEventHandler("onClientColShapeLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
if dom ~= nil then
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
dom=nil
editing=false
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
end
end)

function domWejscie()
if not dom then return end
local dbid=dbid(localPlayer)
removeEventHandler("onClientRender", root, render)
removeEventHandler("onClientClick", root, click)
showCursor(false)
if isElement(editcost) then
editcost:destroy()
end
if isElement(edittime) then
edittime:destroy()
end
if isElement(btn1) then
btn1:destroy()
end
if isElement(btn2) then
btn2:destroy()
end
if isElement(btn3) then
btn3:destroy()
end
if isElement(edit) then
edit:destroy()
end
kupywanie=false
if not dom.ownerid then
ad=dom
triggerServerEvent("moveMeTo", resourceRoot, dom.interior_loc[1], dom.interior_loc[2], dom.interior_loc[3], dom.interior, dom.dimension)
setTimer(function(d,p)
if (getElementDimension(localPlayer)==d) then
triggerServerEvent("moveMeTo", resourceRoot, p[1], p[2], p[3], 0,0)
end
end, 30000,1,ad.dimension, ad.exit_loc)
elseif not dom.zamkniety or dom.ownerid==dbid or czyGraczJestLokatorem() then
triggerServerEvent("moveMeTo", resourceRoot, dom.interior_loc[1], dom.interior_loc[2], dom.interior_loc[3], dom.interior, dom.dimension)

elseif dom.zamkniety then
triggerEvent("onAnnouncement3",root,"Zamkni?te", 3)
end
dom=nil
end

local function domOpcje()
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-03, 00:24


PatryKK.

Emeryt LUA






Wiek: 26
Na forum: 3061 dni
Posty: 1060
Nick w MP: PatryKK.

Piwa: 2322

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

B??dy db3?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-03, 00:40


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

Musisz doda? ifa kt?ry sprawdzi czy podane dni s? wi?ksze od 0

przyk?ad:



local wpisane_dni 1
if wpisane_dni 0 then
   -- kup dom
   else
    -- nppowiadom ?e nie mo?na zakupidomku
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-03, 00:59


StifMaster







Wiek: 30
Na forum: 3525 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

"PatryKK." napisał/a:

B??dy db3?
Nie pokazuje si? ?aden b??d w DB3

[ Dodano: 2020-07-03, 01:06 ]
"Szypki_exe" napisał/a:

Musisz doda? ifa kt?ry sprawdzi czy podane dni s? wi?ksze od 0

przyk?ad:



local wpisane_dni 1
if wpisane_dni 0 then
   -- kup dom
   else
    -- nppowiadom ?e nie mo?na zakupidomku
end
Podczas gdy to dodam wyskakuje b??d w DB3. Czy m?g?by? zrobi? gotowca? Zimny :piwo: poleci :) .

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-03, 01:29


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150



domy={} 
local function usunDom(id) 
if isElement(domy[id].wyjsciethen destroyElement(domy[id].wyjscieend 
if isElement(domy[id].wejsciethen destroyElement(domy[id].wejscieend 
if isElement(domy[id].csthen destroyElement(domy[id].csend 
if isElement(domy[id].textthen destroyElement(domy[id].textend 
domy[id]=nil 
end 

function dodajDom(v,fast) 

if not interiory[v.interioridthen return false end 
if domy[v.idthen 
usunDom(v.idend 
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"v.ownerid) 
if result and #result > 0 then 
local r=result[1] 
if r.login2 == false then 
v.owner_nick r.login 
else 
v.owner_nick r.login2 
end 
else 
if v.ownerid ~= false then 
outputDebugString("B?ad domu ID domu#"..v.idend 
v.owner_nick "do wynaj?cia" 
end 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
v.punkt_wyjscia=split(v.punkt_wyjscia,",") 
for ii,vv in ipairs(v.punkt_wyjscia) do    v.punkt_wyjscia[ii]=tonumber(vv)    end 
local pickupid=1272 
if (not v.owneridthen 
pickupid=1273 
end 
v.wejscie=createPickup v.drzwi[1], v.drzwi[2], v.drzwi[3], 3pickupid0v.cs=createColSphere(v.drzwi[1],v.drzwi[2],v.drzwi[3], 1) 

if (not fast and v.owneridthen 
v.text=createElement("text"setElementPosition(v.textv.drzwi[1],v.drzwi[2],v.drzwi[3]+0.5setElementData(v.text,"text", (v.descr or "Dom").."\n"..v.owner_nickend 
local interior_dimension=v.vwi or 1000+v.id 
if v.lokator1 ~= "false" then 
local lokator1db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator1) 
if #lokator1db > 0 then 
lokator1db=lokator1db[1] 
if lokator1db.login2 then 
lokator1=lokator1db.login2 
else 
lokator1=lokator1db.login 
end 
lokator1uid=lokator1db.id 
else 
lokator1=false 
lokator1uid=false 
end 
end 
if v.lokator2 ~= "false" then 
local lokator2db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator2) 
if #lokator2db > 0 then 
lokator2db=lokator2db[1] 
if lokator2db.login2 then 
lokator2=lokator2db.login2 
else 
lokator2=lokator2db.login 
end 
lokator2uid=lokator2db.id 
else 
lokator2=false 
lokator2uid=false 
end 
end 
if v.lokator3 ~= "false" then 
local lokator3db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator3) 
if #lokator3db > 0 then 
lokator3db=lokator3db[1] 
if lokator3db.login2 then 
lokator3=lokator3db.login2 
else 
lokator3=lokator3db.login 
end 
lokator3uid=lokator3db.id 
else 
lokator3=false 
lokator3uid=false 
end    
end 
setElementData(v.cs"dom", { 
["zamkniety"]=v.zamkniety>and true or false, 
["id"]=v.id, 
["koszt"]=v.koszt, 
["ownerid"]=v.ownerid, 
["owner_nick"]=v.owner_nick, 
["descr"]=v.descr or "dom", 
["dimension"]=interior_dimension, 
["interior"]=interiory[v.interiorid].interior, 
["interior_loc"]=interiory[v.interiorid].entrance, 
["exit_loc"]=v.punkt_wyjscia, 
["paidTo"]=v.paidTo, 
["paidTo_dni"]=v.paidTo_dni, 
["lokator1"]=lokator1, 
["lokator1uid"]=lokator1uid, 
["lokator2"]=lokator2, 
["lokator2uid"]=lokator2uid, 
["lokator3"]=lokator3, 
["lokator3uid"]=lokator3uid, 
}) 

v.wyjscie=createMarker(interiory[v.interiorid].exit[1], interiory[v.interiorid].exit[2], interiory[v.interiorid].exit[3], "arrow",1setElementDimension(v.wyjscieinterior_dimensionsetElementInterior(v.wyjscieinteriory[v.interiorid].interiorsetElementData(v.wyjscie,"tpto"v.punkt_wyjscialocal dbid=v.id 
v.id=nil 
domy[dbid]=return true 
end 

function domyGetInfo(id) 
return domy[idend 

local function zaladujCzescDomow(procent,fastlocal tt=getTickCount() 
i=0 
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"local dbdomy 
if fast then 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
else 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1;"end 
for __,v in ipairs(dbdomy) do 
if math.random(0,100)<=procent then 
if dodajDom(v,fastthen i=i+1 end 
end 
end 
outputDebugString("Zaladowano domow: " .. .. " w " .. (getTickCount()-tt) .. "ms"end 
addEventHandler("onResourceStart"resourceRoot, function() 
zaladujCzescDomow(100,falseend) 

function zaladujZmienioneDomy() 
local i=0 
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1") 
for __,v in ipairs(dbdomy) do 

if dodajDom(vthen i=i+1 end 
end 
end 

setTimer(zaladujZmienioneDomy10*10000) 

function domReload(idlocal dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"id) 
if dbdom then 
for i,v in ipairs(dbdom) do 
return dodajDom(vend 
end 
return false 
end 

addEvent "SprawdzDom"true ) 
function SprawdzDom gracz local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
local r=v.ownerid 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
if r then if == uid then 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend end 
end 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend 
end 
addEventHandler "SprawdzDom"rootSprawdzDom ) 

function kupdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
q=q[1] 
if q.ownerid then 
client:outputChat("Ten dom ma ju? w?a?ciciela!"25500) 
return 
end 
if czas 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na kupno tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set ownerid=?, paidTo=NOW()+INTERVAL ? DAY, lokator1=NULL, lokator2=NULL, lokator3=NULL where id=?"client:getData("player:sid"), czasdomiddomReload(domidclient:outputChat("Pomy?lnie zakupi?e? dom, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:kup"trueaddEventHandler("DOMY:kup"rootkupdom) 

function oplacdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
if czas 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
q=q[1]
if q.ownerid ~= client:getData("player:sid"then 
client:outputChat("To nie jest tw?j dom!"25500) 
return 
end 
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na op?acenie tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set paidTo=paidTo+INTERVAL ? DAY where id=?"czasdomiddomReload(domidclient:outputChat("Pomy?lnie op?aci?e? dom na "..czas.." dni, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:oplac"trueaddEventHandler("DOMY:oplac"rootoplacdom) 

function dodajlokator(uid,domidlocal q2=exports["pystories-db"]:dbSet("select id from pystories_users where id=?"uid) 
if #q2> 0 then 
q=exports["pystories-db"]:dbSet("select lokator1,lokator2,lokator3 from lss_domy where id=?"domid) 
if #q < 1 then client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0) return end 
q=q[1] 
if q.lokator1 and q.lokator2 and q.lokator3 then client:outputChat("Osi?gni?to limit 3 lokator?w na dom!"25500) return end 
if not q.lokator1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
else 
client:outputChat("Nie ma konta z takim UID!"25500end 
end 
addEvent("DOM:lokator+"trueaddEventHandler("DOM:lokator+"rootdodajlokator) 

function usunlokator(id,domid) 
if id == 1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
end 
end 
addEvent("DOM:lokator-"trueaddEventHandler("DOM:lokator-"rootusunlokator) 

function zwolnijdom(domidexports["pystories-db"]:dbSet("update lss_domy set paidTo='2000-01-01 00:00:00' where id=?"domidexports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"domReload(domidclient:outputChat("Pomy?lnie zwolniono dom."02550end 
addEvent("DOM:zwolnij"trueaddEventHandler("DOM:zwolnij"rootzwolnijdomaddCommandHandler("mieszkanie",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Mieszkanie"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),8,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("dom",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Dom"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),221,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("willa",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Willa"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),27,1000000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
end)


linie: 209, 233
Tam masz przyk?ad jak na przysz?o?? to wykonywa?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
StifMaster
Wysłany: 2020-07-03, 02:04


StifMaster







Wiek: 30
Na forum: 3525 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

"Szypki_exe" napisał/a:



domy={} 
local function usunDom(id) 
if isElement(domy[id].wyjsciethen destroyElement(domy[id].wyjscieend 
if isElement(domy[id].wejsciethen destroyElement(domy[id].wejscieend 
if isElement(domy[id].csthen destroyElement(domy[id].csend 
if isElement(domy[id].textthen destroyElement(domy[id].textend 
domy[id]=nil 
end 

function dodajDom(v,fast) 

if not interiory[v.interioridthen return false end 
if domy[v.idthen 
usunDom(v.idend 
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"v.ownerid) 
if result and #result > 0 then 
local r=result[1] 
if r.login2 == false then 
v.owner_nick r.login 
else 
v.owner_nick r.login2 
end 
else 
if v.ownerid ~= false then 
outputDebugString("B?ad domu ID domu#"..v.idend 
v.owner_nick "do wynaj?cia" 
end 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
v.punkt_wyjscia=split(v.punkt_wyjscia,",") 
for ii,vv in ipairs(v.punkt_wyjscia) do    v.punkt_wyjscia[ii]=tonumber(vv)    end 
local pickupid=1272 
if (not v.owneridthen 
pickupid=1273 
end 
v.wejscie=createPickup v.drzwi[1], v.drzwi[2], v.drzwi[3], 3pickupid0v.cs=createColSphere(v.drzwi[1],v.drzwi[2],v.drzwi[3], 1) 

if (not fast and v.owneridthen 
v.text=createElement("text"setElementPosition(v.textv.drzwi[1],v.drzwi[2],v.drzwi[3]+0.5setElementData(v.text,"text", (v.descr or "Dom").."\n"..v.owner_nickend 
local interior_dimension=v.vwi or 1000+v.id 
if v.lokator1 ~= "false" then 
local lokator1db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator1) 
if #lokator1db > 0 then 
lokator1db=lokator1db[1] 
if lokator1db.login2 then 
lokator1=lokator1db.login2 
else 
lokator1=lokator1db.login 
end 
lokator1uid=lokator1db.id 
else 
lokator1=false 
lokator1uid=false 
end 
end 
if v.lokator2 ~= "false" then 
local lokator2db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator2) 
if #lokator2db > 0 then 
lokator2db=lokator2db[1] 
if lokator2db.login2 then 
lokator2=lokator2db.login2 
else 
lokator2=lokator2db.login 
end 
lokator2uid=lokator2db.id 
else 
lokator2=false 
lokator2uid=false 
end 
end 
if v.lokator3 ~= "false" then 
local lokator3db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator3) 
if #lokator3db > 0 then 
lokator3db=lokator3db[1] 
if lokator3db.login2 then 
lokator3=lokator3db.login2 
else 
lokator3=lokator3db.login 
end 
lokator3uid=lokator3db.id 
else 
lokator3=false 
lokator3uid=false 
end    
end 
setElementData(v.cs"dom", { 
["zamkniety"]=v.zamkniety>and true or false, 
["id"]=v.id, 
["koszt"]=v.koszt, 
["ownerid"]=v.ownerid, 
["owner_nick"]=v.owner_nick, 
["descr"]=v.descr or "dom", 
["dimension"]=interior_dimension, 
["interior"]=interiory[v.interiorid].interior, 
["interior_loc"]=interiory[v.interiorid].entrance, 
["exit_loc"]=v.punkt_wyjscia, 
["paidTo"]=v.paidTo, 
["paidTo_dni"]=v.paidTo_dni, 
["lokator1"]=lokator1, 
["lokator1uid"]=lokator1uid, 
["lokator2"]=lokator2, 
["lokator2uid"]=lokator2uid, 
["lokator3"]=lokator3, 
["lokator3uid"]=lokator3uid, 
}) 

v.wyjscie=createMarker(interiory[v.interiorid].exit[1], interiory[v.interiorid].exit[2], interiory[v.interiorid].exit[3], "arrow",1setElementDimension(v.wyjscieinterior_dimensionsetElementInterior(v.wyjscieinteriory[v.interiorid].interiorsetElementData(v.wyjscie,"tpto"v.punkt_wyjscialocal dbid=v.id 
v.id=nil 
domy[dbid]=return true 
end 

function domyGetInfo(id) 
return domy[idend 

local function zaladujCzescDomow(procent,fastlocal tt=getTickCount() 
i=0 
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"local dbdomy 
if fast then 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
else 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1;"end 
for __,v in ipairs(dbdomy) do 
if math.random(0,100)<=procent then 
if dodajDom(v,fastthen i=i+1 end 
end 
end 
outputDebugString("Zaladowano domow: " .. .. " w " .. (getTickCount()-tt) .. "ms"end 
addEventHandler("onResourceStart"resourceRoot, function() 
zaladujCzescDomow(100,falseend) 

function zaladujZmienioneDomy() 
local i=0 
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1") 
for __,v in ipairs(dbdomy) do 

if dodajDom(vthen i=i+1 end 
end 
end 

setTimer(zaladujZmienioneDomy10*10000) 

function domReload(idlocal dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"id) 
if dbdom then 
for i,v in ipairs(dbdom) do 
return dodajDom(vend 
end 
return false 
end 

addEvent "SprawdzDom"true ) 
function SprawdzDom gracz local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
local r=v.ownerid 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
if r then if == uid then 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend end 
end 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend 
end 
addEventHandler "SprawdzDom"rootSprawdzDom ) 

function kupdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
q=q[1] 
if q.ownerid then 
client:outputChat("Ten dom ma ju? w?a?ciciela!"25500) 
return 
end 
if czas 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na kupno tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set ownerid=?, paidTo=NOW()+INTERVAL ? DAY, lokator1=NULL, lokator2=NULL, lokator3=NULL where id=?"client:getData("player:sid"), czasdomiddomReload(domidclient:outputChat("Pomy?lnie zakupi?e? dom, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:kup"trueaddEventHandler("DOMY:kup"rootkupdom) 

function oplacdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
if czas 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
q=q[1]
if q.ownerid ~= client:getData("player:sid"then 
client:outputChat("To nie jest tw?j dom!"25500) 
return 
end 
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na op?acenie tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set paidTo=paidTo+INTERVAL ? DAY where id=?"czasdomiddomReload(domidclient:outputChat("Pomy?lnie op?aci?e? dom na "..czas.." dni, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:oplac"trueaddEventHandler("DOMY:oplac"rootoplacdom) 

function dodajlokator(uid,domidlocal q2=exports["pystories-db"]:dbSet("select id from pystories_users where id=?"uid) 
if #q2> 0 then 
q=exports["pystories-db"]:dbSet("select lokator1,lokator2,lokator3 from lss_domy where id=?"domid) 
if #q < 1 then client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0) return end 
q=q[1] 
if q.lokator1 and q.lokator2 and q.lokator3 then client:outputChat("Osi?gni?to limit 3 lokator?w na dom!"25500) return end 
if not q.lokator1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
else 
client:outputChat("Nie ma konta z takim UID!"25500end 
end 
addEvent("DOM:lokator+"trueaddEventHandler("DOM:lokator+"rootdodajlokator) 

function usunlokator(id,domid) 
if id == 1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
end 
end 
addEvent("DOM:lokator-"trueaddEventHandler("DOM:lokator-"rootusunlokator) 

function zwolnijdom(domidexports["pystories-db"]:dbSet("update lss_domy set paidTo='2000-01-01 00:00:00' where id=?"domidexports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"domReload(domidclient:outputChat("Pomy?lnie zwolniono dom."02550end 
addEvent("DOM:zwolnij"trueaddEventHandler("DOM:zwolnij"rootzwolnijdomaddCommandHandler("mieszkanie",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Mieszkanie"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),8,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("dom",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Dom"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),221,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("willa",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Willa"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),27,1000000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
end)


linie: 209, 233
Tam masz przyk?ad jak na przysz?o?? to wykonywa?
B??d w DB3 domy.lua:208: attempt to compare string with number

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-03, 02:12


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150



domy={} 
local function usunDom(id) 
if isElement(domy[id].wyjsciethen destroyElement(domy[id].wyjscieend 
if isElement(domy[id].wejsciethen destroyElement(domy[id].wejscieend 
if isElement(domy[id].csthen destroyElement(domy[id].csend 
if isElement(domy[id].textthen destroyElement(domy[id].textend 
domy[id]=nil 
end 

function dodajDom(v,fast) 

if not interiory[v.interioridthen return false end 
if domy[v.idthen 
usunDom(v.idend 
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"v.ownerid) 
if result and #result > 0 then 
local r=result[1] 
if r.login2 == false then 
v.owner_nick r.login 
else 
v.owner_nick r.login2 
end 
else 
if v.ownerid ~= false then 
outputDebugString("B?ad domu ID domu#"..v.idend 
v.owner_nick "do wynaj?cia" 
end 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
v.punkt_wyjscia=split(v.punkt_wyjscia,",") 
for ii,vv in ipairs(v.punkt_wyjscia) do    v.punkt_wyjscia[ii]=tonumber(vv)    end 
local pickupid=1272 
if (not v.owneridthen 
pickupid=1273 
end 
v.wejscie=createPickup v.drzwi[1], v.drzwi[2], v.drzwi[3], 3pickupid0v.cs=createColSphere(v.drzwi[1],v.drzwi[2],v.drzwi[3], 1) 

if (not fast and v.owneridthen 
v.text=createElement("text"setElementPosition(v.textv.drzwi[1],v.drzwi[2],v.drzwi[3]+0.5setElementData(v.text,"text", (v.descr or "Dom").."\n"..v.owner_nickend 
local interior_dimension=v.vwi or 1000+v.id 
if v.lokator1 ~= "false" then 
local lokator1db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator1) 
if #lokator1db > 0 then 
lokator1db=lokator1db[1] 
if lokator1db.login2 then 
lokator1=lokator1db.login2 
else 
lokator1=lokator1db.login 
end 
lokator1uid=lokator1db.id 
else 
lokator1=false 
lokator1uid=false 
end 
end 
if v.lokator2 ~= "false" then 
local lokator2db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator2) 
if #lokator2db > 0 then 
lokator2db=lokator2db[1] 
if lokator2db.login2 then 
lokator2=lokator2db.login2 
else 
lokator2=lokator2db.login 
end 
lokator2uid=lokator2db.id 
else 
lokator2=false 
lokator2uid=false 
end 
end 
if v.lokator3 ~= "false" then 
local lokator3db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator3) 
if #lokator3db > 0 then 
lokator3db=lokator3db[1] 
if lokator3db.login2 then 
lokator3=lokator3db.login2 
else 
lokator3=lokator3db.login 
end 
lokator3uid=lokator3db.id 
else 
lokator3=false 
lokator3uid=false 
end    
end 
setElementData(v.cs"dom", { 
["zamkniety"]=v.zamkniety>and true or false, 
["id"]=v.id, 
["koszt"]=v.koszt, 
["ownerid"]=v.ownerid, 
["owner_nick"]=v.owner_nick, 
["descr"]=v.descr or "dom", 
["dimension"]=interior_dimension, 
["interior"]=interiory[v.interiorid].interior, 
["interior_loc"]=interiory[v.interiorid].entrance, 
["exit_loc"]=v.punkt_wyjscia, 
["paidTo"]=v.paidTo, 
["paidTo_dni"]=v.paidTo_dni, 
["lokator1"]=lokator1, 
["lokator1uid"]=lokator1uid, 
["lokator2"]=lokator2, 
["lokator2uid"]=lokator2uid, 
["lokator3"]=lokator3, 
["lokator3uid"]=lokator3uid, 
}) 

v.wyjscie=createMarker(interiory[v.interiorid].exit[1], interiory[v.interiorid].exit[2], interiory[v.interiorid].exit[3], "arrow",1setElementDimension(v.wyjscieinterior_dimensionsetElementInterior(v.wyjscieinteriory[v.interiorid].interiorsetElementData(v.wyjscie,"tpto"v.punkt_wyjscialocal dbid=v.id 
v.id=nil 
domy[dbid]=return true 
end 

function domyGetInfo(id) 
return domy[idend 

local function zaladujCzescDomow(procent,fastlocal tt=getTickCount() 
i=0 
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"local dbdomy 
if fast then 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
else 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1;"end 
for __,v in ipairs(dbdomy) do 
if math.random(0,100)<=procent then 
if dodajDom(v,fastthen i=i+1 end 
end 
end 
outputDebugString("Zaladowano domow: " .. .. " w " .. (getTickCount()-tt) .. "ms"end 
addEventHandler("onResourceStart"resourceRoot, function() 
zaladujCzescDomow(100,falseend) 

function zaladujZmienioneDomy() 
local i=0 
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1") 
for __,v in ipairs(dbdomy) do 

if dodajDom(vthen i=i+1 end 
end 
end 

setTimer(zaladujZmienioneDomy10*10000) 

function domReload(idlocal dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"id) 
if dbdom then 
for i,v in ipairs(dbdom) do 
return dodajDom(vend 
end 
return false 
end 

addEvent "SprawdzDom"true ) 
function SprawdzDom gracz local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
local r=v.ownerid 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
if r then if == uid then 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend end 
end 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend 
end 
addEventHandler "SprawdzDom"rootSprawdzDom ) 

function kupdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
q=q[1] 
if q.ownerid then 
client:outputChat("Ten dom ma ju? w?a?ciciela!"25500) 
return 
end 
if tonumber(czas) and tonumber(czas) < 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na kupno tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set ownerid=?, paidTo=NOW()+INTERVAL ? DAY, lokator1=NULL, lokator2=NULL, lokator3=NULL where id=?"client:getData("player:sid"), czasdomiddomReload(domidclient:outputChat("Pomy?lnie zakupi?e? dom, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:kup"trueaddEventHandler("DOMY:kup"rootkupdom) 

function oplacdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
if tonumber(czas) and tonumber(czas) < 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
q=q[1]
if q.ownerid ~= client:getData("player:sid"then 
client:outputChat("To nie jest tw?j dom!"25500) 
return 
end 
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na op?acenie tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set paidTo=paidTo+INTERVAL ? DAY where id=?"czasdomiddomReload(domidclient:outputChat("Pomy?lnie op?aci?e? dom na "..czas.." dni, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:oplac"trueaddEventHandler("DOMY:oplac"rootoplacdom) 

function dodajlokator(uid,domidlocal q2=exports["pystories-db"]:dbSet("select id from pystories_users where id=?"uid) 
if #q2> 0 then 
q=exports["pystories-db"]:dbSet("select lokator1,lokator2,lokator3 from lss_domy where id=?"domid) 
if #q < 1 then client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0) return end 
q=q[1] 
if q.lokator1 and q.lokator2 and q.lokator3 then client:outputChat("Osi?gni?to limit 3 lokator?w na dom!"25500) return end 
if not q.lokator1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
else 
client:outputChat("Nie ma konta z takim UID!"25500end 
end 
addEvent("DOM:lokator+"trueaddEventHandler("DOM:lokator+"rootdodajlokator) 

function usunlokator(id,domid) 
if id == 1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
end 
end 
addEvent("DOM:lokator-"trueaddEventHandler("DOM:lokator-"rootusunlokator) 

function zwolnijdom(domidexports["pystories-db"]:dbSet("update lss_domy set paidTo='2000-01-01 00:00:00' where id=?"domidexports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"domReload(domidclient:outputChat("Pomy?lnie zwolniono dom."02550end 
addEvent("DOM:zwolnij"trueaddEventHandler("DOM:zwolnij"rootzwolnijdomaddCommandHandler("mieszkanie",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Mieszkanie"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),8,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("dom",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Dom"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),221,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("willa",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Willa"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),27,1000000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
end)


Teraz powinno by? git

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
StifMaster
Wysłany: 2020-07-03, 02:17


StifMaster







Wiek: 30
Na forum: 3525 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

"Szypki_exe" napisał/a:



domy={} 
local function usunDom(id) 
if isElement(domy[id].wyjsciethen destroyElement(domy[id].wyjscieend 
if isElement(domy[id].wejsciethen destroyElement(domy[id].wejscieend 
if isElement(domy[id].csthen destroyElement(domy[id].csend 
if isElement(domy[id].textthen destroyElement(domy[id].textend 
domy[id]=nil 
end 

function dodajDom(v,fast) 

if not interiory[v.interioridthen return false end 
if domy[v.idthen 
usunDom(v.idend 
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"v.ownerid) 
if result and #result > 0 then 
local r=result[1] 
if r.login2 == false then 
v.owner_nick r.login 
else 
v.owner_nick r.login2 
end 
else 
if v.ownerid ~= false then 
outputDebugString("B?ad domu ID domu#"..v.idend 
v.owner_nick "do wynaj?cia" 
end 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
v.punkt_wyjscia=split(v.punkt_wyjscia,",") 
for ii,vv in ipairs(v.punkt_wyjscia) do    v.punkt_wyjscia[ii]=tonumber(vv)    end 
local pickupid=1272 
if (not v.owneridthen 
pickupid=1273 
end 
v.wejscie=createPickup v.drzwi[1], v.drzwi[2], v.drzwi[3], 3pickupid0v.cs=createColSphere(v.drzwi[1],v.drzwi[2],v.drzwi[3], 1) 

if (not fast and v.owneridthen 
v.text=createElement("text"setElementPosition(v.textv.drzwi[1],v.drzwi[2],v.drzwi[3]+0.5setElementData(v.text,"text", (v.descr or "Dom").."\n"..v.owner_nickend 
local interior_dimension=v.vwi or 1000+v.id 
if v.lokator1 ~= "false" then 
local lokator1db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator1) 
if #lokator1db > 0 then 
lokator1db=lokator1db[1] 
if lokator1db.login2 then 
lokator1=lokator1db.login2 
else 
lokator1=lokator1db.login 
end 
lokator1uid=lokator1db.id 
else 
lokator1=false 
lokator1uid=false 
end 
end 
if v.lokator2 ~= "false" then 
local lokator2db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator2) 
if #lokator2db > 0 then 
lokator2db=lokator2db[1] 
if lokator2db.login2 then 
lokator2=lokator2db.login2 
else 
lokator2=lokator2db.login 
end 
lokator2uid=lokator2db.id 
else 
lokator2=false 
lokator2uid=false 
end 
end 
if v.lokator3 ~= "false" then 
local lokator3db=exports["pystories-db"]:dbSet("select login,login2,id from pystories_users where id=?"v.lokator3) 
if #lokator3db > 0 then 
lokator3db=lokator3db[1] 
if lokator3db.login2 then 
lokator3=lokator3db.login2 
else 
lokator3=lokator3db.login 
end 
lokator3uid=lokator3db.id 
else 
lokator3=false 
lokator3uid=false 
end    
end 
setElementData(v.cs"dom", { 
["zamkniety"]=v.zamkniety>and true or false, 
["id"]=v.id, 
["koszt"]=v.koszt, 
["ownerid"]=v.ownerid, 
["owner_nick"]=v.owner_nick, 
["descr"]=v.descr or "dom", 
["dimension"]=interior_dimension, 
["interior"]=interiory[v.interiorid].interior, 
["interior_loc"]=interiory[v.interiorid].entrance, 
["exit_loc"]=v.punkt_wyjscia, 
["paidTo"]=v.paidTo, 
["paidTo_dni"]=v.paidTo_dni, 
["lokator1"]=lokator1, 
["lokator1uid"]=lokator1uid, 
["lokator2"]=lokator2, 
["lokator2uid"]=lokator2uid, 
["lokator3"]=lokator3, 
["lokator3uid"]=lokator3uid, 
}) 

v.wyjscie=createMarker(interiory[v.interiorid].exit[1], interiory[v.interiorid].exit[2], interiory[v.interiorid].exit[3], "arrow",1setElementDimension(v.wyjscieinterior_dimensionsetElementInterior(v.wyjscieinteriory[v.interiorid].interiorsetElementData(v.wyjscie,"tpto"v.punkt_wyjscialocal dbid=v.id 
v.id=nil 
domy[dbid]=return true 
end 

function domyGetInfo(id) 
return domy[idend 

local function zaladujCzescDomow(procent,fastlocal tt=getTickCount() 
i=0 
exports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"local dbdomy 
if fast then 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
else 
dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1;"end 
for __,v in ipairs(dbdomy) do 
if math.random(0,100)<=procent then 
if dodajDom(v,fastthen i=i+1 end 
end 
end 
outputDebugString("Zaladowano domow: " .. .. " w " .. (getTickCount()-tt) .. "ms"end 
addEventHandler("onResourceStart"resourceRoot, function() 
zaladujCzescDomow(100,falseend) 

function zaladujZmienioneDomy() 
local i=0 
local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1") 
for __,v in ipairs(dbdomy) do 

if dodajDom(vthen i=i+1 end 
end 
end 

setTimer(zaladujZmienioneDomy10*10000) 

function domReload(idlocal dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"id) 
if dbdom then 
for i,v in ipairs(dbdom) do 
return dodajDom(vend 
end 
return false 
end 

addEvent "SprawdzDom"true ) 
function SprawdzDom gracz local dbdomy=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid AND d.ownerid IS NOT NULL;") 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
local r=v.ownerid 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
if r then if == uid then 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend end 
end 
for __,v in ipairs(dbdomy) do 
local uid=tonumber(getElementData(gracz,"player:sid")) 
v.drzwi=split(v.drzwi,",") 
for ii,vv in ipairs(v.drzwi) do    v.drzwi[ii]=tonumber(vv)    end 
setElementData(gracz,"player:house",truetak=({v.drzwi[1],v.drzwi[2],v.drzwi[3]}) 
setElementData(gracz,"player:spawn",takend 
end 
addEventHandler "SprawdzDom"rootSprawdzDom ) 

function kupdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
q=q[1] 
if q.ownerid then 
client:outputChat("Ten dom ma ju? w?a?ciciela!"25500) 
return 
end 
if tonumber(czas) and tonumber(czas) < 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na kupno tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set ownerid=?, paidTo=NOW()+INTERVAL ? DAY, lokator1=NULL, lokator2=NULL, lokator3=NULL where id=?"client:getData("player:sid"), czasdomiddomReload(domidclient:outputChat("Pomy?lnie zakupi?e? dom, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:kup"trueaddEventHandler("DOMY:kup"rootkupdom) 

function oplacdom(czas,domidlocal kasa=client:getMoney() 
q=exports["pystories-db"]:dbSet("select ownerid,koszt,id from lss_domy where id=?"domid) 
if #q < 1 then 
client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!"25500) 
return 
end 
if tonumber(czas) and tonumber(czas) < 1 then
    client:outputChat("Podane dni s? mniejsze od 1")
    return
end
q=q[1]
if q.ownerid ~= client:getData("player:sid"then 
client:outputChat("To nie jest tw?j dom!"25500) 
return 
end 
koszt=q.koszt*czas 
if kasa koszt then 
client:outputChat("Nie sta? Ci? na op?acenie tego domu! ("..koszt.." PLN)"25500) 
return 
end 
takePlayerMoney(clientkosztexports["pystories-db"]:dbSet("update lss_domy set paidTo=paidTo+INTERVAL ? DAY where id=?"czasdomiddomReload(domidclient:outputChat("Pomy?lnie op?aci?e? dom na "..czas.." dni, pobrano z konta "..koszt.." PLN!"02550end 
addEvent("DOMY:oplac"trueaddEventHandler("DOMY:oplac"rootoplacdom) 

function dodajlokator(uid,domidlocal q2=exports["pystories-db"]:dbSet("select id from pystories_users where id=?"uid) 
if #q2> 0 then 
q=exports["pystories-db"]:dbSet("select lokator1,lokator2,lokator3 from lss_domy where id=?"domid) 
if #q < 1 then client:outputChat("Wyst?pi? b??d, nie znaleziono takiego domu!", 255, 0, 0) return end 
q=q[1] 
if q.lokator1 and q.lokator2 and q.lokator3 then client:outputChat("Osi?gni?to limit 3 lokator?w na dom!"25500) return end 
if not q.lokator1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
if not q.lokator3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=? where id=?"uiddomiddomReload(domidclient:outputChat("Dodano nowego lokatora do domu."02550) 
return 
end 
else 
client:outputChat("Nie ma konta z takim UID!"25500end 
end 
addEvent("DOM:lokator+"trueaddEventHandler("DOM:lokator+"rootdodajlokator) 

function usunlokator(id,domid) 
if id == 1 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator1=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 2 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator2=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
elseif id == 3 then 
exports["pystories-db"]:dbSet("update lss_domy set lokator3=NULL where id=?"domidclient:outputChat("Pomy?lnie usuni?to lokatora."02550local dbdom=exports["pystories-db"]:dbGet("SELECT d.id,d.lokator1,d.lokator2,d.lokator3,d.descr,d.vwi,d.drzwi,d.punkt_wyjscia,d.interiorid,d.ownerid,d.zamkniety,d.koszt,d.paidTo,datediff(d.paidTo,now()) paidTo_dni FROM lss_domy d LEFT JOIN pystories_users c ON c.id=d.ownerid WHERE d.active=1 AND timediff(now(),d.updated)<'00:09:00' AND datediff(now(),d.updated)<1 and d.id=?"domid) 
for i,v in ipairs(dbdom) do 
dodajDom(vend 
end 
end 
addEvent("DOM:lokator-"trueaddEventHandler("DOM:lokator-"rootusunlokator) 

function zwolnijdom(domidexports["pystories-db"]:dbSet("update lss_domy set paidTo='2000-01-01 00:00:00' where id=?"domidexports["pystories-db"]:dbSet("UPDATE lss_domy SET paidTo=NULL,ownerid=NULL,lokator1=NULL,lokator2=NULL,lokator3=NULL where paidTo<NOW() or paidTo IS NULL"domReload(domidclient:outputChat("Pomy?lnie zwolniono dom."02550end 
addEvent("DOM:zwolnij"trueaddEventHandler("DOM:zwolnij"rootzwolnijdomaddCommandHandler("mieszkanie",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Mieszkanie"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),8,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("dom",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Dom"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),221,500000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
endaddCommandHandler("willa",function(plr,cmd) 
if exports['pystories-admins']:getAdmin(plr,4then 
local x,y,getElementPosition(plrlocal stringe = ("INSERT INTO lss_domy (descr,i,vwe,drzwi,punkt_wyjscia,interiorid,koszt,active) VALUES ('%s',%s,%s,'%s','%s',%s,%s,%s)"):format("Willa"0,0,("%.2f,%.2f,%.2f"):format(x,y,z),("%.2f,%.2f,%.2f"):format(x,y,z),27,1000000,1local q,_,id=exports["pystories-db"]:dbSet(stringedomReload(idend 
end)


Teraz powinno by? git
Dzia?a jak powinno. Dzi?ki za chwilk? po?wi?cenia :) Dopiero si? ucz? :D . Zimne piwko dla Ciebie. Temat do zamkni?cia.

Postaw piwo autorowi tego posta
 

 
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Kupno domków 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