شباب دة ملف الداتا بتاعت الحفظ فى الباك اب الى معايا
@
Ahmed Ly
@xlive
هل فى شى من هنا السبب
Datas, Query = { 'Money', 'Jewelers', 'Level', 'Exp', 'Hours', 'Bank', 'Gang-P', 'Police-P' }, executeSQLQuery
function getJSON( Player )
local Save = { }
for _, v in ipairs( Datas ) do table.insert( Save, getElementData( Player, v ) or 0 ) end
return toJSON( Save )
end
Query( 'CREATE TABLE IF NOT EXISTS SaveSystem ( Serial, Data )' )
for _, Player in ipairs( getElementsByType( 'player' ) ) do
setTimer( setPedWalkingStyle, 50, 1, Player, 0 )
local Serial, JSON = getPlayerSerial( Player ), getJSON( Player )
if ( #Query( 'SELECT * FROM SaveSystem WHERE Serial = ?', Serial ) == 0 ) then
Query ( 'INSERT INTO SaveSystem VALUES ( ? , ? ) ', Serial, JSON )
end
end
addEventHandler( 'onElementDataChange', root,
function( aData, Old, New )
if ( getElementType( source ) == 'player' ) then
for _, Value in ipairs( Datas ) do
if ( aData == Value ) then
setAccountData( getPlayerAccount( source ), aData, New )
end
end
end
end )
addEventHandler( 'onPlayerLogin', root,
function( _, Account )
setTimer(
function( source )
if ( not isElement( source ) ) then return end
for _, Data in ipairs( Datas ) do
local AccountData = getAccountData( Account, Data )
if ( AccountData ) then
setElementData( source, Data, AccountData )
end
end
exports['guimessages']:outputServer( source, '#00FF00Your data has been retrieved' )
end
, 1000, 1, source, Account )
end )
addEventHandler( 'onPlayerSpawn', root,
function( )
for _, v in ipairs( Weapons ) do
takeWeapon( source, v )
end
setTimer( setPedWalkingStyle, 50, 1, source, 0 )
end )
addEventHandler( 'onPlayerQuit', root,
function( )
local Account = getPlayerAccount( source )
if ( Account ) then
for _, Data in ipairs( Datas ) do setAccountData( Account, Data, getElementData( source, Data ) ) end
end
end )
kill = { }
addCommandHandler( 'kill',
function( Player )
if ( isTimer( kill[Player] ) ) then
killTimer( kill[Player] )
exports['guimessages']:outputServer( Player, '#FF0101The suicide process has been completed' )
setElementFrozen( Player, false )
return end
exports['guimessages']:outputServer( Player, '#FCFF01You will die after : 10 Seconds' )
exports['guimessages']:outputServer( Player, '#FCFF01To cancel /kill' )
setElementFrozen( Player, true )
kill[Player] = setTimer (
function( Player )
if ( isElement( Player ) and not isPedDead( Player ) ) then
killPed( Player )
setElementFrozen( Player, false )
end
end
, 1000 * 10, 1, Player )
end )
Weapons = { 4,36,38,35,37,42,5,6,7,8,9,10,11,12,13,15,14,18,41}
addEventHandler( 'onPlayerWasted', root,
function( _, Killer )
if ( isTimer( kill[source] ) ) then
killTimer( kill[source] )
setElementFrozen( source, false )
kill[source] = nil
end
if ( Killer and getElementType( Killer ) == 'player' and getElementData( Killer, 'Mission' ) ) then
if ( Killer and getElementType( Killer ) == 'player' ) then
local Data = ( ( ( getTeamName( getPlayerTeam( Killer ) ) == 'Police' ) and 'Police-P' ) or 'Gang-P' )
setElementData( Killer, Data , ( getElementData( Killer, Data ) or 0 ) + 1 )
end
end
end )
addCommandHandler( '77',
function( Player )
local Account = getElementData( Player, 'Account' )
if ( Account and hasObjectPermissionTo( 'user.' .. Account , 'general.adminpanel', true ) ) then
for Index = 1, 35 do outputChatBox( ' ', root ) end
exports['guimessages']:outputServer( root, '#FF0000Chats were cleaned By :#00FF00 ' .. getPlayerName( Player ) )
end
end )
addEvent( 'VehicleFIX', true )
addEventHandler( 'VehicleFIX', root,
function( )
local Money = getElementData( source, 'Money' ) or 0
if ( Money >= 5000 ) then
local Vehicle = getPedOccupiedVehicle( source )
if ( Vehicle ) then
fixVehicle( Vehicle )
setElementData( source, 'Money', Money - 5000 )
exports['guimessages']:outputServer( source, '#00FF00Your car has been repaired' )
else
exports['guimessages']:outputServer( source, '#FF0000You do not have enough money' )
end
end
end )
createPed( 0, 2036.15, 1535.68, 10.82 )