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

Wysłany: 2019-06-27, 20:23


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jeste? pewny, ?e taka elementDate ustawiasz wcze?niej? Kod usunales to nie zobacz?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 20:39


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Kod:


Wilq



local SQL

local function connect()
-- w ponizszej linii uzupelnij dane autoryzacji
SQL = dbConnect("mysql", "dbname=db_484;host=137.12", "db484","NRnxyONY","share=1")
if (not SQL) then
outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
else
zapytanie("SET NAMES utf8;")
end

end

addEventHandler("onResourceStart",resourceRoot, connect)

function pobierzTabeleWynikow(...)
local h=dbQuery(SQL,...)
if (not h) then
return nil
end
local rows = dbPoll(h, -1)
return rows
end

function pobierzWyniki(...)
local h=dbQuery(SQL,...)
if (not h) then
return nil
end
local rows = dbPoll(h, -1)
if not rows then return nil end
return rows[1]
end

function zapytanie(...)
local h=dbQuery(SQL,...)
local result,numrows=dbPoll(h,-1)
return numrows
end

function init()
local biznesy=pobierzTabeleWynikow("select biznesy.id,biznesy.owner,biznesy.cost,biznesy.zajety,biznesy.nazwa,biznesy.saldo,biznesy.xyz,biznesy.data,pystories_users.login from biznesy LEFT JOIN pystories_users on biznesy.owner=pystories_users.id")
for i,v in ipairs(biznesy) do
stworz(v)
end
end

local pickup = {}

local bramy = {}

function stworz(v)
if not v.login then v.zajety="n" end
v.xyz=split(v.xyz,",")
biz=createPickup ( v.xyz[1], v.xyz[2], v.xyz[3], 3, 1274, 0 )
local biz2 = biz
local tw=createElement("text")
local x2342=v.cost/50
local x234 = math.floor(x2342)
local ***** = math.floor(v.cost/4)
if v.zajety == "n" then v.login = "Brak";v.data="Brak w?asciciela" end
local profir1 = math.floor(x234*24*7)
outputDebugString(v.id)
local format1=("Biznes: %s (ID: %s )\nW?a?ciciel: %s \nKoszt na 7 dni: %s PLN\nPieni?dze co godzine: %s PLN\nPieni?dze za sprzeda?: %s PLN\nOplacony do: %s \nZarobek tygodniowy: %s PLN"):format(v.nazwa,v.id,v.login,v.cost,x234,*****,v.data,profir1)
setElementData(tw, "name", format1)
setElementPosition(tw, v.xyz[1], v.xyz[2], v.xyz[3]+0.8)
setElementData(biz2, "cost", v.cost)
setElementData(biz2, "z", v.zajety)
setElementData(biz2, "name", v.nazwa)
setElementData(biz2, "id", v.id)
setElementData(biz2, "payday",x234)
setElementData(biz2, "saldo",v.saldo)
setElementData(biz2,"data",v.data)
setElementData(biz2, "owner", v.owner)
end
--[[
function bramabiznes(plr)
if isElementWithinColShape(plr, getElementColShape(pickup[plr])) then
local biz2 = pickup[plr]
if getElementData(biz2, "z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!", plr, 255, 255, 255) return end
if tonumber(getElementData(biz2, "owner")) ~= tonumber(getElementData(plr, "player:uid")) then outputChatBox("To nie jest tw?j biznes!", plr, 255, 255, 255) return end
local gate = getElementData(biz2,"gate")
if not gate then outputChatBox("* Twoj biznes nie ma bramy",plr) return end
local zamknieta = getElementData(gate,"state")
local open = getElementData(gate,"open")
local close = getElementData(gate,"close")
local animation = getElementData(gate,"animation")
if animation then outputChatBox("*Poczekaj a? brama sko?czy si? rusza?!",plr) return end
if zamknieta then
moveObject(gate, 5000, open[1],open[2], open[3],0,0,0, "OutQuad")
setElementData(gate,"animation",true)
setTimer(function(gates) setElementData(gates,"animation",false); setElementData(gates,"state",false) end,5000,1,gate)
else
moveObject(gate, 5000, close[1],close[2], close[3],0,0,0, "OutQuad")
setTimer(function(gates) setElementData(gates,"animation",false); setElementData(gates,"state",true) end,5000,1,gate)
end
end
end
addCommandHandler("biznes.brama", bramabiznes)
]]


function sprzedajbiznes(plr)
if isElementWithinColShape(plr, getElementColShape(pickup[plr])) then
local biz2 = pickup[plr]
if getElementData(biz2, "z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!", plr, 255, 255, 255) return end
if tonumber(getElementData(biz2, "owner")) ~= tonumber(getElementData(plr, "player:uid")) then outputChatBox("To nie jest tw?j biznes!", plr, 255, 255, 255) return end
local cashit=getElementData(biz2, "cost")
local lasthit2=cashit/4
to nie dziala local lasthit = math.floor(lasthit2)
outputChatBox("Otrzymujesz "..lasthit.." PLN za sprzeda? swojego biznesu ("..getElementData(biz2, "name")..")", plr, 255, 255, 255)
givePlayerMoney(plr, lasthit)
exports["pystories-db"]:dbSet("UPDATE biznesy SET owner=?, zajety=?, saldo=0 WHERE id=?","brak", "n", getElementData(biz2, "id"))
restartResource(getThisResource())
end
end
addCommandHandler("biznes.sprzedaj", sprzedajbiznes)

