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

Wysłany: 2019-04-25, 09:10


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

Witam, chcia?bym zrobi? biznesy na moim serwerze wszystko all dzia?a ale musz? mie? scoreboard z biznesami i chcia?bym go zrobi? ale nie wiem jak pomo?e mi kto? si? do tego zabra???

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 12:43


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Co masz na my?li pisz?c 'scoreboard z biznesami'?
Co ma si? w nim znajdowa?, w jaki spos?b chcesz go utworzy?: za pomoc? DirectX czy CeGUI?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 15:11


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

"Wilq" napisał/a:

Co masz na my?li pisz?c 'scoreboard z biznesami'?
Co ma si? w nim znajdowa?, w jaki spos?b chcesz go utworzy?: za pomoc? DirectX czy CeGUI?
Co masz na my?li pisz?c 'scoreboard z biznesami'? = Mam to ?e wciskam Tab i ?eby wyskakiwa?o Nick,REP,S?u?ba,Biznes,Ping

w jaki spos?b chcesz go utworzy?: za pomoc? DirectX = Nie chc? tworzy? chc? przerobi?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 15:32


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Okej, powiedz mi - w kolumnie 'biznes' chcesz doda? nazw? biznesu czy status posiadania biznesu ("tak" ; "nie")?

Napisa?e?, ?e chcesz prerobi? scoreboard, pode?lij kod obecnego scoreboardu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 17:06


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

dxscoreboard_exports

Kod:

MAX_PRIRORITY_SLOT = 500

scoreboardColumns = {
{ ["name"] = "player:sid", ["width"] = 40, ["friendlyName"] = "SID", ["priority"]=1 },
{ ["name"] = "id", ["width"] = 25, ["friendlyName"] = "ID", ["priority"]=2},
{ ["name"] = "name", ["width"] = 170, ["friendlyName"] = "Nick", ["priority"] = 3 },
{ ["name"] = "player:srp", ["width"] = 50, ["friendlyName"] = "REP", ["priority"] = 4 },
{ ["name"] = "player:organization", ["width"] = 150, ["friendlyName"] = "Organizacja", ["priority"] = 5 },
{ ["name"] = "player:faction", ["width"] = 85, ["friendlyName"] = "S?u?ba", ["priority"] = 6 },
{ ["name"] = "ping", ["width"] = 30, ["friendlyName"] = "Ping", ["priority"] = MAX_PRIRORITY_SLOT }
}
resourceColumns = {}

function toboolean( bool )
bool = tostring( bool )
if bool == "true" then
return true
elseif bool == "false" then
return false
else
return nil
end
end

forceShowTeams = toboolean( get( "forceShowTeams" ) ) or false
forceHideTeams = toboolean( get( "forceHideTeams" ) ) or false
allowColorcodedNames = toboolean( get( "allowColorcodedNames" ) ) or false
scrollStep = tonumber( get( "scrollStep" ) ) or 1

local function iif( cond, arg1, arg2 )
if cond then
return arg1
end
return arg2
end

function scoreboardAddColumn( name, forElement, width, friendlyName, priority )
if type( name ) == "string" then
width = tonumber( width ) or 70
friendlyName = friendlyName or name
priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) )
fixPrioritySlot( priority )
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )

if forElement == getRootElement() then
if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then
for key, value in ipairs( scoreboardColumns ) do
if name == value.name then
return false
end
end
table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority } )
table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end )
if sourceResource then
if not resourceColumns[sourceResource] then resourceColumns[sourceResource] = {} end
table.insert ( resourceColumns[sourceResource], name )
end
return triggerClientEvent( getRootElement(), "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource )
end
else
return triggerClientEvent( forElement, "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource )
end
end
return false
end

function scoreboardRemoveColumn( name, forElement )
if type( name ) == "string" then
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )

if forElement == getRootElement() then
for key, value in ipairs( scoreboardColumns ) do
if name == value.name then
table.remove( scoreboardColumns, key )
for resource, content in pairs( resourceColumns ) do
table.removevalue( content, name )
end
return triggerClientEvent( getRootElement(), "doScoreboardRemoveColumn", getRootElement(), name )
end
end
else
return triggerClientEvent( forElement, "doScoreboardRemoveColumn", getRootElement(), name )
end
end
return false
end

function scoreboardClearColumns( forElement )
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )

