Jump to content

Search the Community

Showing results for tags 'db'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 13 results

  1. Hello Forum! I need yor help I am just starting to learn programming in Lua, there are not many guides, so I turn to you. I wrote my own passport emulation, but I don't understand how I can put the entered data into the database. Below I will attach my code. Also, I would be happy if you could help me and tell me how I can add the display of this "passport" when entering a marker using addEventHendler. Thank you in advance! My code local dgs = exports.dgs local sw,sh = guiGetScreenSize() -- разрешение экрана игрока local px,py = sw/1920,sh/1080 -- адаптация экрана local window = dgs:dgsCreateWindow(((sw-800)/2)*px,((sh-600)/2)*py,800*px,600*py,"Паспорт",false) local buttonExecute = dgs:dgsCreateButton(325*px,530*py,150*px,40*py,"Подтвердить",false,window,nil,nil,nil,nil,nil,nil,tocolor(255,0,0),tocolor(100,0,0),tocolor(255,0,0)) local labelFirstName = dgs:dgsCreateLabel(200*px,200*py,400*px,30*py," Имя: ",false,window) local editFirstName = dgs:dgsCreateEdit(200*px,220*py,400*px,30*py,"",false,window,tocolor(255,255,255),nil,nil,nil) dgs:dgsSetProperty(labelFirstName,"alignment",{"center"}, {"center"}) dgs:dgsSetProperty(editFirstName,"alignment",{"center"}, {"center"}) local labelLastName = dgs:dgsCreateLabel(200*px,270*py,400*px,30*py," Фамилия: ",false,window) local editLastName = dgs:dgsCreateEdit(200*px,290*py,400*px,30*py,"",false,window,tocolor(255,255,255),nil,nil,nil) dgs:dgsSetProperty(labelLastName,"alignment",{"center"}, {"center"}) dgs:dgsSetProperty(editLastName,"alignment",{"center"}, {"center"}) local labelAge = dgs:dgsCreateLabel(200*px,340*py,400*px,30*py," Возраст: ",false,window,tocolor(255,255,255),nil,nil,nil) local editAge = dgs:dgsCreateEdit(200*px,360*py,400*px,30*py,"",false,window) dgs:dgsSetProperty(labelAge,"alignment",{"center"}, {"center"}) dgs:dgsSetProperty(editAge,"alignment",{"center"}, {"center"}) local labelCountry = dgs:dgsCreateLabel(200*px,410*py,400*px,30*py," Страна: ",false,window,tocolor(255,255,255),nil,nil,nil,tocolor(100,100,100,100)) local editCountry = dgs:dgsCreateEdit(200*px,430*py,400*px,30*py,"",false,window) dgs:dgsSetProperty(labelCountry,"alignment",{"center"}, {"center"}) dgs:dgsSetProperty(editCountry,"alignment",{"center"}, {"center"}) dgs:dgsWindowSetMovable(window,false) dgs:dgsWindowSetSizable(window,false) dgs:dgsWindowSetCloseButtonEnabled(window,false) dgs:dgsSetVisible(window,true) dgs:dgsSetVisible(window,true) showCursor(true) function openPanel() dgs:dgsSetVisible(window,true) showCursor(true) end function colsePanel() dgs:dgsSetVisible(window,false) showCursor(false) end local currentChose = "register" addEventHandler("onDgsMouseClick",root,function(btn,state) if btn == "left" and state == "down" then if source == buttonExecute then local firstName = dgs:dgsGetText(editFirstName) local lastName = dgs:dgsGetText(editLastName) local age = dgs:dgsGetText(editAge) local country = dgs:dgsGetText(editCountry) if not string.find(firstName,"%S") then outputChatBox("Name") return end if not string.find(lastName,"%S") then outputChatBox("LastName") return end if not string.find(age,"%d") then outputChatBox("Age") return end if not string.find(country,"%S") then outputChatBox("Country") return end triggerServerEvent("playerPassportEnter",localPlayer,firstName,lastName,age,country) end end end) If you do help me, please write this with explanations, thank you in advance! I LOVE YOU FORUM
  2. Yesterday evening, I started my apprenticeship with db, I always wanted to learn, because with it, I can do mods, which I could not do without. My introduction with Database was done by adapting a System ID to the DB in the login panel. I did this using the server-side of my login panel. The first thing we do, is to use dbConnect (Wiki), which will make the connection to the db file. local db = dbConnect("sqlite", "db/royalusers.db") It will create the "db" folder, in the resource files, and inside the folder, the "royalusers.db" file. After that, we create a table using the SQL functions. local newTable = dbExec(db, "CREATE TABLE IF NOT EXISTS RoyalUsers (id INT, name TEXT, login TEXT, pass TEXT, serial TEXT)") RoyalUsers - Table-name id INT, name TEXT, login TEXT, pass TEXT, serial TEXT - columns of the table. INT - INTERNAL NUMBER Now the part of using the table defined in the database. function registerPlayer(user, pass, conf) if user == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if pass == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if conf == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if conf == pass then addAccount(tostring(user),tostring(pass)) triggerClientEvent(source, "onRoyalRegister", source) local query = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers WHERE login=?", user),-1) if #query == 0 then dbExec(db, "INSERT INTO RoyalUsers VALUES (?, ?, ?, ?, ?)", countIDs(), getPlayerName(source), user, pass, getPlayerSerial(source)) end outputLoginMsg(source, "Conta criada com sucesso! Aguarde...", "success") if not getAccount(user, pass) then outputLoginMsg(source, "Esta conta já está sendo utilizada!", "error") end else outputLoginMsg(source, "As senhas não estão iguais.", "error") end end end end end addEvent("onPlayerRequestRegister", true) addEventHandler("onPlayerRequestRegister", root, registerPlayer) function countIDs() local table = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers"), -1) local count = 1 for i, result in pairs(table) do count = count + 1 end return count end The login variable returns a table, it selects (SELECT) all the columns of the table, and checks if the login defined in the function does not exist in it, if it does not exist, it will add those information, the columns of the table RoyalUsers (INSERT INTO). VALUES (?, ?, ?, ?, ?) - "?" It is the amount of arguments that will be used to insert into the column. countIDs() - Function that returns the number of IDs in the table, and adds one more. getPlayerName(source) - Gets the player's name, and adds the "name" column of the table. user - Adds the user defined in the function, the column "login". pass - Adds the password set in the function, the "pass" column. getPlayerSerial(source) - Gets the player's serial, and adds the "serial" column of the table. Having the part in which the data that the player registers, are saved in the database, this part is ready. Now, just set the ID added to the database login, when the player logs in. function loginPlayer(source, user, pass) if user == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else if pass == "" then outputLoginMsg(source, "Preencha todos os campos!", "error") else local account = getAccount(user, pass) if account then logIn(source, account, pass) local queryTable = dbPoll(dbQuery(db, "SELECT * FROM RoyalUsers WHERE login='"..getAccountName(getPlayerAccount(source)).."'"), -1) for i, id in pairs(queryTable) do setElementData(source, "ID", id["id"]) end setTimer(setCameraTarget, 3000, 1, source, source) setTimer(triggerClientEvent, 14000, 1, source, "renderRoyalID", source) triggerClientEvent(source, "onRoyalLogin", source) outputLoginMsg(source, "Logado com sucesso! Aguarde...", "success") else outputLoginMsg(source, "Usuário ou senha incorretos!", "error") end end end end addEvent("onPlayerRequestLogin", true) The queryTable gets all the columns of the table, where the login = login of the player. After that, we loop the tables returned by the queryTable, and set the date "ID" to the player, according to the ID returned from the table defined in the loop. I want to make it clear that the tutorial did not go well explained, I just want to share, what I learned yesterday, and if I did something wrong, please let me know.
  3. there is a function to login to account: function login(username, password) local player = client if not (does_account_exist(username)) then create_error_message_dialog("Аккаунта с таким логином не существует!") return; else local handle = dbQuery(function (handle) --callback for the query selecting the user by username local results = dbPoll(handle, -1) if (#results == 0) then outputChatBox("Login Failed!") --triggerClientEvent(player, "loginFailed") return end passwordVerify(password, results[1].password, {}, function(matches) -- callback function for the password verify if (matches) then -- Do anything you wish with the database result to log the player in with the rest of your scripts outputChatBox("Login Success!") --triggerClientEvent(player, "loginSuccess") else outputChatBox("Login Failed!") --triggerClientEvent(player, "loginFailed") end if (rememberMe) then local token = generateRandomToken() dbExec(function() --triggerClientEvent(player, "loginSuccess", token) end,mysqlHandle, "INSERT INTO `access_tokens` (`user_id`, `token`) VALUES ('"..tostring(results[1].id).."', '"..tostring(token).."')") end end) end, mysqlHandle, "SELECT * FROM `users` WHERE username = '"..username.."'") end end but when you call passwordVerify(), the results table for the username returns the correct username, and for the password it returns nil, how to fix this (if necessary, the password is encoded in the database) I also wanted to ask, there is a button in the form of a rectangle: local buttonAuth_round = dgs:dgsCreateRoundRect(30,false,tocolor(62,153,247)) local buttonAuth = dgs:dgsCreateImage(182,0,164,56,buttonAuth_round,false,loginButtons,tocolor(62,153,247)) local buttonAuth_text = dgs:dgsCreateLabel(57,18,50,20,'Войти', false, buttonAuth) There is an event handler: addEventHandler("onDgsMouseClick", buttonAuth, function() local login, password = dgs:dgsGetText(inputLogin_edit), dgs:dgsGetText(inputPass_edit) if not string.find(login, "%S") then return end if not string.find(password, "%S") then return end triggerServerEvent("playerLogin", getLocalPlayer(), login, password) end, false) But when you click on a button or any other dgs element (which is being processed) - it is triggered two times (simultaneously), how can this be fixed?
  4. So hi guys, I've been lately working on some scripts just for fun to get familiar with this concept of creating my own resources and now I would like to ask you if someone could explain to me how can I get data from a database and then compare that data with let's say something like account name of a player. Yes, I know I'm supposed to use dbQuerry and dbPoll but I just can't get it to work, so if you'd be so kind to show me in a simple example how to compare the two I'd be really grateful. So let's say the problem is how can I compare user account name and maybe a ownerName(of a house perhaps or a car) which is stored in my database
  5. Olá pessoas deliciosamente bonitas! Bom, estou desenvolvendo um save-system por SQLite, porém, na parte de salvar as coordenadas do jogador, do contrário de salvar cada um dos tipos de coordenadas em uma coluna (X - Y - Z) eu queria salvar em uma única coluna (Coordenadas), mas como vocês devem saber, dados obtidos de um db são retornados como string, então utilizei Vector3 e tonumber, mas com o tonumber retorna um valor nulo, e sem ele retorna uma string, como eu poderia fazer para retornar o valor original de coordenadas? Código: local x2, y2, z2 = 675.99396,-1692.27075,8.70498 -- LUGAR QUE VAI SPAWNAR QUANDO CRIAR CONTA NOVA local db = exports.ds_sqlite db:exec("CREATE TABLE IF NOT EXISTS Usuarios (Nick TEXT, Usuario TEXT, Serial TEXT, Skin INT, Dinheiro INT, Coordenadas TEXT, Interior INT, Dimensao INT, Procurado INT)") function loadUsuarios(player, acc) local accName = getAccountName(getPlayerAccount(player)) local datas = db:query("SELECT * FROM Usuarios WHERE Usuario=? LIMIT 1", accName) if (datas and type(datas) == "table" and #datas > 0) then -- @Datas setElementData(player, "CRP:Skin", tonumber(datas[1]["Skin"])) setElementData(player, "CRP:Dinheiro", tonumber(datas[1]["Dinheiro"])) setElementData(player, "CRP:Coordenadas", datas[1]["Coordenadas"]) setElementData(player, "CRP:Interior", tonumber(datas[1]["Interior"])) setElementData(player, "CRP:Dimensao", tonumber(datas[1]["Dimensao"])) setElementData(player, "CRP:Procurado", tonumber(datas[1]["Procurado"])) iprint(datas[1]["Coordenadas"]) -- @Funções setCameraTarget(player, player) fadeCamera(player, true, 2.0) spawnPlayer(player, Vector3(datas[1]["Coordenadas"])) setElementPosition(player, Vector3(datas[1]["Coordenadas"])) setElementModel(player, tonumber(datas[1]["Skin"])) setPlayerMoney(player, tonumber(datas[1]["Dinheiro"])) setElementInterior(player, tonumber(datas[1]["Interior"])) setElementDimension(player, tonumber(datas[1]["Dimensao"])) setPlayerWantedLevel(player, tonumber(datas[1]["Procurado"])) else setCameraTarget(player, player) fadeCamera(player, true, 2.0) spawnPlayer(player, x2, y2, z2) setElementPosition(player, x2, y2, z2) local x, y, z = getElementPosition(player) db:exec("INSERT INTO Usuarios VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", getPlayerName(player):gsub("#%x%x%x%x%x%x", ""), accName, getPlayerSerial(player), getElementModel(player), getPlayerMoney(player), x..","..y..","..z + 0.7, getElementInterior(player), getElementDimension(player), getPlayerWantedLevel(player)) end end function saveUsuarios(player, acc) local accName = getAccountName(getPlayerAccount(player)) local datas = db:query("SELECT * FROM Usuarios WHERE Usuario=? LIMIT 1", accName) if (#datas > 0) then local x, y, z = getElementPosition(player) db:query("UPDATE Usuarios SET Nick=?, Usuario=?, Serial=?, Skin=?, Dinheiro=?, Coordenadas=?, Interior=?, Dimensao=?, Procurado=?", getPlayerName(player):gsub("#%x%x%x%x%x%x", ""), accName, getPlayerSerial(player), getElementModel(player), getPlayerMoney(player), x..","..y..","..z + 0.7, getElementInterior(player), getElementDimension(player), getPlayerWantedLevel(player)) end end addEventHandler("onPlayerLogin", root, function() for index, players in ipairs(getElementsByType("player")) do if (players == source) then local account = getPlayerAccount(players) loadUsuarios(players, account) end end end ) addEventHandler("onPlayerQuit", root, function() for index, players in ipairs(getElementsByType("player")) do if (players == source) then local account = getPlayerAccount(players) if (account) then saveUsuarios(players, account) end end end end )
  6. بسم الله الرحمن الرحيم سلام عليكم ورحمة الله وبركاته ,, حبيت اطرح شرح executeSQLQuery مفصل وكامل ان شاء الله . لكثرة الاعضاء الغير فاهمين له او الجاهلين له بسم الله نبدأ .. executeSQLQuery = عبارة عن قاعدة في سيرفرك dbConnect = عبارة عن قاعدة متصلة بالخادم او بالملف اولاً بننشئ كود الاتصال لو كنت بتستعمل dbFunctions test_db = dbConnect( "sqlite", "file.db" ) -- عبر ملف test_db = dbConnect( "mysql", "dbname=frank;host=1.2.3.4", "username", "password", "share=1" ) -- عن طريق الاتصال بالخادم .: ) فالنفترض انه عندنا القاعدة بهذا الشكل : { } فاضي صحيح ؟ طيب عشان ننشئ تيبل وندرج فيه المعلومات , بنحتاج نكتب هالكود : local result1 = executeSQLQuery ( "CREATE TABLE IF NOT EXISTS players (name TEXT, money TEXT, health TEXT)" ) local qh = dbQuery( test_db, "CREATE TABLE IF NOT EXISTS players (name TEXT, money TEXT, health TEXT)" ) -- نسوي الأمر local result2 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result1 and result2 ) then print ( "Success to create tables" ) -- نكتب في الديبق نجاح في انشاء الجداول end -- CREATE TABLE IF NOT EXISTS players (name TEXT, money TEXT, health TEXT) -- الترجمة : -- players اصنع جدول اذا ماكان فيه جدول بأسم -- والأعمدة هي : -- name, money, health بيطلع الناتج في القاعدة ~> { players = { } } ^ الجدول حق players فاضي نبي نضيف عليه قيمة مثلا .. local result31 = executeSQLQuery ( "INSERT INTO players(name,money,health) VALUES(?,?,?)", 'wifi','1000','100' ) local qh2 = dbQuery( test_db, "INSERT INTO players(name,money,health) VALUES(?,?,?)", 'wifi','1000','100' ) -- نسوي الأمر local result41 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result31 and result41 ) then print ( "Success to insert values" ) -- نكتب في الديبق نجاح في ادخال القيم end -- INSERT INTO players(name,money,health) VALUES(?,?,?) -- الترجمة : -- أدخال الى player -- والأعمدة هي : -- name, money, health -- والقيم : -- ?,?,? == 'wifi', '1000', '100' ملاحظة مهمة جداً : عند وضع سهم داخل الأمر او اي عملية SQL استبداله بالارقمنت خارج العملية كمثال : ("?,?",'wifi','1000') -- الاستفهام الاول بيستبدل بوايفاي -- والاستفاهم الثاني بيستبدل برقم ألف ("?,'1000'",'wifi') -- الاستفهام الاول بيستبدل بوايفاي ^ أتمنى تكون وضحت : بيطلع الناتج في القاعدة ~> { players = { { name='wifi', money='1000', health='100' } } } لو نبي نضيف قيمة ثانية بأسم نصور مثلاً وجا بروس قال انا الي ابي اصير القيمة وتضاربو وبعدين صار بروس القيمة ونصور راح .. كذا نسوي : local result3 = executeSQLQuery ( "INSERT INTO players(name,money,health) VALUES(?,?,?)", 'BrosS','-1000','10' ) local qh3 = dbQuery( test_db, "INSERT INTO players(name,money,health) VALUES(?,?,?)", 'BrosS','-1000','10' ) -- نسوي الأمر local result4 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result3 and result4 ) then print ( "Success to insert values" ) -- نكتب في الديبق نجاح في ادخال القيم end -- INSERT INTO players(name,money,health) VALUES(?,?,?) -- الترجمة : -- أدخال الى player -- والأعمدة هي : -- name, money, health -- والقيم : -- ?,?,? == 'BrosS', '-1000', '10' بيطلع الناتج في القاعدة ~> { players = { { name='wifi', money='1000', health='100' }, { name='BrosS', money='-1000', health='10' }, } } طيب لو نبي نجيب فلوس واي فاي كيف ؟ بهذي الطريقة : local result5 = executeSQLQuery ( "SELECT money FROM players WHERE name=?", 'wifi' ) local qh4 = dbQuery( test_db, "SELECT money FROM players WHERE name=?", 'wifi' ) -- نسوي الأمر local result6 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result5 and result6 ) then print ( "Success to select values" ) -- نكتب في الديبق نجاح في تحديد القيم print ( result5, result6 ) -- راح يطبع لنا فلوس واي فاي -- Result : -- 1000 end -- SELECT money FROM players WHERE name=? -- الترجمة : -- تحديد عامود money -- من جدول players -- اين القيمة المطابقة في عامود name -- والقيم : -- ? = 'wifi' شكل التحديد في القاعدة ~> -- > = التحديد -- ? = أين -- == = يطابق { >players = { { ?name=='wifi', >money='1000', health='100' }, { name='BrosS', money='-1000', health='10' }, } } -- توضيح اكثر { >players = { -- نحدد التيبل الي نريده { ?name='wifi', >money='1000', health='100' }, -- ? نحدد القيمة الي نريدها< + الي نبحث عنها { name='BrosS', money='-1000', health='10' }, } } مثال اخر لو نبي نجيب هيلث بروس : local result7 = executeSQLQuery ( "SELECT health FROM players WHERE name=?", 'BrosS' ) local qh5 = dbQuery( test_db, "SELECT health FROM players WHERE name=?", 'BrosS' ) -- نسوي الأمر local result8 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result7 and result8 ) then print ( "Success to select values" ) -- نكتب في الديبق نجاح في تحديد القيم print ( result5, result6 ) -- راح يطبع لنا دم بروس -- Result : -- 10 end -- SELECT money FROM players WHERE name=? -- الترجمة : -- تحديد عامود money -- من جدول players -- اين القيمة المطابقة في عامود name -- والقيم : -- ? = 'BrosS' الآن لو نبي نعدل على فلوس واي فاي او هلث بروس شلون ؟ بهذه الطريقة . : local result9 = executeSQLQuery ( "UPDATE players SET health='5' WHERE name=?", 'BrosS' ) local qh6 = dbQuery( test_db, "UPDATE players SET health='5' WHERE name=?", 'BrosS' ) -- نسوي الأمر local result10 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result9 and result10 ) then print ( "Success to edit values" ) -- نكتب نجاح في تعديل القيم end -- UPDATE players SET health='5' WHERE name=? -- الترجمة : -- تحديث جدول player -- تحديد عامود health='القيمة الجديدة' -- اين القيمة المطابقة في عامود name -- والقيم : -- ? = 'BrosS' النتيجة او الطريقة في القاعدة ~> -- > = التحديد -- ? = أين -- ! = تعديل -- == = يطابق { >players = { { name='wifi', money='1000', health='100' }, { ?name=='BrosS', money='-1000', !health='10' }, } } -- Result : { players = { { name='wifi', money='1000', health='100' }, { name='BrosS', money='-1000', health='5' }, } } ثم بروس صار دمه مره قليل وراح بروس المستشفى وعالجه نصور لكن للأسف مات ونبي نحذفه من الجدول شلون ؟ local result11 = executeSQLQuery ( "DELETE FROM players WHERE name=?", 'BrosS' ) local qh7 = dbQuery( test_db, "DELETE FROM players WHERE name=?", 'BrosS' ) -- نسوي الأمر local result12 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result11 and result12 ) then print ( "Success to delete values" ) -- نكتب نجاح في حذف قيمة end -- DELETE FROM players WHERE name=? -- الترجمة : -- حذف من players -- اين القيمة المطابقة في عامود name -- والقيم : -- ? = 'BrosS' النتيجة او الطريقة في القاعدة ~> -- > = التحديد -- ? = أين -- ! = حذف -- == = يطابق { >players = { { name='wifi', money='1000', health='100' }, !{ ?name=='BrosS', money='-1000', health='5' }, } } -- Result : { players = { { name='wifi', money='1000', health='100' }, } } ثم فجأه واي فاي حزن لأن بروس مات وقال بيستقيل , وصار مافي اي قيمة باقية شلون نحذف الجدول ؟ local result7 = executeSQLQuery ( "DROP TABLE players" ) local qh8 = dbQuery( test_db, "DROP TABLE players" ) -- نسوي الأمر local result8 = dbPoll( qh, -1 ) -- ونطلع النتيجة if ( result7 and result8 ) then print ( "Success to drop table" ) -- نكتب نجاح في حذف الجدول end -- DROP TABLE players -- الترجمة : -- حذف جدول players تنبيه مهم : الترجمة ليست حرفية انما بالمعنى فقط او للتوضيح بنسبة لغة البرمجة المشاركون في المسرحية : @!#NssoR_) @#BrosS @iMr.WiFi..! من فضلكم تصفيق حار من اجلهم .. اعتذر اذا اشركت احدكم وماكان وده يشارك .. او العكس " الشرح مقدم على يد : واي فاي الحكمة من القصة لا تسلب حق غيرك لو كان في ابسط او اصغر الاشياء لأن بيجي شخص بيسلب حقك في اسوء او اكبر الاشياء وفي الختام اتمنى الشرح افادكم ولو قليل وتفهمون ان شاء الله وتقولون الله يرحمك ي بروس ?
  7. Hi, I want a good way to learn database functions and sql, i really had many problems in my scripts without a database, so i want to be pro in database scripting. So pls if u have a good way tell me
  8. السلام عليكم ورحمة الله وبركاته بما ان موضوع setElementData getElementData يضعف البروسيسور حق الخادم وايضاً ماهو محفوظ بشكل يدوم فترة طويلة سويت هذه الوظيفة البسيطة نفس طريقة تشغيل الـ set/getElementData لكن محفوظة واهم شي بيانات اللاعبين نفسهم وكمان ما تضعف البروسيسور حق الخادم المهم لازم تحمل المود و تابع باقي الشرح ملاحظة طريقة الحفظ بملفات db او اللي هي Database يعني تقدر تاخذ الملف اللي عليه الداتا في انك اغلقت ملاحظة الموضوع لملف سيرفر فقط وكمان ملاحظة الموضوع تجريبي لكن شغال تمام ان شاء الله طبعاً اللي تواجهه مشاكل يقول للمساعدة في تطويره اول شي التحميل To4pTop مركز الخليج .. تخطى الاعلانات للتحميل .. ثاني شي الشرح تركيبة الكود -- [[ server side ]] exports["SQL"]:setElementSqlData ( element theElement, string key, value ) -- وضع بيانات أو تحديث بيانات قديمة بنفس الطريقة value = exports["SQL"]:getElementSqlData ( element theElement, string key ) -- لمعرفة البيانات القديمة لعنصر معين --[[ حيث theElement --> هو العنصر الذي ستضيف له البيانات ويجب ان يكون عنصر key --> string هو اسم او مفتاح البيانات ويجب ان يكون من نوع value --> وهي القيمة التي تريد وضعها في بيانات العنصر بما ان هذا الإصدار التجريبي يمكنك وضع القيمة اما رقم او قيمة داخل علامتي تنصيص "" --]] مثال function q () exports["SQL"]:setElementSqlData ( source, "money", getPlayerMoney ( source ) ) local x, y, z = getElementPosition ( source ) exports["SQL"]:setElementSqlData ( source, "x", x ) exports["SQL"]:setElementSqlData ( source, "y", y ) exports["SQL"]:setElementSqlData ( source, "z", z ) end addEventHandler ( "onPlayerQuit", root, q ) function l () givePlayerMoney ( source, exports["SQL"]:getElementSqlData ( source, "money" ) ) local x = exports["SQL"]:getElementSqlData ( source, "x" ) local y = exports["SQL"]:getElementSqlData ( source, "y" ) local z = exports["SQL"]:getElementSqlData ( source, "z" ) setElementPosition ( source, x, y, z ) end addEventHandler ( "onPlayerLogin", root, l )
  9. Hello guys, I once heard that there is a way to connect to Internal.db, And get/set values in it using: dbQuery - dbExec .. etc I tried to get values in it, But i get this error: There is no such table called 'accounts' So my question is, How to do it ? Is there anyone did it before or knows how to do it ?
  10. السلام عليكم ورحمة الله وبركاتة ي جماعة الخير انا سويت طريقة ب ال File لحفظ الاسم + الرمز الخاصة بالحسابات عند التسجيل لكن واجهتني مشكله 1 لاق 2 الحفظ م يكون مضمون 3 تكرار الحفظ عشان كذا قررت اسويها بالداتا بيس لكن المشكله انا م افهم شي بالداتا بيسس وولاشي ياليت تعلمون الطريقةة بالتفصيل الممل انا تابعت شرح اتوقع للشيخ @iMr.WiFi..! لكن م فهمت منه كثير شكراا
  11. Hey I have recently made a script and to save its data and keep it safe in case script was restarted/server was shutdown I moved the data into a SQL using executeSQLQuery function. I believe such function saves the data in the internal DB right? Anyway, I did that in my local server and everything worked fine. But when I moved the script into another (hosted) server, An error showed up in the debug section saying 'Database query failed: file is encrypted or is not database'. I don't know what the heck they talking about, but I need help. Any ideas?
  12. #LycaN

    MySQL internal dbs

    How can I change the MTA internal db (internal.db and registry.db) to MySQL, maintening the functions like getAccountData, getElementData ?
  13. السلام عليكم ورحمة الله وبركاته function E1 ( player, _, playerName ) if playerName and getPlayerFromName ( playerName ) then db = dbConnect("sqlite", "killerProject.db") dbExec(db, "CREATE TABLE IF NOT EXISTS MYSQLTable ( playerName, playerMoney )") dbExec(db, "INSERT INTO MYSQLTable VALUES ( ?, ? )", getPlayerName (player), getPlayerMoney (player) ) playSoundFrontEnd(player, 43) for i, rTable in ipairs( dbPoll( dbQuery( db, "SELECT * FROM MYSQLTable WHERE playerName = ?", playerName ) , -1 ) ) do outputChatBox ( "* Player Name: "..rTable["playerName"].." Player Money: "..rTable["playerMoney"], player, 0, 255, 0 ) end else outputChatBox ( "sql <playerName>", root, 0, 255, 0 ) end end addCommandHandler ( "sql", E1 ) فين المشكل هنا ؟ مع العلم اني مب عارف اي شئ عن السكل لكن حاولت اجرب مب قادر استعمل التاج لأن الانترنت ضعيف الدي بق فارغ outputChatBox( "* Player Name: "..rTable["playerName"].." Player Money: "..rTable["playerMoney"], player, 0, 255, 0 ) -- ما تطلع في الشات ولا اي شئ يتفعل اذا كان داخل هذا اللوب for i, rTable in ipairs( dbPoll( dbQuery( db, "SELECT * FROM MYSQLTable WHERE playerName = ?", playerName ) , -1 ) ) do -- هنا end
×
×
  • Create New...