Sugarakabongo
Wiek: 20 Na forum: 1405 dni Posty: 6
Nick w MP: jasiek
Piwa : 11
Czesc, przychodze z problemem takim, gdzie przy tworzeniu organizacji przestepczej komendą, trzeba restartowac skrypt z organizacjami, po reconnect i tak znika. W db2 nie ma błędu tylko czasem wyskakuje
tutaj kod z organizacji po stronie clienta i servera client -
local sx , sy = guiGetScreenSize ()
local zoom = exports [ "borsuk-gui" ]: getZoom ()
local font1 = exports [ "borsuk-gui" ]: getFont ( "Lato-Regular" , 15 / zoom )
local font2 = exports [ "borsuk-gui" ]: getFont ( "Lato-Regular" , 18 / zoom )
local font3 = exports [ "borsuk-gui" ]: getFont ( "Lato-Regular" , 13 / zoom )
local marker = createMarker ( 2848.49 , - 1124.80 , 113.33 - 1 , "cylinder" , 1 , 50 , 170 , 255 )
setElementDimension ( marker , 1 )
setElementData ( marker , "marker:title" , "Organizacja" )
setElementData ( marker , "marker:desc" , "Tworzenie organizacji" )
addEventHandler ( "onClientMarkerHit" , marker , function( plr )
if plr ~= localPlayer then return end
showOrgCreate ()
end )
addEventHandler ( "onClientMarkerHit" , marker2 , function( plr )
if plr ~= localPlayer then return end
showOrgCreate ()
end )
function renderOrgCreate ()
dxDrawRectangle ( sx / 2 - 228 / zoom , sy / 2 - 230 / zoom , 456 / zoom , 500 / zoom , tocolor ( 55 , 55 , 55 ))
dxDrawRectangle ( sx / 2 - 225 / zoom , sy / 2 - 230 / zoom , 450 / zoom , 500 / zoom , tocolor ( 20 , 20 , 20 ))
dxDrawRectangle ( sx / 2 - 225 / zoom , sy / 2 - 170 / zoom , 450 / zoom , 1 , tocolor ( 35 , 35 , 35 ))
dxDrawText ( "Tworzenie organizacji" , sx / 2 , sy / 2 - 400 / zoom , sx / 2 , sy / 2 , tocolor ( 255 , 255 , 255 , 80 ), 1 , font2 , "center" , "center" )
dxDrawText ( "• Nazwy nie można zmienić\n• Maksymalnie 15 osób z możliwością ulepszenia\n• Wymagany 10 poziom\n• Koszt założenia wynosi 100,000 PLN\n• Organizacje przestępcze wymagają podania" , sx / 2 , sy / 2 - 150 / zoom , sx / 2 , sy / 2 , tocolor ( 255 , 255 , 255 , 150 ), 1 , font3 , "center" , "top" )
dxDrawRectangle ( sx / 2 + 107 / zoom - 1 , sy / 2 + 95 / zoom - 1 , 40 / zoom + 2 , 40 / zoom + 2 , tocolor ( 55 , 55 , 55 ))
local kolor = exports [ "borsuk-gui" ]: getEditboxText ( hex )
if #kolor == 6 or #kolor == 7 then
local r , g , b = hex2rgb ( kolor )
if r and g and b then
dxDrawRectangle ( sx / 2 + 107 / zoom , sy / 2 + 95 / zoom , 40 / zoom , 40 / zoom , tocolor ( r , g , b ))
end
end
end
server -
addCommandHandler ( "rape" , function( plr , cmd , target )
if getElementData ( plr , "player:level" ) < 3 then return end
if not target then return end
local cel = findPlayer ( plr , target )
if not cel then end
local x , y , z = getPositionFromElementOffset ( cel , 0 , 1 , 0 )
setElementPosition ( plr , x , y , z )
local rx , ry , rz = getElementRotation ( cel )
setElementRotation ( plr , rx , ry , rz + 180 )
toggleAllControls ( cel , false )
setPedAnimation ( cel , "sex" , "sex_1_cum_w" , - 1 , true , false )
setPedAnimation ( plr , "sex" , "sex_1_cum_p" , - 1 , true , false )
end )
addCommandHandler ( "rapes" , function( plr , cmd , target )
if getElementData ( plr , "player:level" ) < 3 then return end
if not target then return end
local cel = findPlayer ( plr , target )
if not cel then end
toggleAllControls ( cel , true )
setPedAnimation ( cel , false )
setPedAnimation ( plr , false )
end )
function getPositionFromElementOffset ( element , offX , offY , offZ )
local m = getElementMatrix ( element ) -- Get the matrix
local x = offX * m [ 1 ][ 1 ] + offY * m [ 2 ][ 1 ] + offZ * m [ 3 ][ 1 ] + m [ 4 ][ 1 ] -- Apply transform
local y = offX * m [ 1 ][ 2 ] + offY * m [ 2 ][ 2 ] + offZ * m [ 3 ][ 2 ] + m [ 4 ][ 2 ]
local z = offX * m [ 1 ][ 3 ] + offY * m [ 2 ][ 3 ] + offZ * m [ 3 ][ 3 ] + m [ 4 ][ 3 ]
return x , y , z -- Return the transformed point
end
function findPlayer ( plr , cel )
local target = nil
if ( tonumber ( cel ) ~= nil ) then
target = getElementByID ( "p" .. cel )
else -- podano fragment nicku
for _ , thePlayer in ipairs ( getElementsByType ( "player" )) do
if string . find ( string . gsub ( getPlayerName ( thePlayer ): lower (), "#%x%x%x%x%x%x" , "" ), cel : lower (), 0 , true ) then
if ( target ) then
outputChatBox ( "* Znaleziono więcej niż jednego gracza o pasującym nicku, podaj więcej liter." , plr )
return nil
end
target = thePlayer
end
end
end
if target and getElementData ( target , "p:inv" ) then return nil end
return target
end
function getOrganizationData ( oid )
local q = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM `borsuk-organizacje` WHERE id=?" , oid )
return ( q and q [ 1 ] or false )
end
function loadPlayerOrg ( player )
if isElement ( player ) and player then
if getElementType ( player ) ~= "player" then return end
local sid = getElementData ( player , "player:sid" )
if not sid then return end
local q = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM `borsuk-orgs` WHERE sid=?" , sid )
if #q == 0 then
setElementData ( player , "player:organization" , false )
setElementData ( player , "player:organization:data" , false )
return
end
local data = getOrganizationData ( q [ 1 ][ "org" ])
if data then
setElementData ( player , "player:organization" , data [ "name" ])
setElementData ( player , "player:organization:data" , data )
else
setElementData ( player , "player:organization" , false )
setElementData ( player , "player:organization:data" , false )
end
for _ , stat in ipairs ({ 24 , 69 , 70 , 71 , 72 , 73 , 74 , 76 , 77 , 78 , 79 }) do
setPedStat ( player , stat , 1000 )
end
end
end
addEvent ( "loadPlayerOrg" , true )
addEventHandler ( "loadPlayerOrg" , root , loadPlayerOrg )
addEvent ( "load:player" , true )
addEventHandler ( "load:player" , root , loadPlayerOrg )
local clickTick = {}
for k , v in pairs ( getElementsByType ( "player" )) do
loadPlayerOrg ( v )
end
addEvent ( "createOrg" , true )
addEventHandler ( "createOrg" , root , function( name , tag , r , g , b )
if ( clickTick [ source ] or 0 ) > getTickCount () then return end
local color = r .. "," .. g .. "," .. b
if getPlayerMoney ( source ) < 100000 then
return exports [ "noobisty-notyfikacje" ]: createNotification ( source , "Tworzenie organizacji" , "Nie posiadasz 200,000 PLN" , { 255 , 50 , 50 }, "sighter" )
end
local q = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM `borsuk-organizacje` WHERE `tag`=?" , tag : upper ())
if #q > 0 then
exports [ "noobisty-notyfikacje" ]: createNotification ( source , "Tworzenie organizacji" , "Organizacja z takim TAG'iem już istnieje" , { 255 , 50 , 50 }, "sighter" )
return
end
local q = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM `borsuk-organizacje` WHERE `name`=?" , name )
if #q > 0 then
exports [ "noobisty-notyfikacje" ]: createNotification ( source , "Tworzenie organizacji" , "Organizacja z taką nazwą już istnieje" , { 255 , 50 , 50 }, "sighter" )
return
end
local q = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM `borsuk-organizacje` WHERE `color`=?" , color )
if #q > 0 then
exports [ "noobisty-notyfikacje" ]: createNotification ( source , "Tworzenie organizacji" , "Organizacja z takim kolorem już istnieje" , { 255 , 50 , 50 }, "sighter" )
return
end
local sid = getElementData ( source , "player:sid" )
local q , _ , oid = exports [ "pystories-db" ]: dbGet ( "INSERT INTO `borsuk-organizacje`(`name`, `spawn`, `tag`, `color`, `owner`) VALUES (?,?,?,?,?)" , name , "false" , tag : upper (), color , sid )
takePlayerMoney ( source , 100000 )
exports [ "noobisty-notyfikacje" ]: createNotification ( source , "Tworzenie organizacji" , "Stworzono organizację " .. name , { 50 , 255 , 50 }, "sight" )
exports [ "pystories-db" ]: dbGet ( "INSERT INTO `borsuk-orgs`(`sid`, `org`, `level`) VALUES (?,?,?)" , sid , oid , 4 )
clickTick [ source ] = getTickCount ()+ 3000
end )
local types = {
[ 'normal' ] = nil ,
[ 'crime' ] = true ,
}
function findPlayerBySID ( sid )
for i , v in ipairs ( getElementsByType ( 'player' )) do
if getElementData ( v , "player:sid" ) == sid then
return v
end
end
end
function addOrganization ( plr , cmd , name , tag , type , sid , r , g , b )
if not name or not tag or not type or not sid or not r or not g or not b then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "/stworz.org <nazwa> <tag> <typ> <sid> <r> <g> <b>" , { 200 , 50 , 50 }, "sighter" )
end
if 3 >= name : len () then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Podaj dłuższą nazwę organizacji" , { 200 , 50 , 50 }, "sighter" )
end
if 3 >= type : len () then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Podaj typ organizacji (crime/normal)" , { 200 , 50 , 50 }, "sighter" )
end
if 2 >= tag : len () then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Podaj tag organizacji" , { 200 , 50 , 50 }, "sighter" )
end
if 0 >= sid : len () then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Podaj sid właściciela" , { 200 , 50 , 50 }, "sighter" )
end
if 0 >= r : len () or 0 >= b : len () or 0 >= g : len () then
return exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Podaj kolor organizacji" , { 200 , 50 , 50 }, "sighter" )
end
local orgType = types [ type ]
local q , _ , oid = exports [ "pystories-db" ]: dbGet ( "INSERT INTO `borsuk-organizacje`(`name`, `spawn`, `tag`, `color`, `owner`, `crime`) VALUES (?,?,?,?,?,?)" , name , "false" , tag : upper (), r .. ',' .. g .. ',' .. b , sid , orgType )
exports [ "pystories-db" ]: dbGet ( "INSERT INTO `borsuk-orgs`(`sid`, `org`, `level`) VALUES (?,?,?)" , sid , oid , 4 )
local findPlayer = findPlayerBySID ( sid )
if findPlayer and getElementType ( findPlayer ) == "player" then
loadPlayerOrg ( findPlayer )
exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Stworzono organizację " .. name .. " dla gracza " .. getPlayerName ( findPlayer ), { 50 , 255 , 50 }, "sight" )
else
exports [ "noobisty-notyfikacje" ]: createNotification ( plr , "Tworzenie organizacji" , "Stworzono organizację " .. name .. " dla gracza o SID " .. sid , { 50 , 255 , 50 }, "sight" )
end
end
addCommandHandler ( "stworz.org" , addOrganization )
function globalMessage ( plr , cmd , ...)
local organization = getElementData ( plr , 'player:organization' )
if not organization then
return
end
local msg = table . concat ( { ... }, " " )
local orgplayers = getElementsByType ( 'player' )
for i , v in pairs ( orgplayers ) do
local organization1 = getElementData ( v , 'player:organization' )
if organization == organization1 then
outputChatBox ( "#747474" .. organization1 .. "#FFFFFF > " .. getPlayerName ( plr ): gsub ( "#%x%x%x%x%x%x" , "" ).. "#FFFFFF:#FFFFFF " .. msg : gsub ( "#%x%x%x%x%x%x" , "" ), v , _ , _ , _ , true )
end
end
local desc = "[#747474ORGANIZACJA#ffffff] [" .. getElementData ( plr , "id" ).. "]" .. getPlayerName ( plr ): gsub ( "#%x%x%x%x%x%x" , "" ).. "(" .. getElementData ( plr , "player:organization" ).. "): " .. msg : gsub ( "#%x%x%x%x%x%x" , "" ).. ""
triggerEvent ( "admin:addText" , resourceRoot , desc : gsub ( "#%x%x%x%x%x%x" , "" ))
end
addCommandHandler ( "Organizacja" , globalMessage )
addEventHandler ( "onPlayerJoin" , root , function()
bindKey ( source , "o" , "down" , "chatbox" , "Organizacja" )
end )
pystories-core s_saveplayers
local n , v = "serpent" , "0.302" -- ( C ) 2012 - 18 Paul Kulchenko ; MIT License
local c , d = "Paul Kulchenko" , "Lua serializer and pretty printer"
local snum = {[ tostring ( 1 / 0 )]= '1/0 --[[math.huge]]' ,[ tostring (- 1 / 0 )]= '-1/0 --[[-math.huge]]' ,[ tostring ( 0 / 0 )]= '0/0' }
local badtype = { thread = true , userdata = true , cdata = true }
local getmetatable = debug and debug . getmetatable or getmetatable
local pairs = function( t ) return next , t end -- avoid using __pairs in Lua 5.2 +
local keyword , globals , G = {}, {}, ( _G or _ENV )
for _ , k in ipairs ({ 'and' , 'break' , 'do' , 'else' , 'elseif' , 'end' , 'false' ,
'for' , 'function' , 'goto' , 'if' , 'in' , 'local' , 'nil' , 'not' , 'or' , 'repeat' ,
'return' , 'then' , 'true' , 'until' , 'while' }) do keyword [ k ] = true end
for k , v in pairs ( G ) do globals [ v ] = k end -- build func to name mapping
for _ , g in ipairs ({ 'coroutine' , 'debug' , 'io' , 'math' , 'string' , 'table' , 'os' }) do
for k , v in pairs ( type ( G [ g ]) == 'table' and G [ g ] or {}) do globals [ v ] = g .. '.' .. k end end
local function s ( t , opts )
local name , indent , fatal , maxnum = opts . name , opts . indent , opts . fatal , opts . maxnum
local sparse , custom , huge = opts . sparse , opts . custom , not opts . nohuge
local space , maxl = ( opts . compact and '' or ' ' ), ( opts . maxlevel or math . huge )
local maxlen , metatostring = tonumber ( opts . maxlength ), opts . metatostring
local iname , comm = '_' ..( name or '' ), opts . comment and ( tonumber ( opts . comment ) or math . huge )
local numformat = opts . numformat or "%.17g"
local seen , sref , syms , symn = {}, { 'local ' .. iname .. '={}' }, {}, 0
local function gensym ( val ) return '_' ..( tostring ( tostring ( val )): gsub ( "[^%w]" , "" ): gsub ( "(%d%w+)" ,
-- tostring ( val ) is needed because __tostring may return a non - string value
function( s ) if not syms [ s ] then symn = symn + 1 ; syms [ s ] = symn end return tostring ( syms [ s ]) end )) end
local function safestr ( s ) return type ( s ) == "number" and tostring ( huge and snum [ tostring ( s )] or numformat : format ( s ))
or type ( s ) ~= "string" and tostring ( s ) -- escape NEWLINE / 010 and EOF / 026
or ( "%q" ): format ( s ): gsub ( "0" , "n" ): gsub ( "6" , "\026" ) end
local function comment ( s , l ) return comm and ( l or 0 ) < comm and ' --[[' .. select ( 2 , pcall ( tostring , s )).. ']]' or '' end
local function globerr ( s , l ) return globals [ s ] and globals [ s ].. comment ( s , l ) or not fatal
and safestr ( select ( 2 , pcall ( tostring , s ))) or error ( "Can't serialize " .. tostring ( s )) end
local function safename ( path , name ) -- generates foo . bar , foo [ 3 ], or foo [ 'b a r' ]
local n = name == nil and '' or name
local plain = type ( n ) == "string" and n : match ( "^[%l%u_][%w_]*$" ) and not keyword [ n ]
local safe = plain and n or '[' .. safestr ( n ).. ']'
return ( path or '' )..( plain and path and '.' or '' ).. safe , safe end
local alphanumsort = type ( opts . sortkeys ) == 'function' and opts . sortkeys or function( k , o , n ) -- k = keys , o = originaltable , n = padding
local maxn , to = tonumber ( n ) or 12 , { number = 'a' , string = 'b' }
local function padnum ( d ) return ( "%0" .. tostring ( maxn ).. "d" ): format ( tonumber ( d )) end
table . sort ( k , function( a , b )
-- sort numeric keys first : k [ key ] is not nil for numerical keys
return ( k [ a ] ~= nil and 0 or to [ type ( a )] or 'z' )..( tostring ( a ): gsub ( "%d+" , padnum ))
< ( k [ b ] ~= nil and 0 or to [ type ( b )] or 'z' )..( tostring ( b ): gsub ( "%d+" , padnum )) end ) end
local function val2str ( t , name , indent , insref , path , plainindex , level )
local ttype , level , mt = type ( t ), ( level or 0 ), getmetatable ( t )
local spath , sname = safename ( path , name )
local tag = plainindex and
(( type ( name ) == "number" ) and '' or name .. space .. '=' .. space ) or
( name ~= nil and sname .. space .. '=' .. space or '' )
if seen [ t ] then -- already seen this element
sref [ #sref+1] = spath..space..'='..space..seen[t]
return tag .. 'nil' .. comment ( 'ref' , level ) end
-- protect from those cases where __tostring may fail
if type ( mt ) == 'table' and metatostring ~= false then
local to , tr = pcall (function() return mt . __tostring ( t ) end )
local so , sr = pcall (function() return mt . __serialize ( t ) end )
if ( to or so ) then -- knows how to serialize itself
seen [ t ] = insref or spath
t = so and sr or tr
ttype = type ( t )
end -- new value falls through to be serialized
end
if ttype == "table" then
if level >= maxl then return tag .. '{}' .. comment ( 'maxlvl' , level ) end
seen [ t ] = insref or spath
if next ( t ) == nil then return tag .. '{}' .. comment ( t , level ) end -- table empty
if maxlen and maxlen < 0 then return tag .. '{}' .. comment ( 'maxlen' , level ) end
local maxn , o , out = math . min ( #t, maxnum or #t), {}, {}
for key = 1 , maxn do o [ key ] = key end
if not maxnum or #o < maxnum then
local n = #o -- n = n + 1; o[n] is much faster than o[#o+1] on large tables
for key in pairs ( t ) do if o [ key ] ~= key then n = n + 1 ; o [ n ] = key end end end
if maxnum and #o > maxnum then o[maxnum+1] = nil end
if opts . sortkeys and #o > maxn then alphanumsort(o, t, opts.sortkeys) end
local sparse = sparse and #o > maxn -- disable sparsness if only numeric keys (shorter output)
for n , key in ipairs ( o ) do
local value , ktype , plainindex = t [ key ], type ( key ), n <= maxn and not sparse
if opts . valignore and opts . valignore [ value ] -- skip ignored values ; do nothing
or opts . keyallow and not opts . keyallow [ key ]
or opts . keyignore and opts . keyignore [ key ]
or opts . valtypeignore and opts . valtypeignore [ type ( value )] -- skipping ignored value types
or sparse and value == nil then -- skipping nils ; do nothing
elseif ktype == 'table' or ktype == 'function' or badtype [ ktype ] then
if not seen [ key ] and not globals [ key ] then
sref [ #sref+1] = 'placeholder'
local sname = safename ( iname , gensym ( key )) -- iname is table for local variables
sref [ #sref] = val2str(key,sname,indent,sname,iname,true) end
sref [ #sref+1] = 'placeholder'
local path = seen [ t ].. '[' .. tostring ( seen [ key ] or globals [ key ] or gensym ( key )).. ']'
sref [ #sref] = path..space..'='..space..tostring(seen[value] or val2str(value,nil,indent,path))
else
out [ #out+1] = val2str(value,key,indent,nil,seen[t],plainindex,level+1)
if maxlen then
maxlen = maxlen - #out[#out]
if maxlen < 0 then break end
end
end
end
local prefix = string . rep ( indent or '' , level )
local head = indent and '{\n' .. prefix .. indent or '{'
local body = table . concat ( out , ',' ..( indent and '\n' .. prefix .. indent or space ))
local tail = indent and "\n" .. prefix .. '}' or '}'
return ( custom and custom ( tag , head , body , tail , level ) or tag .. head .. body .. tail ).. comment ( t , level )
elseif badtype [ ttype ] then
seen [ t ] = insref or spath
return tag .. globerr ( t , level )
elseif ttype == 'function' then
seen [ t ] = insref or spath
if opts . nocode then return tag .. "function() --[[..skipped..]] end" .. comment ( t , level ) end
local ok , res = pcall ( string . dump , t )
local func = ok and "((loadstring or load)(" .. safestr ( res ).. ",'@serialized'))" .. comment ( t , level )
return tag ..( func or globerr ( t , level ))
else return tag .. safestr ( t ) end -- handle all other types
end
local sepr = indent and "\n" or ";" .. space
local body = val2str ( t , name , indent ) -- this call also populates sref
local tail = #sref>1 and table.concat(sref, sepr)..sepr or ''
local warn = opts . comment and #sref>1 and space.."--[[incomplete output with shared/self-references skipped]]" or ''
return not name and body .. warn or "do local " .. body .. sepr .. tail .. "return " .. name .. sepr .. "end"
end
local function deserialize ( data , opts )
local env = ( opts and opts . safe == false ) and G
or setmetatable ({}, {
__index = function( t , k ) return t end ,
__call = function( t ,...) error ( "cannot call functions" ) end
})
local f , res = ( loadstring or load )( 'return ' .. data , nil , nil , env )
if not f then f , res = ( loadstring or load )( data , nil , nil , env ) end
if not f then return f , res end
if setfenv then setfenv ( f , env ) end
return pcall ( f )
end
local function merge ( a , b ) if b then for k , v in pairs ( b ) do a [ k ] = v end end ; return a ; end
serpent = { _NAME = n , _COPYRIGHT = c , _DESCRIPTION = d , _VERSION = v , serialize = s ,
load = deserialize ,
dump = function( a , opts ) return s ( a , merge ({ name = '_' , compact = true , sparse = true }, opts )) end ,
line = function( a , opts ) return s ( a , merge ({ sortkeys = true , comment = true }, opts )) end ,
block = function( a , opts ) return s ( a , merge ({ indent = ' ' , sortkeys = true , comment = true }, opts )) end }
function getPremium ( plr , premium )
if premium then
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=? AND premium=?" , getElementData ( plr , "player:sid" ), premium )
if result and #result > 0 then
return true
else
return false
end
else
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , getElementData ( plr , "player:sid" ))
if result and #result > 0 then
return true
else
return false
end
end
end
function loadPlayerData ( plr )
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , getElementData ( plr , "player:sid" ))
if result and #result > 0 then
triggerEvent ( "loadPlayerOrg" , plr , plr )
local v = result [ 1 ]
setPlayerMoney ( plr , v . money )
setElementModel ( plr , v . skin )
setElementData ( plr , "player:license:pjA" , v . pjA )
setElementData ( plr , "player:license:pjB" , v . pjB )
setElementData ( plr , "player:license:pjC" , v . pjC )
setElementData ( plr , "player:license:pjL" , v . pjL )
setElementData ( plr , "player:workinjob" , v . worker )
setElementData ( plr , "player:registerdate" , v . registered )
setElementData ( plr , "player:hours" , v . hours )
setElementData ( plr , "player:skin" , v . skin )
setElementData ( plr , "player:lvl" , v . lvl )
setElementData ( plr , "player:exp" , v . exp )
setElementData ( plr , "player:pp" , v . premiumpoints )
setElementData ( plr , "player:upgrades" , loadstring (( v . upgrades and #v.upgrades > 3) and v.upgrades or "return {}")())
setElementData ( plr , "player:skinShop" , loadstring (( v . skinShop and #v.skinShop > 3) and v.skinShop or "return {}")())
setElementData ( plr , "player:inventory" , loadstring (( v . inventory and #v.inventory > 3) and v.inventory or "return {}")())
setElementData ( plr , "player:shaders" , loadstring (( v . shaders and #v.shaders > 3) and v.shaders or "return {}")())
setElementData ( plr , "player:boughtvinyls" , loadstring (( v . boughtvinyls and #v.boughtvinyls > 3) and v.boughtvinyls or "return {}")())
setElementData ( plr , "player:ratedvinyls" , loadstring (( v . ratedvinyls and #v.ratedvinyls > 3) and v.ratedvinyls or "return {}")())
setElementData ( plr , "player:shownTips" , loadstring (( v . tips and #v.tips > 3) and v.tips or "return {}")())
triggerClientEvent ( plr , "switchShaders" , plr , ( getElementData ( plr , "player:shaders" ) or {}))
local mute = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_punish WHERE type=? AND active=1 AND serial=? AND time>NOW() LIMIT 1;" , "mute" , getPlayerSerial ( plr ))
if mute and #mute > 0 then
setElementData ( plr , 'mute:player' , true )
end
local discordInfo = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM discord_connect WHERE sid=?" , getElementData ( plr , "player:sid" ))
if discordInfo and #discordInfo > 0 then
setElementData ( plr , 'player:avatar' , discordInfo [ 1 ]. avatarurl )
end
local queryB = string . format ( "SELECT * FROM pystories_users WHERE id=%d AND premiumdate>NOW() LIMIT 1" , getElementData ( plr , "player:sid" ))
local resultB = exports [ "DB2" ]: pobierzWyniki ( queryB )
if ( resultB ) then
end
local org = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1" , getElementData ( plr , "player:organization" ), getElementData ( plr , "player:sid" ))
if org and #org > 0 then
setElementData ( plr , "player:organization" , org [ 1 ]. code )
outputChatBox ( "#FF8C00>> #FFFFFFJeste? w organizacji, kt?ra nosi nazwe: " .. org [ 1 ]. code .. "" , plr , 0 , 0 , 0 , true )
exports [ 'pystories-db' ]: dbSet ( "UPDATE ms_organizacje SET actived=curdate() WHERE uid=?" , getElementData ( plr , "player:sid" ))
end
setElementData ( plr , "player:premiumplus" , true )
setElementData ( plr , "player:premiumplusdate" , result [ 1 ]. premiumdate )
outputChatBox ( "✓ #ffffffPosiadasz zakupioną usługę #4093ffPremium+#ffffff #bfbfbf(Ważne do " .. result [ 1 ]. premiumdate .. ")#ffffff" , plr , 0 , 255 , 0 , true )
else
setElementData ( plr , "player:premium" , true )
end
return true
end
end
addEvent ( "load:player" , true )
addEventHandler ( "load:player" , root , function( player )
if isElement ( player ) and player then
if getElementType ( player ) ~= "player" then return end
loadPlayerData ( player )
end
end )
function savePlayerData ( plr )
local sid = getElementData ( plr , "player:sid" )
if not getElementData ( plr , "player:spawn" ) then return end
if not sid then return end
local money = getPlayerMoney ( plr )
local licensea = getElementData ( plr , "player:license:pjA" )
local licenseb = getElementData ( plr , "player:license:pjB" )
local licensec = getElementData ( plr , "player:license:pjC" )
local licensel = getElementData ( plr , "player:license:pjL" )
local lvl = getElementData ( plr , "player:lvl" ) or 0
local exp = getElementData ( plr , "player:exp" ) or 0
local worker = getElementData ( plr , "player:workinjob" )
local hours = tonumber ( getElementData ( plr , "player:hours" )) or 0
local upgrades = getElementData ( plr , "player:upgrades" ) or {}
local skinShop = getElementData ( plr , "player:skinShop" ) or {}
local shaders = getElementData ( plr , "player:shaders" ) or {}
local skin = getElementData ( plr , "player:skin" ) or 0
local pp = getElementData ( plr , "player:pp" ) or 0
local inventory = getElementData ( plr , "player:inventory" ) or {}
local boughtvinyls = getElementData ( plr , "player:boughtvinyls" ) or {}
local ratedvinyls = getElementData ( plr , "player:ratedvinyls" ) or {}
local shownTips = getElementData ( plr , "player:shownTips" ) or {}
-- outputServerLog ( getPlayerName ( plr ) .. "," .. sid .. "," .. serpent . dump ( inventory ).. "," .. serpent . dump ( upgrades ).. "," .. money )
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_users SET money=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=?, upgrades=?, skinShop=?, inventory=?, skin=?, exp=?, lvl=?, premiumpoints=?, shaders=?, boughtvinyls=?, ratedvinyls=?, tips=? WHERE id=?" ,
money , licensea , licenseb , licensec , licensel , worker , hours , serpent . dump ( upgrades ), serpent . dump ( skinShop ), serpent . dump ( inventory ), skin , exp , lvl , pp , serpent . dump ( shaders ), serpent . dump ( boughtvinyls ), serpent . dump ( ratedvinyls ), serpent . dump ( shownTips ), sid )
end
addEvent ( "save:player" , true )
addEventHandler ( "save:player" , root , function( player )
if getElementType ( player ) ~= "player" then return end
savePlayerData ( player )
end )
addEventHandler ( "onPlayerQuit" , root , function() savePlayerData ( source ) end )
setTimer ( function()
for i , v in ipairs ( getElementsByType ( "player" )) do
if getElementData ( v , "player:sid" ) then
savePlayerData ( v )
end
end
end , 60000 * 5 , 0 )
Jeśli ktoś da rade z góry dzięki! daje piwko odrazu
Ostatnio zmieniony przez TheSebaPL 2023-12-27, 22:44, w całości zmieniany 1 raz