@Memory
function onResStart ()
executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Points ( serial TEXT, points INTEGER DEFAULT 0 )" );
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), onResStart )
--------------------------------
function onJoin ( )
local serial = getPlayerSerial ( source );
local getPoints = executeSQLQuery ( "SELECT points FROM Points WHERE serial=?", serial );
if type ( getPoints ) == "table" and #getPoints > 0 and getPoints[1] and getPoints[1].points then
setElementData ( source, "Points", tonumber ( getPoints[1].points ) );
else
executeSQLQuery ( "INSERT INTO Points VALUES ( ?, ? )", serial, 0 );
setElementData ( source, "Points", 0 );
end
end
addEventHandler ( "onPlayerJoin", root, onJoin)
----------------------------------------
function onPlayerQuit ( )
local getActualPoints = tonumber ( getElementData ( source, "Points" ) );
local serial = getPlayerSerial ( source );
local sql = executeSQLQuery ( "SELECT points FROM Points WHERE serial=?", serial );
executeSQLQuery ( "UPDATE Points SET points=? WHERE serial=?", getActualPoints, serial );
end
addEventHandler("onPlayerQuit", root, onPlayerQuit)
@~Gangsta~ на обоих