if forElement == getRootElement() then
while ( scoreboardColumns[1] ) do
table.remove( scoreboardColumns, 1 )
resourceColumns = {}
end
return triggerClientEvent( getRootElement(), "doScoreboardClearColumns", getRootElement() )
else
return triggerClientEvent( forElement, "doScoreboardClearColumns", getRootElement() )
end
end

function scoreboardResetColumns( forElement )
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )

if forElement == getRootElement() then
while ( scoreboardColumns[1] ) do
table.remove( scoreboardColumns, 1 )
resourceColumns = {}
end
local result = triggerClientEvent( getRootElement(), "doScoreboardResetColumns", getRootElement() )
if result then
scoreboardAddColumn( "name", 200, "Name" )
scoreboardAddColumn( "ping", 40, "Ping" )
end
return result
else
return triggerClientEvent( forElement, "doScoreboardResetColumns", getRootElement(), false )
end
end

function scoreboardSetForced( forced, forElement )
if type( forced ) == "boolean" then
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
return triggerClientEvent( forElement, "doScoreboardSetForced", getRootElement(), forced )
else
return false
end
end

function scoreboardSetSortBy( name, desc, forElement )
if type( name ) == "string" or name == nil then
if name == nil then
forElement = iif( type( desc ) == "userdata" and isElement( desc ), desc, getRootElement() )
else
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
end
desc = iif( type( desc ) == "boolean", desc, true )
return triggerClientEvent( forElement, "doScoreboardSetSortBy", getRootElement(), name, desc )
else
return false
end
end

function scoreboardGetColumnPriority( name )
if type( name ) == "string" then
for key, value in ipairs( scoreboardColumns ) do
if name == value.name then
return value.priority
end
end
end
return false
end

function scoreboardSetColumnPriority( name, priority, forElement )
if type( name ) == "string" and type( priority ) == "number" then
if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then
forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
if forElement == getRootElement() then
local columnIndex = false
for key, value in ipairs( scoreboardColumns ) do
if name == value.name then
columnIndex = key
end
end
if columnIndex then
scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority
fixPrioritySlot( priority )
scoreboardColumns[columnIndex].priority = priority
table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end )
return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority )
end
else
return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority )
end
end
end
return false
end

function scoreboardForceTeamsVisible( enabled )
if type( enabled ) == "boolean" then
forceShowTeams = enabled
return true
end
return false
end

function scoreboardForceTeamsHidden( enabled )
if type( enabled ) == "boolean" then
forceHideTeams = enabled
return true
end
return false
end

function scoreboardGetColumnCount()
return #scoreboardColumns
end

function onClientDXScoreboardResourceStart()
for key, column in ipairs( scoreboardColumns ) do
triggerClientEvent( client, "doScoreboardAddColumn", getRootElement(), column.name, column.width, column.friendlyName, column.priority )
end
end
addEvent( "onClientDXScoreboardResourceStart", true )
addEventHandler( "onClientDXScoreboardResourceStart", getResourceRootElement( getThisResource() ), onClientDXScoreboardResourceStart )

function requestServerInfoHandler()
local mapmanager = getResourceFromName( "mapmanager" )
local output = {}
output.forceshowteams = forceShowTeams
output.forcehideteams = forceHideTeams
output.allowcolorcodes = allowColorcodedNames
output.scrollStep = scrollStep
output.server = getServerName()
output.players = getMaxPlayers()
output.gamemode = false
output.map = false
if mapmanager and getResourceState( mapmanager ) == "running" then
local gamemode = exports.mapmanager:getRunningGamemode()
if gamemode then
output.gamemode = getResourceInfo( gamemode, "name" ) or getResourceName( gamemode )
end
local map = exports.mapmanager:getRunningGamemodeMap()
if map then
output.map = getResourceInfo( map, "name" ) or getResourceName( map )
end
end
triggerClientEvent( source, "sendServerInfo", getRootElement(), output )
end
addEvent( "requestServerInfo", true )
addEventHandler( "requestServerInfo", getRootElement(), requestServerInfoHandler )

function removeResourceScoreboardColumns( resource )
if resourceColumns[resource] then
while resourceColumns[resource][1] do
local success = scoreboardRemoveColumn( resourceColumns[resource][1], getRootElement() )
if not success then break end
end
resourceColumns[resource] = nil
end
end
addEventHandler( "onResourceStop", getRootElement(), removeResourceScoreboardColumns )

