Jump to content

lgeri000

Members
  • Posts

    9
  • Joined

  • Last visited

Details

  • Location
    Hungary

lgeri000's Achievements

Newbie

Newbie (4/54)

3

Reputation

  1. The problem was the gaps. I wrote it in a single row without tabs, spaces and numbers and now its working so thank you very much
  2. Hi guys. Im trying to make an inventory system, but i cant save the table that contains the items. So the code is: local inv = { [1] = {{1,false,false,100},{2,false,false,100},{3,false,false,90},{4,false,false,100},{5,false,false,95},{6,false,1000,99},{7,false,1001,100},{8,false,1002,100},{9,false,1003,100},{10,false,1004,30},{11,false,1005,45},{12,false,1006,55},{13,false,1007,60},{14,false,1008,65},{15,false,1009,70},{16,false,1010,75},{17,false,1011,80},{18,false,1012,90},{19,false,1013,99},{13,false,1014,100},{15,false,1015,100}}, [2] = {{1,20,false,false},{2,30,false,false},{3,30,false,false},{4,110,false,false},{5,100,false,false},{6,2,false,false},{7,1,false,false},{8,1,false,false},{9,1,false,false}}, [3] = {}, [4] = {}, [5] = {}, [6] = {}, [7] = {}, [8] = {}, } dbExec(con,"update characters set inventory=? where id=?",toJSON(inv),1) local qh = dbQuery(con,"select * from characters where id=?",1) local invent = dbPoll(qh,100) invent = fromJSON(invent[1]["inventory"]) outputChatBox(#invent) setElementData(getElementsByType("player")[1],"inventory",invent) and the invent variable is not a table. If i save only the first 2 table in the "inv" table then it works so its probably something with the empty tables. Probably i dont know something about mysql or JSON, i would be very glad if someone could help me with this. Thanks
  3. Hi, when i try to remove a house with removeWorldModels this happens: This is the code i use: removeWorldModel(3284,10,-282.94,2719.5,62.5)
  4. Hello, can anybody tell me why is this ids table stay empty? local maxPlayers = getMaxPlayers() local ids = {} addEventHandler("onPlayerJoin", root, function() local player = source for i = 1, maxPlayers do if (ids[i] == false) then ids[i] = i setElementData(player,"id",i) break end end end ) addEventHandler("onPlayerQuit", root, function() local i = getElementData(source,"id") ids[i] = false setElementData(source,"id",false) end ) this would be an id-system
  5. Thanks for your help finally it works
  6. its still not working, but now the console writes: INFO: "connection" elem:db-connection00000049 this is the part of the script where it tries to log in maybe it helps addEvent("attemptLogin",true) addEventHandler("attemptLogin", resourceRoot, function(un,pass) if not(isPlayerBanned(client)) then local qh = dbQuery(con, "SELECT * FROM accounts WHERE username=?",un) local user dbPoll(qh,500) if (user) then if(#user > 0) then if(user[1]["password"] == pass) then setElementData(client, "acc:id", user[1]["id"]) triggerClientEvent(client,"accountServerResponse", resourceRoot, "loginSuccess") spawnPlayer(client,0,0,4,29) setCameraTarget(client,client) fadeCamera(client,true) else triggerClientEvent(client,"accountServerResponse", resourceRoot, "wrongPass") end else triggerClientEvent(client, "accountServerResponse", resourceRoot, "noAccount") end else triggerClientEvent(client,"accountServerResponse",resourceRoot,"unknownError") end else triggerClientEvent(client, "accountServerResponse",resourceRoot,"banned") end end ) it returns the unknownError every times when i try to log in or register
  7. Hey guys, i tried to write an account system for the first time with the help of a youtube video. The problem is that somewhy i cant connect to my mysql. This is my code which connect to the database, and its writing in the chatbox that mysql connection successful. local dbname = "lp"; local host = "127.0.0.1"; local username = "root"; local password = ""; local con; local connectionAttempts = 1; function connectMysql() con = dbConnect( "mysql", "dbname="..dbname..";host="..host..";charset=utf8", username, password, "share=1" ); if (con) then outputChatBox("#FFFFFFMySQL connection#00AA00 successful#FFFFFF!", root, 0, 0, 0, true); connectionAttempts = 1; else outputChatBox("#FFFFFFMySQL connection#AA0000 failed#FFFFFF! trying again("..connectionAttempts.."/3) in 10 sec.", root, 0, 0, 0, true); if (connectionAttempts < 3) then connectionAttempts = connectionAttempts+1; setTimer(connectMysql, 10000, 1); else outputChatBox("#FF0000MySQL connection failed! The server will shut down in 30 sec.", root, 0, 0, 0, true); setTimer(function() shutdown("Unable to connect to MySQL database"); end, 30000, 1); end end end connectMysql(); function getConnection() if (con) then return con; end end its meta file: <meta> <info author="lgeri000" name="MySQL" version="alpha" type="script" /> <script src="server.lua" type="server" /> <export function="getConnection" type="server" /> </meta> and than i export the getConnection function in an other script: local con = exports.mysql:getConnection() and from this point it doesnt work. The consoles message is: ERROR: Account\server.lua:1: exports: Call to non-running server resource (mysql) [string "?"] if i restart the mysql script (the first code) and the accountsystem script i can register, and its appear in the database, but i cant log in. i also tried to use the code of the youtuber but it didnt work either thank you for the help in advance
×
×
  • Create New...