function kupbiznes(plr)
if isElementWithinColShape(plr, getElementColShape(pickup[plr])) then
local biz2 = pickup[plr]
if getElementData(biz2, "z") == "t" then outputChatBox("Ten biznes ma ju? w?a?ciciela!", plr, 255, 255, 255) return end
if getElementData(biz2, "z") == "n" then
local koszt=getElementData(biz2,"cost")
local hajs=getPlayerMoney(plr)
if tonumber(getElementData(plr, "player:reputation")) < 750 then outputChatBox("Aby zakupi? biznes musisz posiada? 750 RP!", plr, 255, 255, 255) return end
if tonumber(bkoszt) > tonumber(hajs) then outputChatBox("Nie posiadasz "..getElementData(biz2, "cost").." PLN", plr, 255, 255, 255) return end
local limit = exports['pysto-db']:dbGet("SELECT * FROM biznesy WHERE owner=?",getElementData(plr,"player:uid"))
if #limit >= 1 then outputChatBox("Posiadasz ju? jeden biznes!",plr,255,0,0) return end
outputChatBox("Pomy?lnie zakupi?e? biznes o nazwie "..getElementData(biz2, "name").." za "..getElementData(biz2, "cost").." PLN na 7 dni. Pamietaj o przedluzeniu!", plr, 255, 255, 255)
takePlayerMoney(plr, getElementData(biz2, "cost"))
exports["pystories-db"]:dbSet("UPDATE biznesy SET zajety=?, owner=?, saldo=?, data = NOW() + INTERVAL 7 day WHERE id=?", "t", getElementData(plr, "player:uid"), "0", getElementData(biz2, "id"))
restartResource(getThisResource())
end
end
end
addCommandHandler("biznes.kup", kupbiznes)


function wyplac(plr,cmd,kwota)
if isElementWithinColShape(plr, getElementColShape(pickup[plr])) then
local biz2 = pickup[plr]
if getElementData(biz2, "z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!", plr, 255, 255, 255) return end
if tonumber(getElementData(biz2, "owner")) ~= tonumber(getElementData(plr, "player:uid")) then outputChatBox("To nie jest tw?j biznes!", plr, 255, 255, 255) return end
local sal = exports['pystories-db']:dbGet("select saldo from biznesy where id=?",getElementData(biz2,"id"))
local saldo = sal[1].saldo
if not tonumber(kwota) then
outputChatBox("-- Biznes --",plr,255, 255, 255)
outputChatBox("/biznes.wyplac <kwota>",plr,255, 255, 255)
outputChatBox("Dostepne ?rodki: "..saldo,plr,255, 255, 255)
return
end
local kwota = math.floor(kwota)
if saldo < kwota then outputChatBox("*Nie masz tyle srodk?w na koncie",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set saldo=saldo-?? where id=?",kwota,getElementData(biz2,"id"))
givePlayerMoney(plr,kwota)
outputChatBox("* Wyp?acile? "..kwota.. "PLN z biznesu!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.wyplac",wyplac)
function wbil ( hitElement )
if getElementType(hitElement) ~= "player" then return end
if getPedOccupiedVehicle(hitElement) then return end
pickup[hitElement] = source
local biznes = source
if getElementData(biznes, "z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela, aby go zakupi? wpisz /biznes.kup", hitElement, 255, 255, 255) return end
local uid=getElementData(hitElement, "player:uid")
local wlasciciel=getElementData(biznes, "owner")
local nazwa=getElementData(biznes, "name")
local id=getElementData(biznes, "id")
local koszt=getElementData(biznes, "cost")
local saldo=getElementData(biznes, "saldo")
local data=getElementData(biznes,"data")
local sal = exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biznes,"id"))
if sal and #sal > 0 then exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW() and id=?","brak","n",getElementData(biznes,"id")) outputChatBox("Biznes zwolniony poniewaz nie zostal oplacony w czasie !",hitElement);restartResource(getThisResource()) return end
if tonumber(uid) ~= tonumber(wlasciciel) then outputChatBox("Ten biznes jest ju? zaj?ty!", hitElement, 255, 255, 255) return end
triggerClientEvent("gui:otworz", hitElement, hitElement, wlasciciel, nazwa, id, koszt,saldo,data)
end
addEventHandler ( "onPickupHit", resourceRoot, wbil )


