Jump to content

طلب فنكشنات


Recommended Posts

طيب ليه الالمنت داتا دامك راح تحفظها بالسكل خليها سكل مره وحده وخلاص

+ الفنكشنات 

"onResourceStart"
"onPlayerJoin"
"onPlayerChangeNick"
getPlayerSerial
getPlayerName
executeSQLQuery

طبعا تقول ليه السريال 

عشان لاغير الاعب اسمه او دخل السيرفر تجيب سرياله وتحقق انه ماهب موجود بالقاعدة وتحط اسم

واذا كان موجود له اسم تحقق انه مايساوي الاسم الي دخل فيه وسويله ابديت

 

  • Like 2
Link to comment

انا مسوي نقاط وبحفظهن ع السريال

محاولتي 

addEventHandler ( "onResourceStart", resourceRoot,
    function ()
        executeSQLQuery  ('CREATE TABLE IF NOT EXISTS 'TABLE' ( playerSerail,Data ) ')
   end
)


addEventHandler("onPlayerQuit ", root,
 function(player)
    local playerSerail = getPlayerSerial(player)
    local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE playerSerail=?',playerSerail )
	local data = getElementData (player,"data")or not 0 
	if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then 
	executeSQLQuery ('INSERT INTO 'TABLE' (playerSerail,data) VALUES ( ? , ?)' playerSerail, data)
  else
    executeSQLQuery (' UPDATE 'TABLE' SET playerSerail = ? , data = ?' playerSerail , data)
    end 
 end
)

addEventHandler ("onPlayerJoin", root,
 function(player)
    local playerSerail = getPlayerSerial(player)
    local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE playerSerail=?',playerSerail )
	if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then return end
    local data = data[1]['data']	
	setElemnetData(player,data)
  end
)

 

ادري انه هريسة

قولولي الاخطاء و باي سطر عشان نتعلم !

@Abdul KariM

@N3xT

 

Link to comment

جرب ذا

local dataName = "" -- إسم الداتا حق النقاط
addEventHandler ( "onResourceStart", resourceRoot,
    function ()
        executeSQLQuery  ('CREATE TABLE IF NOT EXISTS `TABLE` ( serial,point ) ')
	end
)


addEventHandler("onPlayerQuit ", root,
	function ()
		local playerSerail = getPlayerSerial( source )
		local Save = executeSQLQuery  ('SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		local data = getElementData (source, dataName) 
		if ( data and data ~= "" ) then
			if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then 
				executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)' playerSerail, data)
			else
				executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?' playerSerail , data)
			end 
		end
	end
)

addEventHandler ("onPlayerJoin", root,
	function ()
		local playerSerail = getPlayerSerial(source)
		local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then return end
		local saveData = Save[1]['point']
		setElementData(source,dataName,saveData)
	end
)

 

  • Like 1
Link to comment
3 hours ago, N3xT said:

جرب ذا


local dataName = "" -- إسم الداتا حق النقاط
addEventHandler ( "onResourceStart", resourceRoot,
    function ()
        executeSQLQuery  ('CREATE TABLE IF NOT EXISTS `TABLE` ( serial,point ) ')
	end
)


addEventHandler("onPlayerQuit ", root,
	function ()
		local playerSerail = getPlayerSerial( source )
		local Save = executeSQLQuery  ('SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		local data = getElementData (source, dataName) 
		if ( data and data ~= "" ) then
			if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then 
				executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)' playerSerail, data)
			else
				executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?' playerSerail , data)
			end 
		end
	end
)

addEventHandler ("onPlayerJoin", root,
	function ()
		local playerSerail = getPlayerSerial(source)
		local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then return end
		local saveData = Save[1]['point']
		setElementData(source,dataName,saveData)
	end
)

 

جآآآآري التجربة 

')'expected near 'palyerSerai'

Link to comment
local dataName = "" -- إسم الداتا حق النقاط
addEventHandler ( "onResourceStart", resourceRoot,
    function ()
        executeSQLQuery  ('CREATE TABLE IF NOT EXISTS `TABLE` ( serial,point ) ')
	end
)


