Jump to content

Search the Community

Showing results for tags 'mysql'.

  • 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

  1. Hello! I have a local network home server (192.168.0.4) for storage and other service server running. On this server I run Ubuntu server with CasaOS. I recently made two custom flask apps, one for a XAMPP manager and one for an MTA Server Manager so I can easily have a web UI on two different ports. I setup everything successfully, I could run and join to an FTP server from my main desktop PC (192.168.0.122) or laptop, manage MTA servers correctly, start and stop them, join them, open and run phpMyAdmin. But when I got to the part to run the MTA server on the server PC, and setup the MySQL database connection I run into an issue regarding linux. [02:25:51] Starting Database [02:25:51] ERROR: Could not load /home/hmsvr/ftp/servers/LegendaryLegacy/SA/x64/dbconmy.so - /lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /home/hmsvr/ftp/servers/LegendaryLegacy/SA/x64/dbconmy.so) [02:2 5:51] WARNING: [Engine]/[Main]/Database/S_Database.lua:17: Bad usage @ 'dbConnect' [Could not connect] [02:25:51] ERROR: [Engine]/[Main]/Database/S_Database.lua:27: Database connection failed; When I start the server on my desktop PC, but still use the server PC to run the Apache, MySQL and FTP, I can successfully connect to the MySQL server running on my server PC. G_Database.lua & S_Database.lua sections for context DATABASE_DETAILS = { ["host"] = "192.168.0.4", -- "127.0.0.1" or "localhost" if the mysql server - XAMPP - runs on your PC, or "your server ip" if you have a separate PC or VPS ["port"] = 3306, -- Provided in XAMPP control panel or my.ini / my.cnf ["username"] = "mysql", -- Provided in phpMyAdmin or my.ini / my.cnf ["password"] = "", -- Provided in phpMyAdmin or my.ini / my.cnf - none by default ["database"] = "mta-ll", -- Rename if you are using different database or create one with this name } ---------------------- DATABASE = { CONNECTION = nil, RECONNECT_TIMER = nil } function connectDatabase() DATABASE.CONNECTION = dbConnect("mysql", "dbname="..DATABASE_DETAILS["database"]..";host="..DATABASE_DETAILS["host"]..";port="..DATABASE_DETAILS["port"], DATABASE_DETAILS["username"], DATABASE_DETAILS["password"], "log=1") if DATABASE.CONNECTION then print("Database connection successful") if isTimer(DATABASE.RECONNECT_TIMER) then killTimer(DATABASE.RECONNECT_TIMER) end DATABASE.RECONNECT_TIMER = nil --prepareDatabase() return true else error("Database connection failed; retrying in 5 seconds") DATABASE.RECONNECT_TIMER = setTimer(function() connectDatabase() end, 5000, 1) return false end end function disconnectDatabase() if not DATABASE.CONNECTION then return false end DATABASE.CONNECTION = nil print("Database connection closed") if isTimer(DATABASE.RECONNECT_TIMER) then killTimer(DATABASE.RECONNECT_TIMER) end DATABASE.RECONNECT_TIMER = nil return true end addEventHandler("onResourceStart", resourceRoot, function() connectDatabase() return true end) addEventHandler("onResourceStop", resourceRoot, function() disconnectDatabase() return true end) I already had OpenSSL installed when I checked the version, but also my version is 3.0 something. I was looking on many forums on how to get OpenSSL 1.1.1 as the error message requires but I didn't find any easy solutions apart from building from source and many complicated commands which I am not sure how to revert if it doesn't solve the issue. I downloaded some .deb file from ubuntu archive and istalled it via a forum post but I don't remember which one was it, because at first I got an error message saying that the libssl.so1.1 directory didn't exist or something similar, that's why I then tried to install that but then realised I have a newer OpenSSL version. I didn't even know I will have to f*ck around with OpenSSL for the sake of MTA SA MySQL database handling, nor I had to do this previously - well previously I didn't use MTA Linux Server on linux either. Does anybody have any suggestions how could I possibly solve this issue so I am able to run the linux version of MTA server on my home network Ubuntu linux server alongside the XAMPP / LAMPP Apache MySQL and FTP servers? I followed the tutorial on the MTA SA Linux Server Tutorial page. This is currently the only thing keeping me away from finishing what I've been wanting to do for a long time for a home network MTA development environment to be able to store and access and edit the server files on a separate server PC from various other devices. I am planning on releasing the flask apps for the XAMPP and MTA server managers later on in case anybody needs something similar, or also it could be used as good templates if you want to create docker images from it or so on, however the code may not be production ready but will be free to use and adjust. Thank you for your time response and help in advance!
  2. it's working the way I hope there is no error, but I noticed that when checkingpedingQuery[1][status] == 2 it returns only 1 value from a row of the status column I can't make it read more columns with status 2 is only giving 1 line with status 2 function saqueBankMoney(thePlayer, money) local checkpedingQuery = dbPoll(dbQuery(sql, "SELECT * FROM dbt_withdraw WHERE user_id = ? AND status <> "..tonumber(5).." ORDER BY status DESC ", getElementData(thePlayer, "char:userid")), -1) local amount = string.format("%09.8f",checkpedingQuery[1]["amount"] or 0) local amount = tonumber(amount) local vip = getElementData(thePlayer, "char:vip") or 0 local Moedas = string.format("%09.8f", getElementData(thePlayer, "char:vip") or 0) local balance = Moedas - 0.00010000 local man = 10000 if checkpedingQuery[1]["status"] == 2 then if money == getElementData(thePlayer, "char:vip") or money <= getElementData(thePlayer, "char:vip") then if balance > amount then dbExec(sql, "UPDATE dbt_balance SET balance = ? WHERE user_id = ?",balance, getElementData(thePlayer, "char:userid")) setElementData(thePlayer, "char:bankexchange", string.format("%09d", getElementData(thePlayer, "char:bankexchange")) + man) exports.logs:logMessage("[SAQUE]: "..getPlayerName(thePlayer).." ID: "..getElementData(thePlayer, "acc:id").." sacou R$: "..money.." no banco Total: "..getElementData(thePlayer, "char:vip").."", 1) else exports.FR_DxMessages:addBox(thePlayer,"blocked funds", "error") exports.FR_DxMessages:addBox(thePlayer,"peding withdraw", "info") end else outputChatBox('#0071fe[TRANSFERIDOR] #FFFFFFVocê está sem dinheiro', thePlayer,255,255,255,true) end end if checkpedingQuery[1]["status"] == 1 then if money == getElementData(thePlayer, "char:vip") or money <= getElementData(thePlayer, "char:vip") then dbExec(sql, "UPDATE dbt_balance SET balance = ? WHERE user_id = ?",balance, getElementData(thePlayer, "char:userid")) setElementData(thePlayer, "char:bankexchange",string.format("%09d", getElementData(thePlayer, "char:bankexchange")) + man) exports.FR_DxMessages:addBox(thePlayer,"Você retirou "..money.." do banco da exchange! ", "sucess") else outputChatBox('#0071fe[TRANSFERIDOR] #FFFFFFVocê está sem dinheiro', thePlayer,255,255,255,true) end end end
  3. I can't find any tutorial about something like this but I know it's possible because I searched if this question was made before in the forum and yes, I saw some codes and explanation from users and mods, but it doesn't work for me, because I'm using mysql and phpmyadmin, the examples doesn't match with my project, so I was wondering if someone could help me to understand how to save the data from the player's weapon and ammo... this is what I tried first: ---------this is inside of a function that saves all the player's info-------- local weapon1 = getPedWeapon (source) local weapon = getWeaponNameFromID (weapon) local ammo = getPedTotalAmmo(source) --------the info it's send to the table (this was simplified)----------- local sendInfo = exports.mysql:_Query("UPDATE characters SET weapon=?, ammo=? WHERE account=?", weapon, ammo, account) Since i've started, many problems as "getPedWeapons a nill value" appeared in the console, also "expected number, got boolean", etc. If there is a way to make a system like this without the getaccountdata/setaccountdata... I would like to know how to make it. I'm not asking for a full code, just some of knowlegde
  4. I've been trying to save the position of the player's character and it saves... but in a new table, not in the main one where its the account's name, the character's name and the rest. -> This is what happens<- This is the code I'm using for the "character money, position, and health" // i translated some concepts to english so you can understand easly what I'm trying to make: (server-side) function saveDataCharacter() local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local sendInfo = exports.mysql:_Exec("INSERT INTO characters (x,y,z, money, health) VALUES (?,?,?,?,?)", x, y, z, money, health) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end end addEventHandler("onPlayerQuit", getRootElement(), saveDataCharacter)
  5. Well, it's too late to delete it, so if a mod or admin see this, please delete this or move it, I solved the problem
  6. Hola amigos tengo una duda, estoy usando MySQL para la base de datos y tengo el inicio de sesión pero una vez logueado ¿Cómo hago para enviar una petición desde el cliente para identificar el usuario que hace la petición??? Esto para los que programan web, seria guardar en el localStorage de la pagina web donde tengo almacenado el usuario conectado y con el que hago las peticiones O es que tengo que estar llevando a todas partes la variable user? O envió a un archivo de tipo cliente una variable que este siempre ahí? pero esto implicaría que se perdiera esta variable por algún error??
  7. Bom, eu tenho uma proteção que funciona checando o IP pelo site http://checkip.dyndns.com/ Eu queria evoluir e colocar para Funcionar via MySQL só que a única coisa que consegui foi conectar a DataBase, se alguém puder ajudar eu agradeço muito. function connect() DBConnection = dbConnect( "mysql", "dbname=dbname;host=host;charset=utf8", "user", "senha" ) if (not DBConnection) then outputDebugString("Mysql error") else outputDebugString("Mysql Connected") end end addEventHandler("onResourceStart",resourceRoot, connect) function query(...) local queryHandle = dbQuery(DBConnection, ...) if (not queryHandle) then return nil end local rows = dbPoll(queryHandle, -1) return rows end function execute(...) local queryHandle = dbQuery(DBConnection, ...) local result, numRows = dbPoll(queryHandle, -1) return numRows end function getDBConnection() return DBConnection end ------------------------------- o script da proteção é essa SERVER_IP = "false" function startIPChecking () if (hasObjectPermissionTo (getThisResource(), "function.fetchRemote", false)) then -- Se o resource de segurança tem permissão de fetchRemote, então: fetchRemote ("http://checkip.dyndns.com/", myCallback, "", false) -- Obtém o IP do servidor através deste link. else outputDebugString ("The resource '"..getResourceName (getThisResource()).."' needs the following permission: function.fetchRemote", 1) SERVER_IP = "false" -- O resource de segurança precisa da seguinte permissão: function.fetchRemote para poder obter o IP do servidor. end end addEventHandler ("onResourceStart", resourceRoot, startIPChecking) function myCallback (responseData, errors) if (errors == 0) then -- Se não houve erros durante o callBack, então: SERVER_IP = responseData:match("<body>Current IP Address: (.-)</body>") -- SERVER_IP recebe uma string com o IP do servidor. else SERVER_IP = "error" end end function getServerIP() -- Função exportada return SERVER_IP end function authorizeResource () authorizedIP = "000.000.000.000" local ip = exports["serverIP"]:getServerIP () -- ip recebe o valor que está na variável Server_IP do resource de segurança. if (ip ~= authorizedIP) then -- Se o IP que recebeu do resource de segurança for diferente do IP configurado neste resource, então: cancelEvent(true, "This resource was not purchased by this IP.") -- Cancela a ativação deste resource. (não precisa de permissão Admin) print ("Incorrect Server IP from: "..getResourceName(getThisResource()).." (REASON: "..getCancelReason ()..")") end end addEventHandler ("onResourceStart", resourceRoot, authorizeResource)
  8. buenas ~ tengo un error con la gm de roleplay [ paradise ] es un error de mysql y no se mucho de mysql y ya cambie lo del sql [ lo del host y user, etc ] y tambien el settings, me crea todas las tablas menos la que dice characters [xx-xx-xx xx:xx:xx] ERROR: sql\layout.lua:91: Unable to create table characters [ soy nuevo en el foro ] ~gracias de antemano.
  9. 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?
  10. Preciso de ajuda para conectar um inventario no meu banco de dados. Estou em duvida como coloco o ip da host no script para conectar. Script exemplo local sqlDatas = { ["host"] = "127.0.0.1", < --- estou em duvida oq coloco aki na host ["user"] = "--", ["pw"] = "--", ["database"] = "--", } na host eu coloco 127.0.0.1 ou 144.217.121.107 (ip do server sem o port) lembrando que essa host é comprada não é local!
  11. Olá, estou criando um servidor com meus amigos que necessitamos de mysql para continuar o seu desenvolvimento, alguém pode me ensinar, fazer ou enviar um tutorial breve ou nem tanto mostrando como se faz? Agradeço desde então. Obrigado quem ajudar
  12. eu estou tentando programar um trabalho de leiteiro utilizando um inventario, e pra isso estou utilizando uma data base em uma host, a minha ideia pro trabalho do leiteiro é que primeiro o player tem que comprar um balde, depois ele tem que ir até uma vaca e tirar o leite dela, com isso o balde vazio é removido do inventario do player e um cheio é adicionado. só que tem um problema, se o player não tiver comprado o balde e executar o comando, ele irá conseguir tirar o leite da vaca do mesmo jeito, não tenho muita experiencia com MySQL aliás quase nenhuma, essa é a minha primeira vez A foto abaixo é da data base e do que fica armazenado no tabela de items do inventario na minha host:
  13. Hello. Use MySQL connection, all work perfect. But, how I can use dbQuery from another resource? Or I need always use dbConnect before dbQuery? local dbname = <Server DBname> local host = "127.0.0.1" local username = <Server Username> local password = <Server Password> function connectToDatabase() DB = dbConnect( "mysql", "dbname="..dbname..";host="..host..";charset=utf8", username, password, "share=1" ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), connectToDatabase, false) Should I use exports and... ?
  14. Tell me, what is better: MySQL, SQLite or XML? (You need to save (and retrieve) many user settings)
  15. Login System Some Images of GUI: https://puu.sh/sJnRg/2928be4ec3.png https://puu.sh/sJnTw/cb57d4b9ce.png Features: Uses External MySQL Database for register/login Logs in user to MTA System if account exist. It is opensource Installation: Configure your database configurations in server.lua Export database.sql to your selected database. Add this resource to your ACL's admin group and boom! Finished! You can start the script and connect to the server! Download Links MTA Community Resource: https://community.multitheftauto.com/index.php?p=resources&s=details&id=13930 Exports: -- To Be Updated.. exports.login:getPlayerUsername(player) -- Gets Player Username.
  16. This is my problem ERROR: dayzmode/lib/team/s_team.lua:1: call: failed to call 'dayzconnect:MySQL' ERROR: dayzmode/lib/system/player.lua:1: call: failed to call 'dayzconnect:players' Im using this call ( getResourceFromName ( "dayzconnect" ), "MySQL", 1, "2", "three" ) <export function="MySQL"/> <include resource="dayzmap"/> <include resource="dayzmode"/> <include resource="dayzbase"/> <include resource="dayzcache"/> <include resource="object_preview"/> I do not know what to do anymore
  17. بسم الله الرحمن الرحيم سلام عليكم ورحمة الله وبركاته ,, حبيت اطرح شرح 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..! من فضلكم تصفيق حار من اجلهم .. اعتذر اذا اشركت احدكم وماكان وده يشارك .. او العكس " الشرح مقدم على يد : واي فاي الحكمة من القصة لا تسلب حق غيرك لو كان في ابسط او اصغر الاشياء لأن بيجي شخص بيسلب حقك في اسوء او اكبر الاشياء وفي الختام اتمنى الشرح افادكم ولو قليل وتفهمون ان شاء الله وتقولون الله يرحمك ي بروس ?
  18. any problem this code ? pls help me handler = dbConnect("mysql", "dbname="..mysqldatabase2..";host="..mysqlhost2, mysqluser2, mysqlpassword2,";unix_socket="/var/run/mysqld/mysqld.sock, "autoreconnect=1")
  19. can anyone help me mysql problem when i try to fix i cant pfff hope you solve my problem [/] MTA: San Andreas :: 0/32 players :: 157 resources :: 151 fps (25) [02:07:13] ERROR: Couldn't find resource pwnage. Check it exists. [02:07:13] ERROR: Couldn't find resource cinema. Check it exists. [02:07:13] Creating new DB table vending_machines [02:07:13] ERROR: Couldn't find resource changename-system. Check it exists. [02:07:13] Querying MTA master server... success! (Auto detected IP:154.109.159. 190) [02:07:13] Authorized serial account protection is enabled for the ACL group(s): `Admin` See https://mtasa.com/authserial [02:07:13] WARNING: <owner_email_address> not set [02:07:13] Server started and is ready to accept connections! [02:07:13] To stop the server, type 'shutdown' or press Ctrl-C [02:07:13] Type 'help' for a list of commands. [02:07:13] Stopping global [02:07:13] Starting global [02:07:13] ERROR: mysql\connection.lua:62: attempt to call global 'mysql_ping' ( a nil value) [02:07:13] ERROR: global\money_globals.lua:26: call: failed to call 'mysql:query ' [string "?"] [02:07:13] ERROR: mysql\connection.lua:62: attempt to call global 'mysql_ping' ( a nil value) [02:07:13] ERROR: global\money_globals.lua:37: call: failed to call 'mysql:query ' [string "?"] [02:07:13] global restarted successfully thease my sql --[[ MMR ]] local connection = nil local connection = nil local null = nil local results = { } local max_results = 128 -- connection functions local function connect( ) -- retrieve the settings local server = "192.168.8.100" local user = "678_basespielers" local password = "basemed" local db = "678_basespielers" local port = get( "port" ) or 3306 local socket = get( "socket" ) or nil -- connect connection = mysql_connect ( server, user, password, db, port, socket ) if connection then if user == "root" then setTimer( outputDebugString, 100, 1, "Connecting to your MySQL as 'root' is strongly discouraged.", 2 ) end return true else outputDebugString ( "Connection to MySQL Failed.", 1 ) return false end end local function disconnect( ) if connection and mysql_ping( connection ) then mysql_close( connection ) end end local function checkConnection( ) if not connection or not mysql_ping( connection ) then return connect( ) end return true end addEventHandler( "onResourceStart", resourceRoot, function( ) if not mysql_connect then if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "MySQL module missing." ) end cancelEvent( true, "MySQL module missing." ) elseif not hasObjectPermissionTo( resource, "function.mysql_connect" ) then if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "Insufficient ACL rights for mysql resource." ) end cancelEvent( true, "Insufficient ACL rights for mysql resource." ) elseif not connect( ) then if connection then outputDebugString( mysql_error( connection ), 1 ) end if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "MySQL failed to connect." ) end cancelEvent( true, "MySQL failed to connect." ) else null = mysql_null( ) end end ) addEventHandler( "onResourceStop", resourceRoot, function( ) for key, value in pairs( results ) do mysql_free_result( value.r ) outputDebugString( "Query not free()'d: " .. value.q, 2 ) end disconnect( ) end ) -- function escape_string( str ) if type( str ) == "string" then return mysql_escape_string( connection, str ) elseif type( str ) == "number" then return tostring( str ) end end local function query( str, ... ) checkConnection( ) if ( ... ) then local t = { ... } for k, v in ipairs( t ) do t[ k ] = escape_string( tostring( v ) ) or "" end str = str:format( unpack( t ) ) end local result = mysql_query( connection, str ) if result then for num = 1, max_results do if not results[ num ] then results[ num ] = { r = result, q = str } return num end end mysql_free_result( result ) return false, "Unable to allocate result in pool" end return false, mysql_error( connection ) end function query_free( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end checkConnection( ) if ( ... ) then local t = { ... } for k, v in ipairs( t ) do t[ k ] = escape_string( tostring( v ) ) or "" end str = str:format( unpack( t ) ) end local result = mysql_query( connection, str ) if result then mysql_free_result( result ) return true end return false, mysql_error( connection ) end function free_result( result ) if results[ result ] then mysql_free_result( results[ result ].r ) results[ result ] = nil end end function query_assoc( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local t = { } local result, error = query( str, ... ) if result then for result, row in mysql_rows_assoc( results[ result ].r ) do local num = #t + 1 t[ num ] = { } for key, value in pairs( row ) do if value ~= null then t[ num ][ key ] = tonumber( value ) or value end end end free_result( result ) return t end return false, error end function query_assoc_single( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local t = { } local result, error = query( str, ... ) if result then local row = mysql_fetch_assoc( results[ result ].r ) if row then for key, value in pairs( row ) do if value ~= null then t[ key ] = tonumber( value ) or value end end free_result( result ) return t end free_result( result ) return false end return false, error end function query_insertid( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local result, error = query( str, ... ) if result then local id = mysql_insert_id( connection ) free_result( result ) return id end return false, error end function query_affected_rows( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local result, error = query( str, ... ) if result then local rows = mysql_affected_rows( connection ) free_result( result ) return rows end return false, error end next layout --[[ MMR ]] local allowUpdate = get( 'auto_update' ) ~= 0 -- change this setting to 0 to only print the required queries to console but not actually change stuff, removing it or setting it to anything but 0 leaves it enabled -- local query_update = nil if allowUpdate then query_update = query_free else query_update = function( str, ... ) if ( ... ) then local t = { ... } for k, v in ipairs( t ) do t[ k ] = escape_string( tostring( v ) ) or "" end str = str:format( unpack( t ) ) end outputServerLog( str ) return true end end local function getColumnString( value ) local str = "`" .. escape_string( value.name ) .. "` " .. escape_string( value.type ) if not value.null then str = str .. " NOT NULL" end if value.default then if value.default == 'CURRENT_TIMESTAMP' then str = str .. " DEFAULT CURRENT_TIMESTAMP" else str = str .. " DEFAULT '" .. escape_string( tostring( value.default ) ) .. "'" end end if value.auto_increment then str = str .. " AUTO_INCREMENT" end return str end function create_table( name, columns ) if sourceResource == getResourceFromName( "runcode" ) then return false end if not query_assoc_single( "SHOW TABLES LIKE '%s'", name ) then -- try to create the missing table local cols = { } local keys = { } local autoIncrementValue = "" for key, value in pairs( columns ) do if value.primary_key then table.insert( keys, "`" .. escape_string( value.name ) .."`" ) end if type( value.auto_increment ) == "number" then autoIncrementValue = " AUTO_INCREMENT=" .. value.auto_increment end table.insert( cols, getColumnString( value ) ) end if #keys > 0 then table.insert( cols, "PRIMARY KEY (" .. table.concat( keys, ", " ) .. ")" ) end if query_update( "CREATE TABLE `%s`(\n " .. table.concat( cols, ",\n " ) .. "\n) ENGINE=MyISAM" .. autoIncrementValue, name ) then outputDebugString( "Created table " .. name, 3 ) return true, true else outputDebugString( "Unable to create table " .. name, 1 ) return false end else -- make sure all columns do exist local result = query_assoc( 'DESCRIBE ' .. name ) local fields = { } local primary_keys = { } local has_primary_key = false local change_primary_keys = false for key, value in pairs( result ) do fields[ value.Field ] = { name = value.Field, type = value.Type, null = value.Null == "YES", auto_increment = value.Extra == "auto_increment", primary_key = value.Key == 'PRI' or nil, default = value.Default } if value.Key == 'PRI' then has_primary_key = true end end local insertWhere = "FIRST" for key, value in ipairs( columns ) do if not fields[ value.name ] then if query_update( "ALTER TABLE `%s` ADD " .. getColumnString( value ) .. " " .. insertWhere, name ) then outputDebugString( "Created column " .. name .. "." .. value.name, 3 ) else outputDebugString( "Unable to create column " .. name .. "." .. value.name, 1 ) return false end else -- let's check if everything is alright local f = fields[ value.name ] local str = getColumnString( value ) if getColumnString( f ) ~= str then if query_update( "ALTER TABLE `%s` MODIFY COLUMN " .. str, name ) then outputDebugString( "Changed field " .. name .. "." .. value.name, 3 ) else outputDebugString( "Changing field " .. name .. "." .. value.name .. " failed", 1 ) return false end end -- verify our primary keys if value.primary_key then table.insert( primary_keys, "`" .. escape_string( value.name ) .."`" ) end if f.primary_key ~= value.primary_key then change_primary_keys = true end end insertWhere = "AFTER `" .. escape_string( value.name ) .. "`" end -- change the primary key if we have to if change_primary_keys then outputDebugString( "Changing primary keys...", 3 ) if has_primary_key then if #primary_keys == 0 then if not query_update( "ALTER TABLE `%s` DROP PRIMARY KEY", name ) then outputDebugString( "Unable to drop primary key", 1 ) return false end else if not query_update( "ALTER TABLE `%s` DROP PRIMARY KEY, ADD PRIMARY KEY(" .. table.concat( primary_keys, ", " ) .. ")", name ) then outputDebugString( "Unable to change primary key", 1 ) return false end end elseif #primary_keys > 0 then if not query_update( "ALTER TABLE `%s` ADD PRIMARY KEY(" .. table.concat( primary_keys, ", " ) .. ")", name ) then outputDebugString( "Unable to add new primary key", 1 ) return false end end end return true, false end end
  20. So this is the function: https://wiki.multitheftauto.com/wiki/DbExec bool dbExec ( element databaseConnection, string query [, var param1 [, var param2 ...]] ) And I have an SQL Query like: dbExec(connection, "INSERT INTO table_name VALUES('1','Bob','What\'s the time?')") The function think that the ?(question mark) should be replaced with the param1 value and not handle it as a string and this couse an error. How should I escape this?
  21. [2018-03-11 23:43:59] ERROR: ****/source_s.lua:8: dbConnect failed; Can't connect to MySQL server on '**host**' (110) Во время выполнения подключения ужасно лагает сервер. После пишет в консоль эту строку. Код: function dataBaseConnect() dataBase = dbConnect( "mysql", "port=порт;host=хост;dbname=имя_базы", "логин", "пароль"); end addEventHandler("onResourceStart",resourceRoot,dataBaseConnect)
  22. Greetings People! I have a little problem with my Login Panel, because if i click on the Register button then nothing happens. I just tested my MySQL connection too , but its shows that the Connection is good and nothing comes out in the Debugscript either. If anyone can help me with this then Thank you! --Here is the Code for the Register function Server Side function registerReq(player, username, password, email) local password = md5(password) local regQuery = dbPoll(dbQuery(connection, "SELECT * FROM accounts"),-1) if regQuery then for _, rows in ipairs(regQuery) do if rows["username"] == username then exports.vmInfoBox:addNotification(player,"Ezzel a felhasználóval már regisztráltak!", "error") return end if rows["serial"] == getPlayerSerial(source) then exports.vmInfoBox:addNotification(player,"Az adott Serial már regisztrálva van!", "error") return end insertinfo = dbExec(connection, "INSERT INTO accounts SET username = ?, password = ?, ip = ?, serial = ?, email = ?, banned='0', online='0', regdate=NOW()", username, password, getPlayerIP(source), getPlayerSerial(source), email, banned, online, regdate) if insertinfo then exports.vmInfoBox:addNotification(player,"Sikeres regisztráció!", "success") else exports.vmInfoBox:addNotification(player,"Valami hiba történt, keress fel egy fejlesztöt!", "error") end end end end addEvent("registerReq", true) addEventHandler("registerReq", getRootElement(), registerReq) -- This is the code for Client Side function regregisterClick(button, state) if button == "left" and state == "down" then if source == regregbutton then if string.len(DGS:dgsGetText(reguseredit)) < 5 then exports.vmInfoBox:addNotification("A felhasználónév minimum 5 karakterböl kell állnia!", "error") return end if string.len(DGS:dgsGetText(regpasswedit)) < 6 then exports.vmInfoBox:addNotification("A jelszó minimum 6 karakterböl kell állnia!", "error") return end if DGS:dgsGetText(regpasswedit) ~= DGS:dgsGetText(regpasswedit2) then exports.vmInfoBox:addNotification("A két megadott jelszó nem egyezik!", "error") return end if string.len(DGS:dgsGetText(regmailedit)) < 7 then exports.vmInfoBox:addNotification("Az email cím minimum 7 karakterböl kell állnia!", "error") return end if not string.find(DGS:dgsGetText(regmailedit), "@") and string.find(DGS:dgsGetText(regmailedit), ".") then exports.vmInfoBox:addNotification("Kérlek adj meg egy érvényes email címet!", "error") return end if DGS:dgsGetText(reguseredit) == "" and DGS:dgsGetText(regpasswedit) == "" and DGS:dgsGetText(regpasswedit2) == "" and DGS:dgsGetText(regmailedit) == "" then exports.vmInfoBox:addNotification("Ne hagyd üresen a mezöket!", "error") end triggerServerEvent("registerReq", localPlayer, localPlayer, DGS:dgsGetText(reguseredit),DGS:dgsGetText(regpasswedit),DGS:dgsGetText(regpasswedit2),DGS:dgsGetText(regmailedit)) end end end addEventHandler("onDgsMouseClick", getRootElement(), regregisterClick)
  23. The connection is okay but dbQuery and dbPoll first argument got nil. ( sorry for my bad english ) ERROR: MYSQL CONNECTION CODE: "felhasznalo" SCRIPT:
  24. [2018-01-12 14:55:12] ERROR: Could not load /home/gameservers/mta/turbo1/x64/./dbconmy.so - /home/gameservers/mta/turbo1/x64/./dbconmy.so: symbol __cxa_pure_virtual, version libmysqlclient_16 not defined in file libmysqlclient.so.16 with link time reference[2018-01-12 14:55:12] ERROR: san_mysql/server.lua:19: dbConnect failed; Could not connect [2018-01-12 14:55:12] INFO: [mysql]: Sikertelen MYSQL csatlakozás! please help me, how to fix this?
  25. howdy.i just hosted my server "RP" and i dont know why i cant connect with Mysql.i tired to put Mysql.so and lib in Modules but it didnt work on windows works. If u dont know how to help me i can give my PHP because anything i have there ist special
×
×
  • Create New...