^iiEcoo'x_) Posted January 11, 2017 Share Posted January 11, 2017 السلام عليكم ورحمة الله وبركاته ابي اسوي حفظ الداتا واسم الاعب ابي اسويها بالاس كيو ال ابي الفنكشنات واحاول اسويها وتساعدوني بيها Link to comment
N3xT Posted January 11, 2017 Share Posted January 11, 2017 ليه تستخدم الداتا إذا بتحفظ عن طريق قواعد البيانات Link to comment
^iiEcoo'x_) Posted January 11, 2017 Author Share Posted January 11, 2017 مسويها ElementData Link to comment
Abdul KariM Posted January 11, 2017 Share Posted January 11, 2017 طيب ليه الالمنت داتا دامك راح تحفظها بالسكل خليها سكل مره وحده وخلاص + الفنكشنات "onResourceStart" "onPlayerJoin" "onPlayerChangeNick" getPlayerSerial getPlayerName executeSQLQuery طبعا تقول ليه السريال عشان لاغير الاعب اسمه او دخل السيرفر تجيب سرياله وتحقق انه ماهب موجود بالقاعدة وتحط اسم واذا كان موجود له اسم تحقق انه مايساوي الاسم الي دخل فيه وسويله ابديت 2 Link to comment
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 انا مسوي نقاط وبحفظهن ع السريال محاولتي 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
N3xT Posted January 12, 2017 Share Posted January 12, 2017 جرب ذا 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 ) 1 Link to comment
Master_MTA Posted January 12, 2017 Share Posted January 12, 2017 (edited) اعتذر ما شفت الردود السابقه Edited January 12, 2017 by Master_MTA Link to comment
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 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
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 (edited) @N3xT سطر 17 Edited January 12, 2017 by #_iMr,[E]coo Link to comment
N3xT Posted January 12, 2017 Share Posted January 12, 2017 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 ) 1 Link to comment
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 الله يعطيك الف الف الف الف عافية مشكوووور ي شنببببببببببب كلماتي تعجزززز عن شكركــــ والى كل من ساهم بالموضوع Link to comment
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 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
Abdul KariM Posted January 12, 2017 Share Posted January 12, 2017 ضيف الكود هذا 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 ) ; مدري اذا كان فيه اخطاء , لاني كاتبه على السريع بالتوفيق 1 Link to comment
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 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
Master_MTA Posted January 12, 2017 Share Posted January 12, 2017 اخوي هذا قد ساعدني فيه الاخ برستيج من قبل يعطييه العافيه لكن عبر التيبل مش سكل 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
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 @Master_MTA م يحفظ الجدول Link to comment
Master_MTA Posted January 12, 2017 Share Posted January 12, 2017 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
^iiEcoo'x_) Posted January 12, 2017 Author Share Posted January 12, 2017 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
Master_MTA Posted January 12, 2017 Share Posted January 12, 2017 Just now, #_iMr,[E]coo said: قال لي ضيف عليه م احذف اكواد نكست واحط اكواده اها اعذرني ما انتبهت 1 Link to comment
Abdul KariM Posted January 13, 2017 Share Posted January 13, 2017 جرب استبدله بهذا , و خلي المتغير حق الداتا نيم اول شي بالسكربت local aValue = Select_ [ 1 ] [ "point" ] setTimer ( setElementData , 1000 , 1 , v , dataName , aValue ) Link to comment
^iiEcoo'x_) Posted January 13, 2017 Author Share Posted January 13, 2017 @Abdul KariM لم تزبطُ معنا Link to comment
MR.GRAND Posted January 14, 2017 Share Posted January 14, 2017 ماخطر على بال شخص منكم ان الريتورن في اللوب يوقفه كله ؟ يعني فرضنا جاب اللاعبين ومسك لاعب م معه داتا على القاعدة, وش يصير يوقف اللوب كله على اللاعبين ؟ الزبدة انا هالمشكلة مرت عندي وتورطت فيها كثير لين عرفتها + تفضل جرب ذا 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 ) ; 2 Link to comment
^iiEcoo'x_) Posted January 17, 2017 Author Share Posted January 17, 2017 فكرته ضبط بس م ضبط Link to comment
MR.GRAND Posted January 17, 2017 Share Posted January 17, 2017 4 hours ago, #_iMr,[E]coo said: فكرته ضبط بس م ضبط ممكن عندك خلل ^ تأكد من الداتا Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now