-- Compability
addScoreboardColumn = function( name, forElement, position, size )
if type( size ) == "number" and size >= 0 and size <= 1.0 then
size = size*700
end
return scoreboardAddColumn( name, forElement, size, name, position )
end
removeScoreboardColumn = scoreboardRemoveColumn
resetScoreboardColumns = scoreboardResetColumns
setPlayerScoreboardForced = function( forElement, forced ) return scoreboardSetForced( forced, forElement ) end



function onPlayerJoinToServer()
if source then
findIDForPlayer(source)
local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
if country then
setElementData(source,"country",country)
else
setElementData(source,"country","?")
end
end
end
addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)


function findIDForPlayer(thePlayer)
if thePlayer and not getElementData(thePlayer,"ID") then
local i = 0
local players = getElementsByType("player")
repeat
local foundID = false
i = i + 1
for _,player in pairs(players) do
if player ~= thePlayer then
local playerID = tonumber(getElementData(player,"ID"))
if playerID == i then
foundID = true
break
end
end
end
until not foundID
setElementData(thePlayer,"ID",i)
end
end

function onServerIDStart()
for i,thePlayer in pairs(getElementsByType("player")) do
findIDForPlayer(thePlayer)
--local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
if country then
setElementData(source,"country",country)
else
setElementData(source,"country","?")
end
end
end
addEventHandler("onResourceStart",resourceRoot,onServerIDStart)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 17:24


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W tabeli "scoreboardColumns" masz to, co znajduje si? w scoreboardzie.

Musisz tam doda? now? linijk? zawieraj?c? poprawne dane (elementData nazwy biznesu), co? takiego:
{ ["name"] = "tutaj-elementdata-biznesu", ["width"] = 100, ["friendlyName"] = "Biznes", ["priority"] = }, 


"tutaj-elementdata-biznesu" zamie? na odpowiedni? elementDat?, w kt?rej zapisujesz nazw? biznesu gracza.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 18:42


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

W tym elementData tam mam wpisa? nazw? tabeli z MYSQL?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 18:44


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Nie, elementDat? w kt?rej zapisujesz NAZW? BIZNESU W GRZE.

Je?li nie mo?esz jej znale?? (lub jej nie zaimplementowa?e?) - pode?lij kod od biznes?w.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 18:46


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

czyli ca?y kod od biznes?w??

[ Dodano: 2019-04-25, 18:48 ]
Kod:



local SQL