addEventHandler("onPlayerQuit ", root,
	function ()
		local playerSerail = getPlayerSerial( source )
		local Save = executeSQLQuery  ('SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		local data = getElementData (source, dataName) 
		if ( data and data ~= "" ) then
			if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then 
				executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', playerSerail, data)
			else
				executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', playerSerail , data)
			end 
		end
	end
)

addEventHandler ("onPlayerJoin", root,
	function ()
		local playerSerail = getPlayerSerial(source)
		local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then return end
		local saveData = Save[1]['point']
		setElementData(source,dataName,saveData)
	end
)

 

  • Like 1
Link to comment
4 hours ago, N3xT said:

local dataName = "" -- إسم الداتا حق النقاط
addEventHandler ( "onResourceStart", resourceRoot,
    function ()
        executeSQLQuery  ('CREATE TABLE IF NOT EXISTS `TABLE` ( serial,point ) ')
	end
)


addEventHandler("onPlayerQuit ", root,
	function ()
		local playerSerail = getPlayerSerial( source )
		local Save = executeSQLQuery  ('SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		local data = getElementData (source, dataName) 
		if ( data and data ~= "" ) then
			if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then 
				executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', playerSerail, data)
			else
				executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', playerSerail , data)
			end 
		end
	end
)

addEventHandler ("onPlayerJoin", root,
	function ()
		local playerSerail = getPlayerSerial(source)
		local Save = executeSQLQuery  ( 'SELECT * FROM `TABLE` WHERE serial=?',playerSerail )
		if (type ( Save ) == 'TABLE' and #Save == 0 or not Save ) then return end
		local saveData = Save[1]['point']
		setElementData(source,dataName,saveData)
	end
)

 

دخلت وخرجت الدتا ما انحفظت :(

 

Link to comment

ضيف الكود هذا

addEventHandler ("onResourceStart", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then return end
	
	setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )
			end
		end
	end
	) ;
	
addEventHandler ("onResourceStop", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
	
	local aData = getElementData ( source , dataName )
	
	if ( aData and aData ~= false ) then
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then 
	
	executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', aPlayersSerial, aData)
	
	else
	
	executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', aPlayersSerial , aData )
					end
				end
			end
		end
	end
	) ;
	


	

مدري اذا كان فيه اخطاء , لاني كاتبه على السريع 

بالتوفيق

  • Like 1
Link to comment
20 minutes ago, Abdul KariM said:

ضيف الكود هذا


addEventHandler ("onResourceStart", resourceRoot ,	function (	)		local aPlayers = getElementsByType ( "player" )		if ( #aPlayers ~= 0 ) then		for _ , v in ipairs ( aPlayers ) do 		local aPlayersSerial = getPlayerSerial( v )			local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then return end		setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )			end		end	end	) ;	addEventHandler ("onResourceStop", resourceRoot ,	function (	)		local aPlayers = getElementsByType ( "player" )		if ( #aPlayers ~= 0 ) then		for _ , v in ipairs ( aPlayers ) do 		local aPlayersSerial = getPlayerSerial( v )		local aData = getElementData ( source , dataName )		if ( aData and aData ~= false ) then			local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then 		executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', aPlayersSerial, aData)		else		executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', aPlayersSerial , aData )					end				end			end		end	end	) ;		

مدري اذا كان فيه اخطاء , لاني كاتبه على السريع 

بالتوفيق

الله يعطيك الف الف عافية

    setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )
 

خطا ب هذا السطر 

 

attempt to index field '?' (a nil value)
 

Link to comment

اخوي هذا 

قد ساعدني فيه الاخ برستيج من قبل يعطييه العافيه لكن عبر التيبل مش سكل

aKillsData = 'داتا النقاط'

function aUpdateKiller ( 		)
	aTopKiller = {		};
	for _,v in ipairs( getElementsByType ( 'player') ) do 
		if getElementData ( v,aKillsData ) then
  		  table.insert ( aTopKiller,{ ['aName'] = getPlayerName ( v ),['aScore'] = getElementData ( v,aKillsData ) } );
  		end;
	end;
	table.sort ( aTopKiller, function ( a,b )  return a.aScore > b.aScore end ); 
end;
aUpdateKiller ( 		);

addEventHandler ( 'onClientElementDataChange',root,
	function (	aD )
		if aD == aKillsData then
			aUpdateKiller ( 		);
		end
	end
);

local aX,aY = guiGetScreenSize ( ) 
addEventHandler ( 'onClientRender',root,
function  ( )
	if #aTopKiller > 0 then
   		 dxDrawText ( 'Top Player is : '..aTopKiller[1].aName..' and His score is : '..aTopKiller [1].aScore..'', 44, aY - 43, aX, aY, tocolor ( 255, 255, 255, 255 ), 1 ) 
   	end
end
)

 

Link to comment
3 minutes ago, #_iMr,[E]coo said:

@Master_MTA

م يحفظ الجدول

هممم عاد والله ذا اللي كان عندي وتدري بقوم انام وكذا

جرب هذا وعطني خبر

dataName ="اسم الداتا"
addEventHandler ("onResourceStart", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then return end
	
	setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )
			end
		end
	end
	) ;
	
addEventHandler ("onResourceStop", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
	
	local aData = getElementData ( source , dataName )
	
	if ( aData and aData ~= false ) then
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then 
	
	executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', aPlayersSerial, aData)
	
	else
	
	executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', aPlayersSerial , aData )
					end
				end
			end
		end
	end
	) ;

نفس حق الاخ عبد الكريم لكن الداتا نسى يكتبها شكله او انت

لانه اصلا من الاول سوا ادخال لقيمه مب موجوده اللي هي داتا نيم والله اعلم

Link to comment
1 minute ago, Master_MTA said:

هممم عاد والله ذا اللي كان عندي وتدري بقوم انام وكذا

جرب هذا وعطني خبر


dataName ="اسم الداتا"addEventHandler ("onResourceStart", resourceRoot ,	function (	)		local aPlayers = getElementsByType ( "player" )		if ( #aPlayers ~= 0 ) then		for _ , v in ipairs ( aPlayers ) do 		local aPlayersSerial = getPlayerSerial( v )			local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then return end		setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )			end		end	end	) ;	addEventHandler ("onResourceStop", resourceRoot ,	function (	)		local aPlayers = getElementsByType ( "player" )		if ( #aPlayers ~= 0 ) then		for _ , v in ipairs ( aPlayers ) do 		local aPlayersSerial = getPlayerSerial( v )		local aData = getElementData ( source , dataName )		if ( aData and aData ~= false ) then			local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )	if ( type ( Select_ ) == 'TABLE' and #Select_ == 0 or not Select_ ) then 		executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', aPlayersSerial, aData)		else		executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', aPlayersSerial , aData )					end				end			end		end	end	) ;

نفس حق الاخ عبد الكريم لكن الداتا نسى يكتبها شكله او انت

قال لي ضيف عليه

م احذف اكواد نكست 

واحط اكواده 

Link to comment

p_379pv9di1.png
ماخطر على بال شخص منكم ان الريتورن في اللوب يوقفه كله ؟

يعني فرضنا جاب اللاعبين ومسك لاعب م معه داتا على القاعدة,

وش يصير يوقف اللوب كله على اللاعبين ؟

الزبدة انا هالمشكلة مرت عندي وتورطت فيها كثير لين عرفتها 

+ تفضل جرب ذا

 

dataName ="اسم الداتا"
addEventHandler ("onResourceStart", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'table' and #Select_ ~= 0 ) then
	
	setElementData( v , dataName , Select_ [ 1 ][ 'point' ] )
			end
		end
	end
	end
	) ;
	
addEventHandler ("onResourceStop", resourceRoot ,

	function (	)
	
	local aPlayers = getElementsByType ( "player" )
	
	if ( #aPlayers ~= 0 ) then
	
	for _ , v in ipairs ( aPlayers ) do 
	
	local aPlayersSerial = getPlayerSerial( v )
	
	local aData = getElementData ( source , dataName )
	
	if ( aData and aData ~= false ) then
		
	local Select_ = executeSQLQuery ( 'SELECT * FROM `TABLE` WHERE serial=?', aPlayersSerial )

	if ( type ( Select_ ) == 'table' and #Select_ == 0 or not Select_ ) then 
	
	executeSQLQuery ('INSERT INTO `TABLE` (serial,point) VALUES (?,?)', aPlayersSerial, aData)
	
	else
	
	executeSQLQuery ('UPDATE `TABLE` SET serial = ? , point = ?', aPlayersSerial , aData )
					end
				end
			end
		end
	end
	) ;

 

  • Like 2
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...