MR.GRAND Posted May 4, 2016 Posted May 4, 2016 سلآم عليكم ي عيال ~~ أبي اسأل عن شغلة .! الحين لنفرض إني ابي اعطي لكل لاعب عند حدوث امر معين قيمة رقمية ماحد بالكون عنده نفس القيمة الرقمية اللي عطيتها للاعب المحدد اوك!؟ وابي عند حدوث امر ثاني أعطي للاعب اللي عطيته القيمة الرقمية فوق قيمة رقميه ثانية ماحد بالكون عنده نفس القيمة الرقمية اللي عطيتها له اول مرة وثاني مرة وابي القيمة الرقمية في كل مرة تتغير وماتجي نفس القيمة اللي عطيتها له قبل أتمنى احد يعطيني طريقة لعمل هالشيء
mouamle Posted May 4, 2016 Posted May 4, 2016 تستخدم math.random(min, max) وتسوي جدول تحفظ فيه القيمه واللاعب ومن تسوي القيمه لللاعب الثاني تتحقق اذا كانت موجوده داخل الجدول تزيدها قيمه عشوائيه واذا مو موجوده تظيفها للجدول
MR.GRAND Posted May 4, 2016 Author Posted May 4, 2016 تستخدم math.random(min, max) وتسوي جدول تحفظ فيه القيمه واللاعب ومن تسوي القيمه لللاعب الثاني تتحقق اذا كانت موجوده داخل الجدول تزيدها قيمه عشوائيه واذا مو موجوده تظيفها للجدول مثال او شرح صغيرر عن الطريقة بالضبط
mouamle Posted May 4, 2016 Posted May 4, 2016 سويته تيبل تكدر تسويه SQL مثال Lua t = { } function insertName ( name1 ) rand = math.random(5, 10) if ( t[tostring(rand)] == nil ) then t[tostring(rand)] = name1 else rand = rand * math.random(5, 500) t[tostring(rand)] = name1 end end insertName("Mouamle") insertName("Mouamle2") insertName("Mouamle3") for k, v in pairs(t) do print(k, v) end مثال Mta TempTable = { } addCommandHandler( "sign", function ( p ) local pName = getPlayerName(p) local randNum = math.random(0, 1024) if ( TempTable[tostring(randNum)] == nil ) then TempTable[tostring(randNum)] = pName else randNum = randNum * math.random(5, 255) TempTable[tostring(randNum)] = pName end end )
MR.GRAND Posted May 4, 2016 Author Posted May 4, 2016 سويته تيبل تكدر تسويه SQL مثال Lua t = { } function insertName ( name1 ) rand = math.random(5, 10) if ( t[tostring(rand)] == nil ) then t[tostring(rand)] = name1 else rand = rand * math.random(5, 500) t[tostring(rand)] = name1 end end insertName("Mouamle") insertName("Mouamle2") insertName("Mouamle3") for k, v in pairs(t) do print(k, v) end مثال Mta TempTable = { } addCommandHandler( "sign", function ( p ) local pName = getPlayerName(p) local randNum = math.random(0, 1024) if ( TempTable[tostring(randNum)] == nil ) then TempTable[tostring(randNum)] = pName else randNum = randNum * math.random(5, 255) TempTable[tostring(randNum)] = pName end end ) ضبط لي الوضع هنا addEvent( 'NewPlayerBought', true ) addEventHandler( 'NewPlayerBought', root, function(BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) local check = executeSQLQuery('SELECT * FROM `BoughtUSERSsystem` WHERE userSerial=?', getPlayerSerial(source)) if (type(check) == 'table' and #check ~= 0 and check) then local oldItemPlan = check[1]['boughtPlan'] local getSuchID = check[1]['userID'] if (oldItemPlan == BoutghPlan) then outputChatBox('* خطأ : #FFFFFF لقد قمت بشراء النوع والخطة التي حددتها مسبقا !', source, 255, 0, 0, true) triggerClientEvent( source, "ERRORselectedBUY", source ) return end local ID = math.random(1,100) if (ID == getSuchID) then local ID = math.random(1000,1000000) * 1000 / 100 end executeSQLQuery('INSERT INTO `BoughtUSERSsystem` (userSerial,userID,userName,boughtType,boughtPlan,boughtPrice,typeCard,CARD1,CARD2,CARD3,CARD4,CARD5,CARD6) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)', getPlayerSerial(source), ID, getPlayerName(source), BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) triggerClientEvent( 'UPDATEGRIDLIST', source) triggerClientEvent( source, 'SeccessfullySent', source) else local ID = 1 executeSQLQuery('INSERT INTO `BoughtUSERSsystem` (userSerial,userID,userName,boughtType,boughtPlan,boughtPrice,typeCard,CARD1,CARD2,CARD3,CARD4,CARD5,CARD6) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)', getPlayerSerial(source), ID, getPlayerName(source), BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) triggerClientEvent( 'UPDATEGRIDLIST', source) triggerClientEvent( source, 'SeccessfullySent', source) end end ) شايف local ID ? ابي كل لاعب له اي دي خاص فيه ولما يسوي العملية مرة ثانية وهو عنده بيانات بالقاعدة الاي دي حقه يتغير وأي لاعب مايملك أي دي حقه واي دي حق الاعب ابيه مايتشابه بالمرة اللي قبها "
mouamle Posted May 4, 2016 Posted May 4, 2016 الفكره موجوده بالأكواد فوك طبقها بس على SQL مو تيبل ;-;
MR.GRAND Posted May 4, 2016 Author Posted May 4, 2016 الفكره موجوده بالأكواد فوك طبقها بس على SQL مو تيبل ;-; ابي مثال يالليل
MR.GRAND Posted May 4, 2016 Author Posted May 4, 2016 function playerID() local check = executeSQLQuery( ' SELECT * FROM `BoughtUSERSsystem` ' ) if ( type(check) == "table" and #check ~= 0 ) then local playerIDcheck = check[1]['userID'] local playerSerial = getPlayerSerial(source) local value = math.random(1, 1000) -- خطا بزيادة سترنق مع سترنق if (playerIDcheck == nil) then playerID = (tostring(value) + playerSerial) else local value = value * math.random(1, 1000) -- playerID = tostring(value) + playerSerial --خطا بزيادة سترنق مع سترنق end else local value = math.random(1, 1000) local playerSerial = getPlayerSerial(source) playerID = getPlayerSerial(source) end end addEvent( 'NewPlayerBought', true ) addEventHandler( 'NewPlayerBought', root, function(BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) local check = executeSQLQuery('SELECT * FROM `BoughtUSERSsystem` WHERE userSerial=?', getPlayerSerial(source)) if (type(check) == 'table' and #check ~= 0 and check) then local oldItemPlan = check[1]['boughtPlan'] if (oldItemPlan == BoutghPlan) then outputChatBox('* خطأ : #FFFFFF لقد قمت بشراء النوع والخطة التي حددتها مسبقا !', source, 255, 0, 0, true) triggerClientEvent( source, "ERRORselectedBUY", source ) return end playerID() local ID = playerID executeSQLQuery('INSERT INTO `BoughtUSERSsystem` (userSerial,userID,userName,boughtType,boughtPlan,boughtPrice,typeCard,CARD1,CARD2,CARD3,CARD4,CARD5,CARD6) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)', getPlayerSerial(source), ID, getPlayerName(source), BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) triggerClientEvent( 'UPDATEGRIDLIST', source) triggerClientEvent( source, 'SeccessfullySent', source) else playerID() local ID = playerID executeSQLQuery('INSERT INTO `BoughtUSERSsystem` (userSerial,userID,userName,boughtType,boughtPlan,boughtPrice,typeCard,CARD1,CARD2,CARD3,CARD4,CARD5,CARD6) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)', getPlayerSerial(source), ID, getPlayerName(source), BoutghType, BoutghPlan, BoutghPrice, cardType, CARDnumber1, CARDnumber2, CARDnumber3, CARDnumber4, CARDnumber5, CARDnumber6) triggerClientEvent( 'UPDATEGRIDLIST', source) triggerClientEvent( source, 'SeccessfullySent', source) end end )
محمد Posted May 4, 2016 Posted May 4, 2016 function insertname(name) local num = math.random(1,5) if t[num] then print(name..' don\'t insert') return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') شوف المثال ذا
Jupi Posted May 4, 2016 Posted May 4, 2016 function insertname(name) local num = math.random(1,5) if t[num] then print(name..' don\'t insert') return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') شوف المثال ذا
mouamle Posted May 4, 2016 Posted May 4, 2016 function insertname(name) local num = math.random(1,5) if t[num] then print(name..' don\'t insert') return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') شوف المثال ذا شسويت انت ؟
محمد Posted May 5, 2016 Posted May 5, 2016 سوا كود خربان ضض http://www.lua.org/cgi-bin/demo روح حط الكود وجرب إيش يطلعلك , وفي شيء قهرني print(name..' don't insert') كل ما احطها print(name..' don\'t insert') المنتدى يخربها . بإختصار t = {} function insertname(name) local num = math.random(1,5) if t[num] then print(name .."don't insert") return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4')
mouamle Posted May 5, 2016 Posted May 5, 2016 سوا كود خربان ضض http://www.lua.org/cgi-bin/demo روح حط الكود وجرب إيش يطلعلك , وفي شيء قهرني print(name..' don't insert') كل ما احطها print(name..' don\'t insert') المنتدى يخربها . بإختصار t = {} function insertname(name) local num = math.random(1,5) if t[num] then print(name .."don't insert") return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') متى عدلت الكود
mouamle Posted May 5, 2016 Posted May 5, 2016 هه ه ه هاقوول غلطي الوححيد اني نسيت الجدول وروح صلح كودك لا علمني اصلحه بعد
Jupi Posted May 5, 2016 Posted May 5, 2016 سوا كود خربان ضض http://www.lua.org/cgi-bin/demo روح حط الكود وجرب إيش يطلعلك , وفي شيء قهرني print(name..' don't insert') كل ما احطها print(name..' don\'t insert') المنتدى يخربها . بإختصار t = {} function insertname(name) local num = math.random(1,5) if t[num] then print(name .."don't insert") return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') print(name..' don't insert') ??? جربتها طلع لي خطأ
محمد Posted May 5, 2016 Posted May 5, 2016 ^ ما شاء الله مدرك الأوضاع وكاشف الأخطاء ما شاء الله عليك بس ناقصك شوية تركيز وفهم عشان تصير احسن وتتفلسف زي الناس سوا كود خربان ضض http://www.lua.org/cgi-bin/demo روح حط الكود وجرب إيش يطلعلك , وفي شيء قهرني print(name..' don't insert') كل ما احطها print(name..' don\'t insert') المنتدى يخربها . بإختصار t = {} function insertname(name) local num = math.random(1,5) if t[num] then print(name .."don't insert") return false else print(name..' insert '..num) t[num] = name return true end end repeat until insertname('dddd') repeat until insertname('dddd1') repeat until insertname('dddd2') repeat until insertname('dddd3') repeat until insertname('dddd4') [ lua]print(name ..'don\'t insert')[/lua] روح حطها برد وجرب ايش يصير والله اني غلطان اني جاي اساعدكم ياليتني ما سويت الحساب
justboy Posted May 5, 2016 Posted May 5, 2016 print(name ..'don\'t insert') ض2 صح كلامه دابل بلا فلسفة ض2
Jupi Posted May 5, 2016 Posted May 5, 2016 print(name ..'don\'t insert') ض2 صح كلامه دابل بلا فلسفة ض2 اتكلم عن الكود السابق ... تعرف تقرا؟
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