local function connect()
-- w ponizszej linii uzupelnij dane autoryzacji
SQL = dbConnect("mysql", "dbname=xd;host=xd", "xd","xd","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
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 bkoszt=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['pystories-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,4) or exports['pystories-admins']:getAdmin(plr,3) then
if not tonumber(cost) or #arg == 0 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,4) or exports['pystories-admins']:getAdmin(plr,3) 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)


[ Dodano: 2019-04-25, 18:49 ]


local SQL 

local function connect() 
-- w ponizszej linii uzupelnij dane autoryzacji 
SQL dbConnect("mysql""dbname=xd;host=xd""xd","xd","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[1end 

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(vend 
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], 31274local biz2 biz 
local tw=createElement("text"local x2342=v.cost/50 
local x234 math.floor(x2342local ***** = 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*7outputDebugString(v.idlocal 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,profir1setElementData(tw"name"format1setElementPosition(twv.xyz[1], v.xyz[2], v.xyz[3]+0.8setElementData(biz2"cost"v.costsetElementData(biz2"z"v.zajetysetElementData(biz2"name"v.nazwasetElementData(biz2"id"v.idsetElementData(biz2"payday",x234setElementData(biz2"saldo",v.saldosetElementData(biz2,"data",v.datasetElementData(biz2"owner"v.ownerend 
--[[ 
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",truesetTimer(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,gateend 
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(lasthit2outputChatBox("Otrzymujesz "..lasthit.." PLN za sprzeda? swojego biznesu ("..getElementData(biz2"name")..")"plr255255255)
givePlayerMoney(plrlasthitexports["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['pystories-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!"plr255255255takePlayerMoney(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,255255255outputChatBox("/biznes.wyplac <kwota>",plr,255255255outputChatBox("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,kwotaoutputChatBox("* Wyp?acile? "..kwota.. "PLN z biznesu!",plr,0,255,0triggerClientEvent("gui:zamknij",rootrestartResource(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,dataend 
addEventHandler "onPickupHit"resourceRootwbil ) 


function cmd(plr,cmd,cost,...) 
if exports['pystories-admins']:getAdmin(plr,4) or exports['pystories-admins']:getAdmin(plr,3then 
if not tonumber(cost) or #arg == 0 then 
outputChatBox("U?ycie: /biznes.stworz <koszt> <nazwa>"plr255255255) 
return 
end 
local x,y,z=getElementPosition(plrlocal name2 table.concat(arg" "outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255exports['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,4) or exports['pystories-admins']:getAdmin(plr,3then 
if #arg == 0 or id then 
outputChatBox("U?ycie: /biznes.stworz2 <nazwa>"plr255255255) 
return 
end 
local cost math.random(200000,250000local x,y,z=getElementPosition(plrlocal name2 table.concat(arg" "outputChatBox("Pomy?lnie utworzy?e? nowy biznes o nazwie "..name2.." za "..cost.." PLN"plr255255255exports['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(bkosztlocal saldo getPlayerMoney(plrlocal 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,kwotaoutputChatBox("* Przedluzyles biznes o 7 dni!",plr,0,255,0triggerClientEvent("gui:zamknij",rootrestartResource(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")..""source255255255givePlayerMoney(sourceflorend 
end 
end 
end 
addEvent("sypnij"trueaddEventHandler("sypnij"getRootElement(), sypnijmuaddEventHandler("onResourceStart",resourceRoot,function() 
exports['pystories-db']:dbSet("UPDATE biznesy SET owner=?,zajety=? WHERE data < NOW()","brak","n"setTimer(init,3000,1endlocal 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,0addEventHandler("onResourceStop",resourceRoot, function() restartResource(getResourceFromName("guibiznes")) end


[ Dodano: 2019-04-25, 19:03 ]
Wilq, jeste???

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 20:19


AmaMa.

AmaMa.#3768






Wiek: 25
Na forum: 3207 dni
Posty: 182
Nick w MP: AmaMa.

Piwa: 1825

Respekt: 165,3
Respekt: 165,3Respekt: 165,3

NotRed, Kod nie jest przystosowany do tego, aby w scoreboard by?y wy?wietlane biznesy. Dany gracz nie ma przypisanych biznes?w elementdat?, je?li chcesz, ?eby by?y one wymienione po "," musisz w kodzie scoreboard pobra? z bazy danych posiadane biznesy dla danego gracza, a p??niej wy?wietli? je w stringu. Je?li ma by? na tabie Biznes i "Tak"/"Nie" to r?wnie? musisz pobra? z bazy danych posiadane biznesy i je?li jest wi?cej ni? 0 to ustawia napis "Tak". Pami?taj r?wnie?, aby exporty z bazy danych by?y wykonywane przy ka?dym naci?nieciu przycisku "Tab", aby si? od?wie?a?y.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 21:19


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

Zglaszam r?wnie? 1 problem

1.Zrobi?em ca?y biznes w SF na doherty nazwa?em go Mechanik i jak wejd? w blip $ oraz wpisz? komend? /biznes.kup to mi go nie kupuje mo?e wiesz co? na ten temat?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 22:10


AmaMa.

AmaMa.#3768






Wiek: 25
Na forum: 3207 dni
Posty: 182
Nick w MP: AmaMa.

Piwa: 1825

Respekt: 165,3
Respekt: 165,3Respekt: 165,3

NotRed, Debugscript co? pokazuje?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 23:10


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

Nic.

[ Dodano: 2019-04-25, 23:10 ]
Baza danych podpi?ta itp

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-25, 23:25


AmaMa.

AmaMa.#3768






Wiek: 25
Na forum: 3207 dni
Posty: 182
Nick w MP: AmaMa.

Piwa: 1825

Respekt: 165,3
Respekt: 165,3Respekt: 165,3

NotRed, Czy skrypt posiada uprawnienia ACL administratora? Musisz doda? do jednego z 3 skrypt?w na biznesy, bodaj?e tym z GUI. Wtedy skrypt od?wie?a biznesy i mo?e dzia?aj? Ci, ale nie maj? praw administratora i nie dzia?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-26, 15:18


NotRed







Wiek: 20
Na forum: 2629 dni
Posty: 24
Nick w MP: KONTO NIE AKTYWNE

Piwa: 64

Respekt: 50

AmaMa, nada?em im prawa administratora i tak jest jak by?o wpisuje /biznes.kup i nie chce si? kupi? wszystko mam podpi?te jak nale?y.

Postaw piwo autorowi tego posta
 

 
Tagi: scoreboard :: pys :: 3.0 :: biznesy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku