addEventHandler ( 'onResourceStart' , resourceRoot ,
function ( )
executeSQLQuery ( ' CREATE TABLE IF NOT EXISTS aSavedSystem_ ( aAcc_ , aName_ ) ' )
end
)
function aSavedNick_ ( )
if ( not isGusetAccount ( getPlayerAccount ( source ) ) ) then
local aResult_ = executeSQLQuery ( ' SELECT * FROM aSavedSystem_ WHERE aAcc_ = ? ' , getAccountName ( getPlayerAccount ( source ) ) )
if ( aResult_ ) then
if ( type ( aResult_ ) == 'table' ) then
if ( #aResult_ == 0 ) then
executeSQLQuery ( ' INSERT INTO aSavedSystem_ ( aAcc_ , aName_ ) VALUES ( ? , ? ) ' , getAccountName ( getPlayerAccount ( source ) ) , getPlayerName ( source ) )
else
executeSQLQuery ( ' UPDATE aSavedSystem_ SET aName_ = ? WHERE aAcc_ =?', getPlayerName ( source ) , getAccountName ( getPlayerAccount ( source ) ) )
end
else
error ( '* This is not a table ' )
end
else
error ( '* No results found ' )
end
end
end
addEventHandler ( 'onPlayerLogin' , root , aSavedNick_ )
addEventHandler ( 'onPlayerQuit' , root , aSavedNick_ )
addEventHandler ( 'onPlayerChangeNick' , root ,
function ( _ , aNewNick_ )
local aResult_ = executeSQLQuery ( ' SELECT * FROM aSavedSystem_ WHERE aAcc_ = ? ' , getAccountName ( getPlayerAccount ( source ) ) )
if ( aResult_ ) then
if ( type ( aResult_ ) == 'table' ) then
if ( #aResult_ == 0 ) then
executeSQLQuery ( ' INSERT INTO aSavedSystem_ ( aAcc_ , aName_ ) VALUES ( ? , ? ) ' , getAccountName ( getPlayerAccount ( source ) ) , aNewNick_ )
else
executeSQLQuery ( ' UPDATE aSavedSystem_ SET aName_ = ? WHERE aAcc_ =?', aNewNick_ , getAccountName ( getPlayerAccount ( source ) ) )
end
else
error ( '* This is not a table ' )
end
else
error ( '* No results found ' )
end
end
)