• Gm_MySql v1.0 - OO edition.
    824 replies, posted
  • [QUOTE=Teddi Orange;33369546][lua]query.start()[/lua] should be: [lua]query:start()[/lua][/QUOTE] Are you kidding me. It worked. *facepalm* I can't believe I missed that! I've rewritten that function countless times, and stared at it for hours. And it was something as simple as having a period where a colon should be... Thank you so much Teddi.
  • Avatar of Phoenixf129
  • Anyone got random crashes while using this module (since latest gmod update) My server seems to crash when people join, totally bombed while using this!
  • Avatar of Teddi
  • [QUOTE=Phoenixf129;33588755]Anyone got random crashes while using this module (since latest gmod update) My server seems to crash when people join, totally bombed while using this![/QUOTE] No issues here.
  • Avatar of LuaMilkshake
  • [QUOTE=Phoenixf129;33588755]Anyone got random crashes while using this module (since latest gmod update) My server seems to crash when people join, totally bombed while using this![/QUOTE] I was having these issues while experimenting with sourcenet3, would you happen to be using that as well?
  • Could someone help me, MySql worked perfectly on windows, but now on ubuntu, it doesnt?
  • Avatar of Phoenixf129
  • [QUOTE=LuaMilkshake;33607017]I was having these issues while experimenting with sourcenet3, would you happen to be using that as well?[/QUOTE] yeah, turns out it was the DB itself, being corrupt. Hehe, resetting and dropping all tables worked fine
  • Avatar of LuaMilkshake
  • [QUOTE=camcole1;33767576]Could someone help me, MySql worked perfectly on windows, but now on ubuntu, it doesnt?[/QUOTE] Are you using the Linux version of the module?
  • Lol, So im trying to figure this one out [lua]function _R.Player:Exists() Msg("2") local query = databaseObject:query("SELECT * FROM player_info WHERE uniqueid = '"..self:UniqueID().."'") query.onData = function(Q,D) Msg("3") self:LoadStats() Msg("4") end query.onError = function(Q,E) Msg("5") self:NewPlayer() end query:start() end function PlayerInitialSpawn( ply ) ply:Exists() Msg("1") end hook.Add( "PlayerInitialSpawn", "SAVE_PlayerInitialSpawn", PlayerInitialSpawn )[/lua] Was wondering why "Exists()" doesnt appear to run, But the "LoadStats()" gets called when this is the only place "LoadStats()" is called...1, and 2 appear. But 3, 4, 5 will not Is this a pilot error or?
  • Avatar of Ploo
  • Why is it that connection can be made from the very start but no query will be ran until a player joins?
  • Avatar of Teddi
  • [QUOTE=Ploo;33861713]Why is it that connection can be made from the very start but no query will be ran until a player joins?[/QUOTE] Queries can be ran, however the results / actions won't be parsed until a player / bot joins due to various reasons (performance mostly).
  • could i use your mysqloo.dll( s) in another software (not HL2) I work on lua script(s) with another gaming software and i want to store datas in a mysql database. Thanks for your help ;-)
  • Avatar of Teddi
  • [QUOTE=gilko;33922007]could i use your mysqloo.dll( s) in another software (not HL2) I work on lua script(s) with another gaming software and i want to store datas in a mysql database. Thanks for your help ;-)[/QUOTE] mysqloo uses headers and functions specific to Garrysmod so it wouldn't be possible afaik.
  • I have also been having issues with my server hanging or crashing while using this module. It seems to only happen when the server has been running idle for a few hours and only player connects and/or disconnects trigger the occurrence. I sometimes see the error in the server console when it crashes and it refers to 'Illegal termination in worker thread'. I am using it in my gamemode and it works fine on startup and when I join soon after that. I am running the newest version (7). [IMG]http://i41.tinypic.com/n6b6fd.png[/IMG] Here is my gamemode file that handles MySQLOO [CODE] local HOST = "localhost" local USER_NAME = "root" local PASSWORD = "*******" local DATABASE = "lprp" local PORT = 3306 require("mysqloo") function GM.MySQLConnect() if !mysqloo then Msg("Error: Check that MySQLOO is installed.\n") return end local dboDB = mysqloo.connect(HOST,USER_NAME,PASSWORD,DATABASE,PORT) print("Connecting to MySQL Server...") dboDB:connect() GAMEMODE.CheckDB(dboDB) print("MySQL connection established!") return dboDB end function GM.CheckDB(dboDB) dboDB = dboDB or DB while dboDB:status() > 0 do if dboDB:status() == 2 then print("Retrying connection to MySQL Server") dboDB:connect() end end end function GM.MySQLError(qQuery,sError) file.Append("lprp_mysql_log.txt",Format("%s %s\n",os.date("%m/%d/%Y %I:%M:%S"),sError)) print(sError) end [/CODE] Here is an example of how I run queries within my gamemode functions. This is consistent on all functions. [CODE] function Player:LoadCharacters() GAMEMODE.CheckDB(DB) local q = DB:query(Format("select * from characters where AID=%q",self.LPRP.Account.ID)) q.onError = GAMEMODE.MySQLError q:start() q:wait() self.LPRP.Characters = q:getData() for k,v in pairs(self.LPRP.Characters) do v.FirstName = string.sub(v.FirstName,1,1)..string.lower(string.sub(v.FirstName,2)) v.LastName = string.sub(v.LastName,1,1)..string.lower(string.sub(v.LastName,2)) local status,r = pcall(glon.decode,v.Inventory) if status then v.Inventory = r or {} else v.Inventory = {} end v.Weight = 0 for k2,v2 in pairs(v.Inventory) do v.Weight = v.Weight + GAMEMODE.Items[k2].Weight*v2 end end end [/CODE] Also, it usually hangs most of the time on PlayerDisconnected after i have been connected and idle for a few hours, so here is the function that is ran on this hook. [CODE] function Player:SaveAccount() self.LPRP.Account.TimePlayed = self.LPRP.Account.TimePlayed+self:TimeConnected() self.LPRP.Account.LastJoin = os.time() GAMEMODE.CheckDB(DB) local q = DB:query(Format("update accounts set TimePlayed=%q,LastJoin=%q where SteamID=%q",self.LPRP.Account.TimePlayed,self.LPRP.Account.LastJoin,self:SteamID())) q.onError = GAMEMODE.MySQLError q:start() q:wait() end [/CODE] It usually crashes on PlayerConnect after long idle time but I don't actually run any queries until PlayerInitialSpawn. My code refers to a global var, DB, which is set when the server starts up and connects to the MySQL server.
  • Avatar of Mercior
  • This module leaks threads. Every time you run a blocking query (with :wait()) the thread never appears to terminate, and over time you will find they grind your servers FPS down and eventually it will crash. tmysql was the only solution I could find, but beware of race conditions since it does not do blocking queries!
  • Avatar of Teddi
  • You shouldn't be using wait() in the first place. This module is asynchronous and besides, the callback function itself waits to see if it gets a response or not (hence onError and onFailure).
  • Is there a function alike to PHP's [URL="http://php.net/manual/en/function.mysql-insert-id.php"]mysql_insert_id[/URL] in this library?
  • Avatar of JustSoFaded
  • [QUOTE=Panto;34209516]Is there a function alike to PHP's [URL="http://php.net/manual/en/function.mysql-insert-id.php"]mysql_insert_id[/URL] in this library?[/QUOTE] DATABASE_OBJECT:query("INSERT INTO
  • Avatar of pennerlord
  • [QUOTE=Panto;34209516]Is there a function alike to PHP's [URL="http://php.net/manual/en/function.mysql-insert-id.php"]mysql_insert_id[/URL] in this library?[/QUOTE] There is a mysql function for it: LAST_INSERT_ID() I think you use it this way: "SELECT LAST_INSERT_ID()" Correct me if I'm wrong.
  • I get this Error. [QUOTE]error loading module 'mysqloo' from file '/home/gmod/srcds_l/orangebox/garrysmod/lua/includes/modules/gmsv_mysqloo_linux.dll': libmysql.so.16: cannot open shared object file: No such file or directory[/QUOTE] If i don´t rename the /home/gmod/srcds_l/orangebox/garrysmod/lua/includes/modules/ -> [B]gmcl_mysqloo_i486.dll[/B] <- and -> [B]gmsv_mysqloo_i486.dll[/B] <- to -> [B]gmcl_mysqloo_linux.dll[/B] <- and -> [B]gmsv_mysqloo_linux.dll[/B] <-... ... i get the Error, that the module cannot be loaded. I hope you can help my ^^ And please [B]don´t say[/B], that i must install "apt-get -y install libmysql16off". I need a Alternative for this easy step :dance: [HR][/HR] Thank you in Advance
  • Avatar of JustSoFaded
  • [QUOTE=Bubelbub;34332662]I get this Error. If i don´t rename the /home/gmod/srcds_l/orangebox/garrysmod/lua/includes/modules/ -> [B]gmcl_mysqloo_i486.dll[/B] <- and -> [B]gmsv_mysqloo_i486.dll[/B] <- to -> [B]gmcl_mysqloo_linux.dll[/B] <- and -> [B]gmsv_mysqloo_linux.dll[/B] <-... ... i get the Error, that the module cannot be loaded. I hope you can help my ^^ And please [B]don´t say[/B], that i must install "apt-get -y install libmysql16off". I need a Alternative for this easy step :dance: [HR][/HR] Thank you in Advance[/QUOTE] yum update mysqld :v:
  • yum on Debian, haha :D you mean apt-get update mysqld But i must find a other way to fix the Problem!
  • Avatar of JustSoFaded
  • It was a joke, really. Also, you need to rename it to linux because of the way garrysmod loads linux binary modules in a .dll extension rather then .so (I think, I may be wrong).
  • Yes, but if i copy the right binarys to orangebox/bin then i get -> no error <-. But i doesn´t work!
  • Avatar of JustSoFaded
  • That's because require(); loads from includes/modules/ so, when you require it an its not in there it will say failed to load the module! And then just not work.
  • orangebox/lua/includes/modules Read the Error!? /home/gmod/srcds_l/orangebox/garrysmod/lua/includes/modules/ I reset the Server and try again... Or i remove mysql, sqlite must support a "live" editing, too!