function cmd(plr,cmd,cost,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4) then
if not tonumber(cost) or #arg == 1 then
outputChatBox("U?ycie: /biznes.stworz <koszt> <nazwa>", plr, 255, 255, 255)
return
end
local x,y,z=getElementPosition(plr)
local name2 = table.concat(arg, " ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN", plr, 255, 255, 255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz", cmd)



function cmd4(plr,cmd,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4) then
if #arg == 0 or id then
outputChatBox("U?ycie: /biznes.stworz2 <nazwa>", plr, 255, 255, 255)
return
end
local cost = math.random(200000,250000)
local x,y,z=getElementPosition(plr)
local name2 = table.concat(arg, " ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN", plr, 255, 255, 255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET id=?,owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",id,
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz2", cmd4)

function przedluz(plr,cmd)
if isElementWithinColShape(plr, getElementColShape(pickup[plr])) then
local biz2 = pickup[plr]
if getElementData(biz2, "z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!", plr, 255, 255, 255) return end
if tonumber(getElementData(biz2, "owner")) ~= tonumber(getElementData(plr, "player:uid")) then outputChatBox("To nie jest tw?j biznes!", plr, 255, 255, 255) return end
local sal = exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biz2,"id"))
if sal and #sal > 0 then outputChatBox("Ten biznes juz nie nalezy do ciebie spozniles sie !",plr); restartResource(getThisResource()) return end
local bkoszt=getElementData(biz2, "cost")
local kwota = math.floor(bkoszt)
local saldo = getPlayerMoney(plr)
local brakuje = kwota - saldo
if saldo < kwota then outputChatBox("*Nie masz tyle srodk?w na koncie ("..kwota..") Brakuje ci "..brakuje.." PLN",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set data=data + INTERVAL 7 day where id=?",getElementData(biz2,"id"))
takePlayerMoney(plr,kwota)
outputChatBox("* Przedluzyles biznes o 7 dni!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.przedluz",przedluz)



function sypnijmu()
local marker = getElementsByType("pickup")
for _,m in ipairs(marker) do
if getElementData(m, "owner") then
if tonumber(getElementData(m, "owner")) == tonumber(getElementData(source, "player:uid")) then
local flor= tonumber(getElementData(m, "dostanie"))
outputChatBox("Otrzymujesz "..flor.." PLN za posiadanie biznesu: "..getElementData(m, "name").."", source, 255, 255, 255)
givePlayerMoney(source, flor)
end
end
end
end
addEvent("sypnij", true)
addEventHandler("sypnij", getRootElement(), sypnijmu)


addEventHandler("onResourceStart",resourceRoot,function()
exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW()","brak","n")
setTimer(init,3000,1)
end)

local czas_restartu = 60*60*1000
setTimer(function()
for i,p in pairs(getElementsByType('pickup')) do
if #getElementsWithinColShape(getElementColShape(p)) > 0 then return end
end
restartResource(getThisResource())
end,czas_restartu,0)

addEventHandler("onResourceStop",resourceRoot, function() restartResource(getResourceFromName("guibiznes")) end)
[/code]

[ Dodano: 2019-06-27, 20:41 ]
Wilq,

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 20:58


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Niemo?liwe, ?eby 142 linijka to
local koszt=getElementData(biz2,"cost"


Upewnij si?, kt?ra to 142 linijka i j??wklej tutaj w BBCODE [.lua] [./lua] bez kropek oczywi?cie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:02


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,

ERROR: [biznesy/s.lua:126attempt to compare nil with number
local koszt=getElementData(biz2,"cost")


Postaw piwo autorowi tego posta
 

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


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Dalej skopiowa?e? z???linijk??z b??du i dalej skopiowa?e? z?? linijk??z kodu.

Znajd? t? linijk?:
if tonumber(bkoszt) > tonumber(hajsthen outputChatBox("Nie posiadasz "..getElementData(biz2"cost").." PLN"plr255255255) return end 

i podmie? j??na
if tonumber(koszt) > tonumber(hajsthen outputChatBox("Nie posiadasz "..getElementData(biz2"cost").." PLN"plr255255255) return end 


Jak si? chcesz bra? za serwer jak nawet z tym masz problem.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:14


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,
nie dziala
https://imgur.com/wwG6clz

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:20


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wklej kod po zmianach, nie dopisuj do niego nic abym m?g? w ?atwy spos?b odnale?? 126 linijk? na w?asn? r?k?.

Postaw piwo autorowi tego posta
 

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


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,

local SQL

local function connect()
    -- w ponizszej linii uzupelnij dane autoryzacji
    SQL dbConnect("mysql""dbname=84;host=.0.12""db_44","NRXONY","share=1")
    if (not SQLthen
        outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
    else
        zapytanie("SET NAMES utf8;")
    end

end

addEventHandler("onResourceStart",resourceRootconnect)

function pobierzTabeleWynikow(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    return rows
end

function pobierzWyniki(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    if not rows then return nil end
    return rows[1]
end

function zapytanie(...)
    local h=dbQuery(SQL,...)
    local result,numrows=dbPoll(h,-1)
    return numrows
end

function init()
    local biznesy=pobierzTabeleWynikow("select biznesy.id,biznesy.owner,biznesy.cost,biznesy.zajety,biznesy.nazwa,biznesy.saldo,biznesy.xyz,biznesy.data,pystories_users.login from biznesy LEFT JOIN pystories_users on biznesy.owner=pystories_users.id")
    for i,v in ipairs(biznesy) do
    stworz(v)
    end
end

local pickup = {}

local bramy = {}

function stworz(v)
    if not v.login then v.zajety="n" end
    v.xyz=split(v.xyz,",")
    biz=createPickup v.xyz[1], v.xyz[2], v.xyz[3], 31274)
    local biz2 biz
    local tw=createElement("text")
    local x2342=v.cost/50
    local x234 math.floor(x2342)
    local ***** = math.floor(v.cost/4)
    if v.zajety == "n" then v.login "Brak";v.data="Brak w?asciciela" end
    local profir1 math.floor(x234*24*7)
    outputDebugString(v.id)
    local format1=("Biznes: %s (ID: %s )\nW?a?ciciel: %s \nKoszt na 7 dni: %s PLN\nPieni?dze co godzine: %s PLN\nPieni?dze za sprzeda?: %s PLN\nOplacony do: %s \nZarobek tygodniowy: %s PLN"):format(v.nazwa,v.id,v.login,v.cost,x234,*****,v.data,profir1)
    setElementData(tw"name"format1)
    setElementPosition(twv.xyz[1], v.xyz[2], v.xyz[3]+0.8)
    setElementData(biz2"cost"v.cost)
    setElementData(biz2"z"v.zajety)
    setElementData(biz2"name"v.nazwa)
    setElementData(biz2"id"v.id)
    setElementData(biz2"payday",x234)
    setElementData(biz2"saldo",v.saldo)
    setElementData(biz2,"data",v.data)
    setElementData(biz2"owner"v.owner)
end
--[[
function bramabiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
    local biz2 pickup[plr]
    if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
        if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
    local gate getElementData(biz2,"gate")
    if not gate then outputChatBox("* Twoj biznes nie ma bramy",plr) return end
    local zamknieta getElementData(gate,"state")
        local open getElementData(gate,"open")
    local close getElementData(gate,"close")
    local animation getElementData(gate,"animation")
    if animation then outputChatBox("*Poczekaj a? brama sko?czy si? rusza?!",plr) return end
    if zamknieta then
        moveObject(gate5000open[1],open[2], open[3],0,0,0"OutQuad")
        setElementData(gate,"animation",true)
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",falseend,5000,1,gate)
    else
        moveObject(gate5000close[1],close[2], close[3],0,0,0"OutQuad")
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",trueend,5000,1,gate)
    end
end
end
addCommandHandler("biznes.brama"bramabiznes)
]]


function sprzedajbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local cashit=getElementData(biz2"cost")
local lasthit2=cashit/4
local lasthit math.floor(lasthit2)
outputChatBox("Otrzymujesz "..lasthit.." PLN za sprzeda? swojego biznesu ("..getElementData(biz2"name")..")"plr255255255)
givePlayerMoney(plrlasthit)
exports["pystories-db"]:dbSet("UPDATE biznesy SET owner=?, zajety=?, saldo=0 WHERE id=?","brak""n"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
addCommandHandler("biznes.sprzedaj"sprzedajbiznes) 

function kupbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "t" then outputChatBox("Ten biznes ma ju? w?a?ciciela!"plr255255255) return end
if getElementData(biz2"z") == "n" then
local bkoszt=getElementData(biz2"cost")
local hajs=getPlayerMoney(plr)
if tonumber(getElementData(plr"player:reputation")) < 750 then outputChatBox("Aby zakupi? biznes musisz posiada? 750 RP!"plr255255255) return end
if tonumber(koszt) > tonumber(hajsthen outputChatBox("Nie posiadasz "..getElementData(biz2"cost").." PLN"plr255255255) return end 
local limit exports['pysto-db']:dbGet("SELECT * FROM biznesy WHERE owner=?",getElementData(plr,"player:uid"))
if #limit >= 1 then outputChatBox("Posiadasz ju? jeden biznes!",plr,255,0,0) return end
outputChatBox("Pomy?lnie zakupi?e? biznes o nazwie "..getElementData(biz2"name").." za "..getElementData(biz2"cost").." PLN na 7 dni. Pamietaj o przedluzeniu!"plr255255255)
takePlayerMoney(plrgetElementData(biz2"cost"))
exports["pystories-db"]:dbSet("UPDATE biznesy SET zajety=?, owner=?, saldo=?, data = NOW() + INTERVAL 7 day WHERE id=?""t"getElementData(plr"player:uid"), "0"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
end
addCommandHandler("biznes.kup"kupbiznes)


function wyplac(plr,cmd,kwota)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select saldo from biznesy where id=?",getElementData(biz2,"id"))
local saldo sal[1].saldo
if not tonumber(kwotathen
    outputChatBox("-- Biznes --",plr,255255255)
    outputChatBox("/biznes.wyplac <kwota>",plr,255255255)
    outputChatBox("Dostepne ?rodki: "..saldo,plr,255255255)
    return
end
local kwota math.floor(kwota)
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set saldo=saldo-?? where id=?",kwota,getElementData(biz2,"id"))
givePlayerMoney(plr,kwota)
outputChatBox("* Wyp?acile? "..kwota.. "PLN z biznesu!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.wyplac",wyplac)
function wbil hitElement )
if getElementType(hitElement) ~= "player" then return end
if getPedOccupiedVehicle(hitElementthen return end
pickup[hitElement] = source
local biznes source
if getElementData(biznes"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela, aby go zakupi? wpisz /biznes.kup"hitElement255255255) return end
local uid=getElementData(hitElement"player:uid")
local wlasciciel=getElementData(biznes"owner")
local nazwa=getElementData(biznes"name")
local id=getElementData(biznes"id")
local koszt=getElementData(biznes"cost")
local saldo=getElementData(biznes"saldo")
local data=getElementData(biznes,"data")
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biznes,"id"))
if sal and #sal > 0 then exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW() and id=?","brak","n",getElementData(biznes,"id")) outputChatBox("Biznes zwolniony poniewaz nie zostal oplacony w czasie !",hitElement);restartResource(getThisResource()) return end
if tonumber(uid) ~= tonumber(wlascicielthen outputChatBox("Ten biznes jest ju? zaj?ty!"hitElement255255255) return end
triggerClientEvent("gui:otworz"hitElementhitElementwlascicielnazwaidkoszt,saldo,data)
end
addEventHandler "onPickupHit"resourceRootwbil )


function cmd(plr,cmd,cost,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if not tonumber(cost) or #arg == 1 then
  outputChatBox("U?ycie: /biznes.stworz <koszt> <nazwa>"plr255255255)
  return
 end
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz"cmd)



function cmd4(plr,cmd,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if #arg == 0 or id then
  outputChatBox("U?ycie: /biznes.stworz2 <nazwa>"plr255255255)
  return
 end
 local cost math.random(200000,250000)
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET id=?,owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",id,
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz2"cmd4)

function przedluz(plr,cmd)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biz2,"id"))
if sal and #sal > 0 then outputChatBox("Ten biznes juz nie nalezy do ciebie spozniles sie !",plr); restartResource(getThisResource()) return end
local bkoszt=getElementData(biz2"cost")
local kwota math.floor(bkoszt)
local saldo getPlayerMoney(plr)
local brakuje kwota saldo
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie ("..kwota..") Brakuje ci "..brakuje.." PLN",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set data=data + INTERVAL 7 day where id=?",getElementData(biz2,"id"))
takePlayerMoney(plr,kwota)
outputChatBox("* Przedluzyles biznes o 7 dni!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.przedluz",przedluz)



function sypnijmu()
local marker getElementsByType("pickup")
for _,m in ipairs(marker) do
if getElementData(m"owner"then
if tonumber(getElementData(m"owner")) == tonumber(getElementData(source"player:uid")) then
local flortonumber(getElementData(m"dostanie"))
outputChatBox("Otrzymujesz "..flor.." PLN za posiadanie biznesu: "..getElementData(m"name")..""source255255255)
givePlayerMoney(sourceflor)
end
end
end
end
addEvent("sypnij"true)
addEventHandler("sypnij"getRootElement(), sypnijmu)


addEventHandler("onResourceStart",resourceRoot,function()
exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW()","brak","n")
setTimer(init,3000,1)
end)

local czas_restartu 60*60*1000
setTimer(function()
for i,p in pairs(getElementsByType('pickup')) do
 if #getElementsWithinColShape(getElementColShape(p)) > 0 then return end
end
restartResource(getThisResource())
end,czas_restartu,0)

addEventHandler("onResourceStop",resourceRoot, function() restartResource(getResourceFromName("guibiznes")) end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:24


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Czy masz ustawion? elementDat? "player:reputation" graczowi, kt?ry wpisuje /biznes.kup?

Podmie? kod, pope?ni?em b??d, gdy? wykorzysta?em nieistniej?c? zmienn?, problem si? nie rozwi??e poniewa? nie masz ustawionej powy?szej elementDaty.

local SQL

local function connect()
    -- w ponizszej linii uzupelnij dane autoryzacji
    SQL dbConnect("mysql""dbname=84;host=.0.12""db_44","NRXONY","share=1")
    if (not SQLthen
        outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
    else
        zapytanie("SET NAMES utf8;")
    end

end

addEventHandler("onResourceStart",resourceRootconnect)

function pobierzTabeleWynikow(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    return rows
end

function pobierzWyniki(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    if not rows then return nil end
    return rows[1]
end

function zapytanie(...)
    local h=dbQuery(SQL,...)
    local result,numrows=dbPoll(h,-1)
    return numrows
end

function init()
    local biznesy=pobierzTabeleWynikow("select biznesy.id,biznesy.owner,biznesy.cost,biznesy.zajety,biznesy.nazwa,biznesy.saldo,biznesy.xyz,biznesy.data,pystories_users.login from biznesy LEFT JOIN pystories_users on biznesy.owner=pystories_users.id")
    for i,v in ipairs(biznesy) do
    stworz(v)
    end
end

local pickup = {}

local bramy = {}

function stworz(v)
    if not v.login then v.zajety="n" end
    v.xyz=split(v.xyz,",")
    biz=createPickup v.xyz[1], v.xyz[2], v.xyz[3], 31274)
    local biz2 biz
    local tw=createElement("text")
    local x2342=v.cost/50
    local x234 math.floor(x2342)
    local ***** = math.floor(v.cost/4)
    if v.zajety == "n" then v.login "Brak";v.data="Brak w?asciciela" end
    local profir1 math.floor(x234*24*7)
    outputDebugString(v.id)
    local format1=("Biznes: %s (ID: %s )\nW?a?ciciel: %s \nKoszt na 7 dni: %s PLN\nPieni?dze co godzine: %s PLN\nPieni?dze za sprzeda?: %s PLN\nOplacony do: %s \nZarobek tygodniowy: %s PLN"):format(v.nazwa,v.id,v.login,v.cost,x234,*****,v.data,profir1)
    setElementData(tw"name"format1)
    setElementPosition(twv.xyz[1], v.xyz[2], v.xyz[3]+0.8)
    setElementData(biz2"cost"v.cost)
    setElementData(biz2"z"v.zajety)
    setElementData(biz2"name"v.nazwa)
    setElementData(biz2"id"v.id)
    setElementData(biz2"payday",x234)
    setElementData(biz2"saldo",v.saldo)
    setElementData(biz2,"data",v.data)
    setElementData(biz2"owner"v.owner)
end
--[[
function bramabiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
    local biz2 pickup[plr]
    if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
        if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
    local gate getElementData(biz2,"gate")
    if not gate then outputChatBox("* Twoj biznes nie ma bramy",plr) return end
    local zamknieta getElementData(gate,"state")
        local open getElementData(gate,"open")
    local close getElementData(gate,"close")
    local animation getElementData(gate,"animation")
    if animation then outputChatBox("*Poczekaj a? brama sko?czy si? rusza?!",plr) return end
    if zamknieta then
        moveObject(gate5000open[1],open[2], open[3],0,0,0"OutQuad")
        setElementData(gate,"animation",true)
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",falseend,5000,1,gate)
    else
        moveObject(gate5000close[1],close[2], close[3],0,0,0"OutQuad")
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",trueend,5000,1,gate)
    end
end
end
addCommandHandler("biznes.brama"bramabiznes)
]]


function sprzedajbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local cashit=getElementData(biz2"cost")
local lasthit2=cashit/4
local lasthit math.floor(lasthit2)
outputChatBox("Otrzymujesz "..lasthit.." PLN za sprzeda? swojego biznesu ("..getElementData(biz2"name")..")"plr255255255)
givePlayerMoney(plrlasthit)
exports["pystories-db"]:dbSet("UPDATE biznesy SET owner=?, zajety=?, saldo=0 WHERE id=?","brak""n"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
addCommandHandler("biznes.sprzedaj"sprzedajbiznes) 

function kupbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "t" then outputChatBox("Ten biznes ma ju? w?a?ciciela!"plr255255255) return end
if getElementData(biz2"z") == "n" then
local bkoszt=getElementData(biz2"cost")
local hajs=getPlayerMoney(plr)
if tonumber(getElementData(plr"player:reputation")) < 750 then outputChatBox("Aby zakupi? biznes musisz posiada? 750 RP!"plr255255255) return end
if tonumber(bkoszt) > tonumber(hajsthen outputChatBox("Nie posiadasz "..getElementData(biz2"cost").." PLN"plr255255255) return end 
local limit exports['pysto-db']:dbGet("SELECT * FROM biznesy WHERE owner=?",getElementData(plr,"player:uid"))
if #limit >= 1 then outputChatBox("Posiadasz ju? jeden biznes!",plr,255,0,0) return end
outputChatBox("Pomy?lnie zakupi?e? biznes o nazwie "..getElementData(biz2"name").." za "..getElementData(biz2"cost").." PLN na 7 dni. Pamietaj o przedluzeniu!"plr255255255)
takePlayerMoney(plrgetElementData(biz2"cost"))
exports["pystories-db"]:dbSet("UPDATE biznesy SET zajety=?, owner=?, saldo=?, data = NOW() + INTERVAL 7 day WHERE id=?""t"getElementData(plr"player:uid"), "0"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
end
addCommandHandler("biznes.kup"kupbiznes)


function wyplac(plr,cmd,kwota)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select saldo from biznesy where id=?",getElementData(biz2,"id"))
local saldo sal[1].saldo
if not tonumber(kwotathen
    outputChatBox("-- Biznes --",plr,255255255)
    outputChatBox("/biznes.wyplac <kwota>",plr,255255255)
    outputChatBox("Dostepne ?rodki: "..saldo,plr,255255255)
    return
end
local kwota math.floor(kwota)
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set saldo=saldo-?? where id=?",kwota,getElementData(biz2,"id"))
givePlayerMoney(plr,kwota)
outputChatBox("* Wyp?acile? "..kwota.. "PLN z biznesu!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.wyplac",wyplac)
function wbil hitElement )
if getElementType(hitElement) ~= "player" then return end
if getPedOccupiedVehicle(hitElementthen return end
pickup[hitElement] = source
local biznes source
if getElementData(biznes"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela, aby go zakupi? wpisz /biznes.kup"hitElement255255255) return end
local uid=getElementData(hitElement"player:uid")
local wlasciciel=getElementData(biznes"owner")
local nazwa=getElementData(biznes"name")
local id=getElementData(biznes"id")
local koszt=getElementData(biznes"cost")
local saldo=getElementData(biznes"saldo")
local data=getElementData(biznes,"data")
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biznes,"id"))
if sal and #sal > 0 then exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW() and id=?","brak","n",getElementData(biznes,"id")) outputChatBox("Biznes zwolniony poniewaz nie zostal oplacony w czasie !",hitElement);restartResource(getThisResource()) return end
if tonumber(uid) ~= tonumber(wlascicielthen outputChatBox("Ten biznes jest ju? zaj?ty!"hitElement255255255) return end
triggerClientEvent("gui:otworz"hitElementhitElementwlascicielnazwaidkoszt,saldo,data)
end
addEventHandler "onPickupHit"resourceRootwbil )


function cmd(plr,cmd,cost,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if not tonumber(cost) or #arg == 1 then
  outputChatBox("U?ycie: /biznes.stworz <koszt> <nazwa>"plr255255255)
  return
 end
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz"cmd)



function cmd4(plr,cmd,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if #arg == 0 or id then
  outputChatBox("U?ycie: /biznes.stworz2 <nazwa>"plr255255255)
  return
 end
 local cost math.random(200000,250000)
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET id=?,owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",id,
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz2"cmd4)

function przedluz(plr,cmd)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biz2,"id"))
if sal and #sal > 0 then outputChatBox("Ten biznes juz nie nalezy do ciebie spozniles sie !",plr); restartResource(getThisResource()) return end
local bkoszt=getElementData(biz2"cost")
local kwota math.floor(bkoszt)
local saldo getPlayerMoney(plr)
local brakuje kwota saldo
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie ("..kwota..") Brakuje ci "..brakuje.." PLN",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set data=data + INTERVAL 7 day where id=?",getElementData(biz2,"id"))
takePlayerMoney(plr,kwota)
outputChatBox("* Przedluzyles biznes o 7 dni!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.przedluz",przedluz)



function sypnijmu()
local marker getElementsByType("pickup")
for _,m in ipairs(marker) do
if getElementData(m"owner"then
if tonumber(getElementData(m"owner")) == tonumber(getElementData(source"player:uid")) then
local flortonumber(getElementData(m"dostanie"))
outputChatBox("Otrzymujesz "..flor.." PLN za posiadanie biznesu: "..getElementData(m"name")..""source255255255)
givePlayerMoney(sourceflor)
end
end
end
end
addEvent("sypnij"true)
addEventHandler("sypnij"getRootElement(), sypnijmu)


addEventHandler("onResourceStart",resourceRoot,function()
exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW()","brak","n")
setTimer(init,3000,1)
end)

local czas_restartu 60*60*1000
setTimer(function()
for i,p in pairs(getElementsByType('pickup')) do
 if #getElementsWithinColShape(getElementColShape(p)) > 0 then return end
end
restartResource(getThisResource())
end,czas_restartu,0)

addEventHandler("onResourceStop",resourceRoot, function() restartResource(getResourceFromName("guibiznes")) end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:36


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,
https://imgur.com/8B9Xre6
co? si? ***** mo?e wbijesz do mnie na serwer dam ci dost?p i mi to ogarniesz bo sam nie dam rady nie ogarniam akurat tego

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:39


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W linijce 60 masz co??takiego: *****
Zamie? to na jak?? zmienn?, potem w linijce 64 na ko?cu zamie? ***** na t??sam? zmienn?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:44


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,

nie dam rady zmienilem na inna niby si? odpala ale dalej kupi? nie mog?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:45


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Poka? kod po zmianach.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 21:52


dawidmajka

tfuj stary






Wiek: 22
Na forum: 3612 dni
Posty: 137
Nick w MP: kutas

Piwa: 13

Respekt: 40

Wilq,

sorki za to ?e tak m?cz? ale nie ogarniam tego daje inn? zmienna typu 6 kropek i error

local SQL

local function connect()
    -- w ponizszej linii uzupelnij dane autoryzacji
    SQL dbConnect("mysql""dbname=db84;host=132""db_44484","nj","share=1")
    if (not SQLthen
        outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
    else
        zapytanie("SET NAMES utf8;")
    end

end

addEventHandler("onResourceStart",resourceRootconnect)

function pobierzTabeleWynikow(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    return rows
end

function pobierzWyniki(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    if not rows then return nil end
    return rows[1]
end

function zapytanie(...)
    local h=dbQuery(SQL,...)
    local result,numrows=dbPoll(h,-1)
    return numrows
end

function init()
    local biznesy=pobierzTabeleWynikow("select biznesy.id,biznesy.owner,biznesy.cost,biznesy.zajety,biznesy.nazwa,biznesy.saldo,biznesy.xyz,biznesy.data,pystories_users.login from biznesy LEFT JOIN pystories_users on biznesy.owner=pystories_users.id")
    for i,v in ipairs(biznesy) do
    stworz(v)
    end
end

local pickup = {}

local bramy = {}

function stworz(v)
    if not v.login then v.zajety="n" end
    v.xyz=split(v.xyz,",")
    biz=createPickup v.xyz[1], v.xyz[2], v.xyz[3], 31274)
    local biz2 biz
    local tw=createElement("text")
    local x2342=v.cost/50
    local x234 math.floor(x2342)
    local asdfgh math.floor(v.cost/4)
    if v.zajety == "n" then v.login "Brak";v.data="Brak w?asciciela" end
    local profir1 math.floor(x234*24*7)
    outputDebugString(v.id)
    local format1=("Biznes: %s (ID: %s )\nW?a?ciciel: %s \nKoszt na 7 dni: %s PLN\nPieni?dze co godzine: %s PLN\nPieni?dze za sprzeda?: %s PLN\nOplacony do: %s \nZarobek tygodniowy: %s PLN"):format(v.nazwa,v.id,v.login,v.cost,x234,asdfgh,v.data,profir1)
    setElementData(tw"name"format1)
    setElementPosition(twv.xyz[1], v.xyz[2], v.xyz[3]+0.8)
    setElementData(biz2"cost"v.cost)
    setElementData(biz2"z"v.zajety)
    setElementData(biz2"name"v.nazwa)
    setElementData(biz2"id"v.id)
    setElementData(biz2"payday",x234)
    setElementData(biz2"saldo",v.saldo)
    setElementData(biz2,"data",v.data)
    setElementData(biz2"owner"v.owner)
end
--[[
function bramabiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
    local biz2 pickup[plr]
    if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
        if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
    local gate getElementData(biz2,"gate")
    if not gate then outputChatBox("* Twoj biznes nie ma bramy",plr) return end
    local zamknieta getElementData(gate,"state")
        local open getElementData(gate,"open")
    local close getElementData(gate,"close")
    local animation getElementData(gate,"animation")
    if animation then outputChatBox("*Poczekaj a? brama sko?czy si? rusza?!",plr) return end
    if zamknieta then
        moveObject(gate5000open[1],open[2], open[3],0,0,0"OutQuad")
        setElementData(gate,"animation",true)
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",falseend,5000,1,gate)
    else
        moveObject(gate5000close[1],close[2], close[3],0,0,0"OutQuad")
        setTimer(function(gatessetElementData(gates,"animation",false); setElementData(gates,"state",trueend,5000,1,gate)
    end
end
end
addCommandHandler("biznes.brama"bramabiznes)
]]


function sprzedajbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local cashit=getElementData(biz2"cost")
local lasthit2=cashit/4
local lasthit math.floor(lasthit2)
outputChatBox("Otrzymujesz "..lasthit.." PLN za sprzeda? swojego biznesu ("..getElementData(biz2"name")..")"plr255255255)
givePlayerMoney(plrlasthit)
exports["pystories-db"]:dbSet("UPDATE biznesy SET owner=?, zajety=?, saldo=0 WHERE id=?","brak""n"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
addCommandHandler("biznes.sprzedaj"sprzedajbiznes) 

function kupbiznes(plr)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "t" then outputChatBox("Ten biznes ma ju? w?a?ciciela!"plr255255255) return end
if getElementData(biz2"z") == "n" then
local bkoszt=getElementData(biz2"cost")
local hajs=getPlayerMoney(plr)
if tonumber(getElementData(plr"player:reputation")) < 750 then outputChatBox("Aby zakupi? biznes musisz posiada? 750 RP!"plr255255255) return end
if tonumber(bkoszt) > tonumber(hajsthen outputChatBox("Nie posiadasz "..getElementData(biz2"cost").." PLN"plr255255255) return end 
local limit exports['pysto-db']:dbGet("SELECT * FROM biznesy WHERE owner=?",getElementData(plr,"player:uid"))
if #limit >= 1 then outputChatBox("Posiadasz ju? jeden biznes!",plr,255,0,0) return end
outputChatBox("Pomy?lnie zakupi?e? biznes o nazwie "..getElementData(biz2"name").." za "..getElementData(biz2"cost").." PLN na 7 dni. Pamietaj o przedluzeniu!"plr255255255)
takePlayerMoney(plrgetElementData(biz2"cost"))
exports["pystories-db"]:dbSet("UPDATE biznesy SET zajety=?, owner=?, saldo=?, data = NOW() + INTERVAL 7 day WHERE id=?""t"getElementData(plr"player:uid"), "0"getElementData(biz2"id"))
restartResource(getThisResource())
end
end
end
addCommandHandler("biznes.kup"kupbiznes)


function wyplac(plr,cmd,kwota)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select saldo from biznesy where id=?",getElementData(biz2,"id"))
local saldo sal[1].saldo
if not tonumber(kwotathen
    outputChatBox("-- Biznes --",plr,255255255)
    outputChatBox("/biznes.wyplac <kwota>",plr,255255255)
    outputChatBox("Dostepne ?rodki: "..saldo,plr,255255255)
    return
end
local kwota math.floor(kwota)
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set saldo=saldo-?? where id=?",kwota,getElementData(biz2,"id"))
givePlayerMoney(plr,kwota)
outputChatBox("* Wyp?acile? "..kwota.. "PLN z biznesu!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.wyplac",wyplac)
function wbil hitElement )
if getElementType(hitElement) ~= "player" then return end
if getPedOccupiedVehicle(hitElementthen return end
pickup[hitElement] = source
local biznes source
if getElementData(biznes"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela, aby go zakupi? wpisz /biznes.kup"hitElement255255255) return end
local uid=getElementData(hitElement"player:uid")
local wlasciciel=getElementData(biznes"owner")
local nazwa=getElementData(biznes"name")
local id=getElementData(biznes"id")
local koszt=getElementData(biznes"cost")
local saldo=getElementData(biznes"saldo")
local data=getElementData(biznes,"data")
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biznes,"id"))
if sal and #sal > 0 then exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW() and id=?","brak","n",getElementData(biznes,"id")) outputChatBox("Biznes zwolniony poniewaz nie zostal oplacony w czasie !",hitElement);restartResource(getThisResource()) return end
if tonumber(uid) ~= tonumber(wlascicielthen outputChatBox("Ten biznes jest ju? zaj?ty!"hitElement255255255) return end
triggerClientEvent("gui:otworz"hitElementhitElementwlascicielnazwaidkoszt,saldo,data)
end
addEventHandler "onPickupHit"resourceRootwbil )


function cmd(plr,cmd,cost,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if not tonumber(cost) or #arg == 1 then
  outputChatBox("U?ycie: /biznes.stworz <koszt> <nazwa>"plr255255255)
  return
 end
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz"cmd)



function cmd4(plr,cmd,...)
if exports['pystories-admins']:getAdmin(plr,3) or exports['pystories-admins']:getAdmin(plr,4then
 if #arg == 0 or id then
  outputChatBox("U?ycie: /biznes.stworz2 <nazwa>"plr255255255)
  return
 end
 local cost math.random(200000,250000)
local x,y,z=getElementPosition(plr)
local name2 table.concat(arg" ")
outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255)
exports['pystories-db']:dbSet("INSERT INTO biznesy SET id=?,owner=?, xyz='?,?,?', cost=?, nazwa=?, zajety=?",id,
"brak",x,y,z,tonumber(cost),tostring(name2),"n")
restartResource(getThisResource())
end
end
addCommandHandler("biznes.stworz2"cmd4)

function przedluz(plr,cmd)
if isElementWithinColShape(plrgetElementColShape(pickup[plr])) then
local biz2 pickup[plr]
if getElementData(biz2"z") == "n" then outputChatBox("Ten biznes nie ma w?a?ciciela!"plr255255255) return end
if tonumber(getElementData(biz2"owner")) ~= tonumber(getElementData(plr"player:uid")) then outputChatBox("To nie jest tw?j biznes!"plr255255255) return end
local sal exports['pystories-db']:dbGet("select data from biznesy where data < NOW() and id=?",getElementData(biz2,"id"))
if sal and #sal > 0 then outputChatBox("Ten biznes juz nie nalezy do ciebie spozniles sie !",plr); restartResource(getThisResource()) return end
local bkoszt=getElementData(biz2"cost")
local kwota math.floor(bkoszt)
local saldo getPlayerMoney(plr)
local brakuje kwota saldo
if saldo kwota then outputChatBox("*Nie masz tyle srodk?w na koncie ("..kwota..") Brakuje ci "..brakuje.." PLN",plr,255,0,0) return end
exports['pystories-db']:dbSet("update biznesy set data=data + INTERVAL 7 day where id=?",getElementData(biz2,"id"))
takePlayerMoney(plr,kwota)
outputChatBox("* Przedluzyles biznes o 7 dni!",plr,0,255,0)
triggerClientEvent("gui:zamknij",root)
restartResource(getThisResource())
end
end
addCommandHandler("biznes.przedluz",przedluz)



function sypnijmu()
local marker getElementsByType("pickup")
for _,m in ipairs(marker) do
if getElementData(m"owner"then
if tonumber(getElementData(m"owner")) == tonumber(getElementData(source"player:uid")) then
local flortonumber(getElementData(m"dostanie"))
outputChatBox("Otrzymujesz "..flor.." PLN za posiadanie biznesu: "..getElementData(m"name")..""source255255255)
givePlayerMoney(sourceflor)
end
end
end
end
addEvent("sypnij"true)
addEventHandler("sypnij"getRootElement(), sypnijmu)


addEventHandler("onResourceStart",resourceRoot,function()
exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW()","brak","n")
setTimer(init,3000,1)
end)

local czas_restartu 60*60*1000
setTimer(function()
for i,p in pairs(getElementsByType('pickup')) do
 if #getElementsWithinColShape(getElementColShape(p)) > 0 then return end
end
restartResource(getThisResource())
end,czas_restartu,0)

addEventHandler("onResourceStop",resourceRoot, function() restartResource(getResourceFromName("guibiznes")) end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-27, 22:08


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

I co, dalej ten sam b??d?

Postaw piwo autorowi tego posta
 

 
Tagi: biznes
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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