Jump to content

سؤال بسيط


Recommended Posts

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
)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...