Jump to content

Search the Community

Showing results for tags 'sql'.

  • 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. Hey! For example, I have an user table. I have an achievement list store in the scripts. How can I store the completed achievements for the users in the SQL? Maybe a third connection table? Because it is a many-to-many connection Or in the user table somehow?
  2. Hey guys! My question is where should I store static data? For exaple list of achievements, or list of weapon config (damage, model etc). In a local XML file, or an uniqe sql table? Thank you!
  3. 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
  4. 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
  5. Hello guys I recently had ideas for setting up a server in MTA. I heard a bit about lua and its characteristics. I wanted to know what programming languages are needed to set up a game server in MTA and manage it from beginner to professional. thank you.?
  6. O que é? Pra que serve? Um banco de dados é onde ficam salvos diversos tipos de dados que são usados entre as sessões dos jogadores e do servidor, isto significa que mesmo se o jogador relogar no servidor ou até mesmo o servidor reiniciar, os dados salvos no banco de dados não são perdidos. (se o script que salvou lá foi feito corretamente). O que posso salvar neles? O MTA já cria 2 bancos de dados padrão quando vc cria seu servidor, são eles: internal.db - Onde são salvos todos os dados das contas dos jogadores, login, senha, grana do bolso, posição do jogador quando deslogou, vida, colete, skin, armas, munição, etc. registry.db - Onde são salvos todos os dados que são utilizados pelos resources, como por exemplo melhores pontuações das corridas (race gamemode), proprietários das casas, dados bancários dos jogadores, saldo bancário dos jogadores, carros comprados pelos jogadores, roupas compradas pelos jogadores, empresas adquiridas pelos jogadores, etc. Onde eles estão? Estes dois bancos de dados estão na pasta deathmatch do seu servidor, estão na linguagem SQLite. Você ainda pode criar outros bancos de dados externos, para serem usados pelos resources, mas na minha opinião isso não é recomendável, uma vez que vc usaria MySQL, que é mais complexo e exige certos cuidados de acesso e domínio, mas alguns servidores profissionais precisam fazer assim pois fizeram os bancos de dados ficarem fora do servidor em outro IP por segurança, dai é necessário ter bancos de dados externos. Nesse tutorial vamos tratar somente dos bancos de dados nativos do MTA, por serem mais fáceis de entender. Como mexo neles? Para salvar alguma coisa na conta do jogador, isto é, no internal.db, você usa setAccountData, e para obter esses dados depois, use getAccountData. É extremamente simples, funciona da mesma forma que um setElementData, mas em vez de salvar uma data temporária em um elemento, salva uma data permanente numa conta. Porém, para salvar alguma coisa no registry.db, é um pouco mais complicado, uma vez que vc vai precisar criar uma tabela nova para cada resource. Por exemplo, vc acabou de criar um resource de ranking por kills/deaths e você deseja salvar esse ranking no banco de dados para que ao reiniciar o resource ou o servidor, o ranking não seja perdido. Para isso vc vai precisar primeiramente criar uma tabela no banco de dados registry.db, essa tabela será acessada pelo resource, que irá salvar os dados dele lá. Para fazer qualquer coisa neste banco de dados (criar tabelas, inserir, alterar, remover, deletar, inserir colunas em determinada tabela, etc) vc vai precisar usar isso: executeSQLQuery. Aqui, será necessário conhecimento em SQL para fazer isso, mas é mais fácil do que aprender uma linguagem de programação nova, pois suas opções e sintaxes são menores do que uma linguagem inteira de programação, você não vai inventar nenhum sistema novo aqui, apenas criar e gerenciar tabelas e dados. Criar tabela nova no banco de dados: (o Caps Lock não é uma regra, mas é melhor para entender o que é código e o que é nome) [Os seguintes códigos só funcionam server-side] executeSQLQuery ("CREATE TABLE IF NOT EXISTS nomedatabela (nomecoluna1 TEXT, nomecoluna2 REAL, nomecoluna3 INTEGER)") TEXT = Valores desta coluna serão textos. Podem ter símbolos, números e espaços. REAL = Valores desta coluna serão numéricos reais. (números decimais, positivos, negativos e 0.0) INTEGER = Valores desta coluna serão numéricos inteiros. (positivos, negativos e 0) (não existe tipo BOOLEAN, use TEXT e insira valor "false" ou "true") (existe valor NULL, é diferente de vazio e diferente de 0. NULL significa ausência de dados. O NULL aparece quando você cria uma linha ou coluna nova sem atribuir valores a elas.) Deletar tabela do banco de dados: executeSQLQuery ("DROP TABLE nomedatabela") Todas as linhas, colunas, células e valores desta tabela são deletados junto. Deletar linhas da tabela: (as células não ficarão NULL) executeSQLQuery ("DELETE FROM nomedatabela WHERE colunaespecífica=?", valorDaCelulaEspecifica) O ? indica que o valor está após a declaração do SQL. Você poderia colocar o valor direto no lugar do ?. Mas por alguma razão, as vezes isso gera erro. Além disso, se o valor da célula estiver em uma variável no seu script, você não pode declarar a variável no lugar do ?. Ali só pode ser o valor direto, pois a declaração SQL inteira se trata de uma string. Por isso o uso do ?, que está recebendo o valor da variável que está depois da vírgula. Obs: Para verificar se uma célula tem valor nulo, não se usa os operadores lógicos de ==, <= >=. Para isso, usa-se IS NULL ou IS NOT NULL. Ex: executeSQLQuery ("DELETE nomecoluna1,nomecoluna2 FROM nomedatabela WHERE nomecoluna3 IS NULL") Isso vai deletar todas as células da coluna 1 e coluna 2 onde a coluna 3 tem uma célula de valor NULL. Se a coluna 3 não tiver nenhuma célula de valor NULL, nada acontece. Inserir nova linha de valores: (ele vai criar automaticamente uma nova linha com novas células) executeSQLQuery ("INSERT INTO nomedatabela(nomecoluna1,nomecoluna2,nomecoluna3) VALUES(?,?,?)", valorCelulaColuna1, valorCelulaColuna2, valorCelulaColuna3) Neste caso, ele está inserindo 3 novos valores, cada valor em uma coluna. Se você não declarar os nomes das colunas, ele vai preencher na ordem das colunas automaticamente. Você pode deixar de declarar uma coluna se não quiser atribuir valor na célula daquela coluna. Se o tipo de valor da variável não for do tipo de dado daquela coluna, dará erro. Atualizar valores de células que já existem em uma tabela: (não é possível alterar os tipos de valores, é necessário editar o tipo da coluna se quiser fazer isso) executeSQLQuery ("UPDATE nomedatabela SET nomecoluna2=?,nomecoluna3=? WHERE nomecoluna1=?", valorCelulaColuna2, valorCelulaColuna3, valorCelulaColuna1) No caso acima, ele vai atualizar as células das colunas 2 e 3 onde o valor da célula da coluna 1 for igual ao valor de valorColunaCelula1. OBS: Nada impede que você coloque as primeiras variáveis junto à declaração SQL, mas para fazer isso você deve "cortar" a string, inserir as variáveis e depois continuar a string, Ex: executeSQLQuery ("UPDATE nomedatabela SET nomecoluna2= '".. valorCelulaColuna2 .."',nomecoluna3='".. valorCelulaColuna2 .."' WHERE nomecoluna1=?", valorCelulaColuna1) Lembrando que o valor destas variáveis também são strings na declaração, portanto use aspas simples antes e depois de cada corte para transformar os valores em string. Os dois pontos (..) significam que estes valores fazem parte do argumento SQL. Da mesma forma, se vc usar "1" .. "1", será igual a "11". (Por isso acho muito mais fácil deixar tudo ? na declaração SQL e colocar as variáveis todas após a string.) Selecionar determinadas células da tabela: (usado geralmente para obter os valores destas células para usar no script, você pode selecionar somente 1 célula ou várias) executeSQLQuery ("SELECT nomecoluna1,nomecoluna2 FROM nomedatabela WHERE nomecoluna3=?", valorCelulaColuna3) Neste exemplo, ele vai selecionar a célula da coluna 1 e a célula da coluna 2, na linha onde a célula da coluna 3 for igual a valorCelulaColuna3. Alterar a tabela (adicionar coluna nova) [SQLite não suporta deletar coluna nem editar tipo de coluna] executeSQLQuery ("ALTER TABLE nomedatabela ADD nomecoluna4 REAL") Devido a limitações do SQLite, ALTER TABLE não pode ser usado para deletar uma coluna nem para editar seu tipo. Para fazer isso é necessário recriar a tabela inteira com as novas alterações. No exemplo acima, ele vai adicionar uma nova coluna chamada "nomecoluna4". Tá, mas como ficaria tudo isso dentro de um script? Fiz um código com vários testes de banco de dados. Cada comando faz alguma coisa. É possível mexer em um banco de dados manualmente sem usar scripts? Sim, é possível. Eu mesmo costumo fazer isso para corrigir algumas coisas rápidas sem precisar programar mais nada. Para poder abrir os bancos de dados (internal.db e registry.db) você deve usar um programa chamado DB Browser for SQLite. Um programa gratuito, leve e bem fácil de entender. Nele você consegue acessar todas as tabelas do banco de dados e editar os valores como se fosse em uma planilha do Excel. Basta ir na aba Navegar dados, selecionar a tabela que deseja modificar, clicar em cima da célula cujo valor deseja atualizar, digitar o novo valor, clicar em Aplicar e depois clicar em Escrever modificações (salvar banco de dados). Pronto! E tem mais! Se você já tiver conhecimento avançado com a linguagem SQL, você também pode fazer alterações avançadas via código dentro do programa. Basta acessar a aba Executar SQL, escrever o comando SQL corretamente e depois clicar no botão de Play. Espero ter ajudado.
  7. can anyone please send me and Database file/script for a dayz server or a video how i can make it cose im new to making servers and i realy don't understand anything
  8. Olá, eu estou desenvolvendo um código e me vi a necessidade de usar uma database, porém não entendo nada do assunto, eu andei dando uma lida no tutorial do @Lord Henry porém não entendi como por cada coisa em pratica; O que eu quero fazer: Uma Loja de Skins, que a mesma tem um botão de usar, na hora que ele apertar o botão de Comprar, se ele já tiver a Skin comprada, aparece uma mensagem para apertar no outro botão (Botão de usar a Skin), porém estou em dúvidas nessa parte de obter se ele tem a skin... Enfim, na Database em Geral. Se pudessem me ajudar ficaria agradecido function DeltaSCR_Comprar (_, state) if DeltaSCR_Painel == true then if state == "down" then if isCursorOnElement (screenW * 0.5295, screenH * 0.5583, screenW * 0.1094, screenH * 0.0500) then -- //CANCELAR DeltaSCR_Abrir () elseif isCursorOnElement (screenW * 0.5295, screenH * 0.4917, screenW * 0.1094, screenH * 0.0500) then -- //USAR elseif isCursorOnElement (screenW * 0.5295, screenH * 0.4250, screenW * 0.1094, screenH * 0.0500) then -- //COMPRAR local rowItem = guiGridListGetSelectedItem (skinsList) if rowItem ~= -1 then if guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 1" then setElementModel (localPlayer, 0) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 2" then setElementModel (localPlayer, 1) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 3" then setElementModel (localPlayer, 2) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 4" then setElementModel (localPlayer, 7) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 5" then setElementModel (localPlayer, 9) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 6" then setElementModel (localPlayer, 10) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 7" then setElementModel (localPlayer, 11) takePlayerMoney (300) DeltaSCR_Abrir () elseif guiGridListGetItemText (skinsList, rowItem, 1) == "Skin 8" then setElementModel (localPlayer, 12) takePlayerMoney (300) DeltaSCR_Abrir () end end end end end end addEventHandler ("onClientClick", getRootElement(), DeltaSCR_Comprar)
  9. -- This piece of code in located in the 'onPlayerQuit' event handler. It saves the player's weapons and ammo if he has any, this is all working correctly local weapons = {} for slot = 1, 12 do local weapon = getPedWeapon(source, slot) if weapon > 0 then local ammo = getPedTotalAmmo(source, slot) if ammo > 0 then table.insert(weapons, {weapon, ammo}) end end end -- This is what appears under the 'weapons' column in the player's account table entry [ [ [ 30, 176 ] ] ] -- Which means the player left the server and had an AK-47 with total 176 ammo left -- And this is the part which loads the SQL weapons data for weapon, ammo in ipairs(fromJSON(accountData.weapons)) do giveWeapon(player, tonumber(weapon), tonumber(ammo)) end -- The problem is, the player doesn't get the weapons he has saved, instead, he'll be given a brassknuckle everytime and the SQL entry is reset Any ideas why it is not working properly? I'm using SQLite not MySQL. The weapons are saved correctly, so it would seem that the problems stems in the loading part.
  10. Alaan

    SQL Help/Ayuda

    Good people, I would like to know if someone could help me to pass a database sql to a saved by folder or something that is not sql or mysql because the host I hire is not mysql or sql and I need to save it in another way , Thank you very much already Buenas gente, quisiera saber si alguien me podria ayudar en pasar una base de datos sql a un guardado por carpeta u algo asi que no sea sql ni mysql por que el host que contrate no es mysql ni sql y necesito que se guarde de otra manera, desde ya muchisimas gracias
  11. Alaan

    Help/Ayuda SQL

    Hola buenas tardes/noches/dias, quisiera saber como utilizar SQL, tengo un resource de autos pero al reiniciar el servidor se salen los autos que compré, me trajo un archivo SQL que supongo que es para que no pase eso y no se como instalarla, si alguien me da una mano por favor se lo agradezco mucho. Hello good afternoon / nights / days, I would like to know how to use SQL, I have a resource of cars but when restarting the server the cars that I bought come out, I brought an SQL file that I guess it is so that it does not happen and I do not know how to install it , if someone gives me a hand please I appreciate it very much Olá boa tarde / noites / dias, gostaria de saber como usar SQL, tenho um recurso de carros mas ao reiniciar o servidor os carros que comprei saem, trouxe um arquivo SQL que acho que é para que não aconteça e eu não sei como instalá-lo , se alguém me der uma mão, agradeço muito
  12. السلام عليكم ورحمة الله وبركاته بما ان موضوع 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 )
  13. Hello guyz. I have the following problem: I have an mta:sa server, and I'm trying to connect it to mysql, but it doesn't work. It finds the table, but the table has records in it, which cannot be found.
  14. السلام عليكم ورحمة الله وبركاتة كيف الحال ان شاء الله بخير اليوم انا بدي منكو بعض الافكار : اول فكرة ايش احط نوع المتغير الخاص بموضوع كامل text يعني انا بسوي موقع الان لما الناس تنشر توبك اخلي نوع التوبك ذا في قاعدة البيانات ولا في افضل الامر الأخر : الان انا بدي الناس تقدر تحط لايك الان الايك ويظهر عند الموضوع عدد الايكات زبط معي كل شي بس ضل قصة هي ابي يظهر مين الي حطو لايكات كيف اربطهم بالقاعدة الخاصة بالبيانات عقل يقول اسوي جدول للايكات لوحده واربطه مع الجدول التوبك وش قلتو ابي اشوف اذا في طرق افضل
  15. السلآم عليكم ورحمة الله وبركاته طلبي وآضح فوق File بإستخدام ال هل ينحفظن ولا لا ؟
  16. 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?
  17. SOMEONE CAN GIVE ME ACCOUNT.sql , because one idiot hacked my server and deleted account table from data de base , i don't know what to do now , need help guys!
  18. [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?
  19. السلام عليكم ورحمة الله وبركاته كيف الحال شباب باذن الله اليوم بشرحلكم كيف تستخمون executeSQLQuery بطريقه مفصله بس اهم شي دعواتكم لي في الاختبار +_+ حق القدرات والله المستعان بس بسم الله نبدا طيب اولا executeSQLQuery هي وظيفه ثابته ما تتغير لكن فقط ما بين الاقواس هو اللي يتغير يعني انا شرحي ما اعرف اوصل المعلومه صح لكن حاولو تفهمو مني على قدر استطاعتكم +_+ نبدا باول وظيفه وهي انشاء قاعدة بيانات او بمعنى اصح تيبل executeSQLQuery("CREATE TABLE IF NOT EXISTS players (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT)") طيب الان ناخذ ما بين الاقواس وحده وحده في حالة انشائك لاي تيبل بتكون هذي ثابته ما فيها اي تغيير ما تعدل عليها ابد CREATE TABLE IF NOT EXISTS الان نجيي للي بنعدل عليه players هذا وشو هذا اسم التيبل اللي تبيه وليكن حطيته انا ماستر Master بكذا يكون هذا اول متغير صادفك في انشاء التيبل (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT) نجي لهنا وش هي clothes_head_texture هذا اسم الكولمن اللي داخل التيبل اللي بندخل فيه القيم وما الى ذلك طيب وش هي TEXT هذا نوع الكولمن يحتوي بالمناسبه الكلومن=عمود على تكست فقط طيب والفاصله وش وظيفتها الفاصله تستخدمها لو تبي تسوي اكثر من كولمن مثلا في هذي الحاله هو هنا مسوي 3 كولمن الاول اسمه clothes_head_texture الثاني clothes_head_model والاخير name اتمنى وصلت فكرة انشاء التيبل طيب هنا نجي للحذف انا دخلت قيمه وما ابيها ابي احذفها من الجدول او مثلا سويت تفعيل اشتراك في رنت سيستم للاعب وابيه ينحذف من التيبل اللي عندي كيف بنشوف الان executeSQLQuery("DELETE FROM players WHERE name=?", playerName) وكالعاده هي ثابته DELETE FROM اما بالنسبه لذي players فهي بتكون ماستر لاننا بدلناها لو تذكرون في انشاء التيبل فوق هذا اسم التيبل اللي انشاناه ايا كان اسمهه Master زي ما قلنا فوق مثلا WHERE name=? هنا تبي تحذف من اي كولمن؟ اي عمود تبي تحذف منه هنا سوينا حذف من عمود name , playerName) الفاصله ثابته playername تكون القيمه اللي تبي تحذفها وليكن اسم اللاعب محمد ابي احذف محمد كيف بتكون كذا ,'محمد') على سبيل المثال فقط بالنسبه لكم انتم على حسب استخدامكم مثلا getPlayerName(source) المصدر اسم لاعب المصدر اللي بالايفينت على حسبكم انتم طيب افرض انا ابي احذف ايضا من clothes_head_texture هل بطر اسوي 2 سطر ورا بعض؟ executeSQLQuery("DELETE FROM players WHERE name=?", playerName) executeSQLQuery("DELETE FROM players WHERE clothes_head_texture=?", head) طبعا هيد تكونو معرفينها انتم ما يحتاج بس هل ذي طريقه صحيحه الجواب خطا الطريقه الصحيح لو تبي تحذف القيمه صح بتسوي كذا executeSQLQuery("DELETE FROM players WHERE clothes_head_texture=? AND name=?", head,playername) زي ما تلاحظون ظفت انت وحطيت فاصله بعد وبلاير نيم بالظبط هذا اللي بتسويه ملاحظه مهمه الان لازم كابيتال ما يصلح سمول نجيي للي بعده executeSQLQuery("DROP TABLE players" ) هذي وظيفه لحذف التيبل وفي حالة شرحنا بتكون زي ما قلنا ماستر يعني كذا executeSQLQuery("DROP TABLE Master" ) executeSQLQuery("SELECT score,health FROM players WHERE name=?", playerName ) طيب هذي وشو هذي تجيبلك بينات من التيبل للاعب معين مثلا اانت لما دخلت للتيبل سويت اللاعب مع نقاطه مثلا SELECT ثابته كالعاده score,health هذي اسماء الكولمن اللي تبي تختار منها البيانات في حالة شرحنا بتكون clothes_head_texture, clothes_head_model طيب FROM players WHERE name=? بشرحها دفعه وحده FROM ثابته players اسم التيبل وفي حالتنا بتكون Master WHERE ثابته name=? هذا اللي عندك قيمته تبي تختار من عمود الاسماء بينات اللاعب اللي جمبو اللي هي clothes_head_texture, clothes_head_model فهمتو طيب بيكون التعريف كذا مثلا local ss,mm=executeSQLQuery("SELECT clothes_head_texture, clothes_head_model FROM Master WHERE name=?", playerName ) بكذا بيطلعلك القيمتين المجهولتين نجي للي بعده اوه قبل لا نجي للي بعده في شي افرض انا ابي كل التيبل بسوي كذا local table=executeSQLQuery("SELECT * FROM Master" ) كذا بيكون عندي جمميع البيانات اللي بالتيبل نجي للي بعده executeSQLQuery("INSERT INTO players(name,color,sound) VALUES(?,?,?)", playerName, colorName, soundName ) وش وظيفتها الادخال في التيبل تبي تدخل قيم جديده INSERT INTO players(name,color,sound) VALUES(?,?,?) اولا الانزرت ثابته وانتو ثابته اما ما بين الاقواس فبتكون اسماء العمود اللي تبي تدخل فيه القيم وفي حالتنا INSERT INTO players (name,clothes_head_texture, clothes_head_model) VALUES(?,?,?) VALUES(?,?,?) وش هذي هذي عدد القيم ونعبر عنها باستفهام لاننا بنكتبها باخر السطر بنشوف افرض عندي اربع عواميد راح نزيد ,? وبالتالي بتصير كذا VALUES(?,?,?,?) لكن احنا حاليا شغالين على 3 فمافي داعي VALUES(?,?,?) نكمل , playerName, colorName, soundName ) playername هذا اللي تبي تدخله في العمود الاول حسب الترتيب (name,clothes_head_texture, clothes_head_model) اللي سويته هنا وكذلك الباقي نجي للي بعده executeSQLQuery("UPDATE players SET color=?,sound=? WHERE name=?", colorName, soundName, playerName ) هذي وظيفتها تحديث البيانات افرض اللاعب زادت نقاطه كل اللي عليك انك تستخدم هذي الوظيفه لتحديث بياناته UPDATE players SET ابديت ثابته players في حالتنا بتكون Master بالنسبه ل SET ثابته color=?,sound=? WHERE name=? color=?,sound=? في حالتنا بتكون كذا clothes_head_texture=?, clothes_head_model=? بالنسبه ل WHERE name=? هذا وين تبي تحدث انت عند اي اسم تبي تحدث؟ على حسب اسم اللاعب اللي زادت نقاطه مثلا طيب colorName, soundName, playerName colorName هذا زي ما قلت بالترتيب حق العواميد اللي سويته يعني ذا راح يروح ل clothes_head_texture soundName وهذا راح يروح ل clothes_head_model والقيمه الاخيره وهي اللي نبي نحدث عندها اسم اللاعب اللي زادت نقاطه playerName اللي بتكون عند WHERE name=? وفي الختام اتمنى من كل قلبي تكونو استفدتو ولا تنسو دعواتكم بالمناسبه الشرح لارضاء الاخ ابوسولو لانه بغا شرح له من زمن @Abu-Solo ولك ايضا عزيزي المتابع لا تنسوني من دعواتكم يقلبي بالتوفيق يا رب لي ولكم
  20. السلام عليكم ورحمة الله وبركاته 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
  21. Hi guys. Can u tell me which fuctions from mta:wiki should I use to make this system. I want in this system: saving group to the player based on sql, indvidual commands for group. Like a Police - /arrest, Medics /heal. For all groups leader panel inlc. cmd /invite /kick. For admin /creategroup /setownergroup. I think in sql I need some table which saves values like a loginplayer, nicknameplayer, idGroup, nameGroup, leaderGroup, membersGroup? and make permission system for indvidual cmd but which fuction is responsible for that ?
  22. السلام عليكم ورحمة الله وبركاته عندي مشكلة , صار لي ساعة عليها _ المهم المشكلة إنه مستدعي بيانات الاعب بس ما يجيبهن بقريد ليست aServer Side local aSelect = executeSQLQuery ( 'SELECT * FROM CreateSystem WHERE aSerial_ =? ' , aSerial_ ) triggerClientEvent ( source , 'Attention' , source , aSelect ) aClientSide addEvent ( 'Attention' , true ) addEventHandler ( 'Attention' , root , function ( aSelect ) guiGridListClear ( GUIEditor2.gridlist[2] ) for i , v in ipairs ( aSelect ) do local aRow_ = guiGridListAddRow( GUIEditor2.gridlist[2] ) guiGridListSetItemText ( GUIEditor2.gridlist[2] , aRow_ , 1 , aSelect[i]['aName_'] , false , false ) guiGridListSetItemData ( GUIEditor2.gridlist[2] , aRow_ , 1 , aSelect[i]['aName_'] ) guiGridListSetItemText ( GUIEditor2.gridlist[2] , aRow_ , 2 , aSelect[i]['aInfos_'] , false , false ) guiGridListSetItemData ( GUIEditor2.gridlist[2] , aRow_ , 2 , aSelect[i]['aInfos_'] ) guiGridListSetItemData ( GUIEditor2.gridlist[2] , aRow_ , 1 , aSelect[i]['aSerial_'] ) end end )
  23. Hello fellas i have an important question about the databases in lua scripting, i have made a carshop system which stores the vehicles inside the database and i have made a menu which the user selects to spawn despawn his vehicle. if the user has 2 same vehicles how the script will know wich one from the database will pick? image of database:
  24. Hello fellows how are you ? Today i want to use database connections Into a simple script that im gonna make about user settings The script is simple a gui opens up and the user selects if he wants to enable disable some graphical settings (car reflection, water, detail, contrast, show fps counter etc blah blah) Script is made and works perfect but i want to save each user settings to database(sqlite for now since i don't want to have remote control of database for now so mysql is not needed) so when he logs on to server the settings he set before will be applied, and also if hes new user server will make a new list in database for that user with default settings (1(enable) for each setting)) anyway i don't need you to tell me how exaclty im gonna code that cause you will get through much work but i want to give me the idea how the hell am i gonna do this because the wiki is helpless in these things if you want some example how bad i am in scripting sql see below: playerSettings = {} function playerJoin() local settingsQuery = dbQuerry(connectionDb,"select * from settings") local settingsQueryResult = dbPoll(settingsQuery, -1) for i, user in pairs(settingsQueryResult) do local playerName = getAccountName(source) table.insert(playerSettings,playerName) end end addEventHandler("onPlayerJoin", resourceRoot, playerJoin) thanks in advance
  25. Olá pessoas peçonhentas. Bom, estou fazendo uns testes com portão que abre somente para determinado jogador cuja conta seja igual a um determinado campo do banco de dados. Por exemplo, quero que o portão abra somente quando o jogador da conta "lordhenry" se aproxime, mas não é tão simples, pois essa conta pode mudar caso ele venda a casa, dai o valor passa a ser vazio. Dai se outra pessoa comprar a casa, dai a conta dessa pessoa fica naquele campo que estava vazio e o portão passa a abrir somente com a conta dessa pessoa. Eu estou pensando em usar executeSQLQuery("SELECT.... Mas não sei o que declarar após isso para ele receber o valor daquela célula do banco de dados. Tentei usar: local accOwner = executeSQLQuery("SELECT 'owner' FROM 'housevip_data' WHERE 'ID'=?", 2) Ou também: local accOwner = executeSQLQuery("SELECT 'ID' FROM 'housevip_data' WHERE 'owner'=?", 2) Mas não da certo pois ele retorna uma tabela em vez de um valor.
×
×
  • Create New...