1. Post #521
    Gold Member
    alexanderk's Avatar
    May 2007
    1,355 Posts
    lua_run require( 'mysqloo' )
    Reply With Quote Edit / Delete Windows 7 Norway Show Events Agree Agree x 4 (list)

  2. Post #522
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    lua_run require( 'mysqloo' )
    Wut... I typed that to get that message...
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 1Dumb Dumb x 1 (list)

  3. Post #523
    Kenny_'s Avatar
    March 2009
    135 Posts
    Wut... I typed that to get that message...
    The name of the module needs to be enclosed in quotes.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  4. Post #524
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    The name of the module needs to be enclosed in quotes.
    Show me please.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 3 (list)

  5. Post #525
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,830 Posts
    lua_run require( 'mysqloo' )
    ..
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua King Lua King x 1 (list)

  6. Post #526
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    Dude... i type that... and i get this...

    Code:
    > require ( ' mysqloo ' )...
    LuaGetfile: Not Loading includes\modules\ mysqloo .lua
    ERROR! Module ' mysqloo ' not found!
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  7. Post #527
    Kenny_'s Avatar
    March 2009
    135 Posts
    You're adding spaces now. Copy and paste this: require("mysqloo")
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  8. Post #528
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 10 (list)

  9. Post #529
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,830 Posts
    you can't use " in RCON commands, use [[ and ]]
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  10. Post #530
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    So if it response with...
    Code:
    require[[mysqloo]]...
    Its working?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #531
    Kenny_'s Avatar
    March 2009
    135 Posts
    Yes. You might also want to change your rcon password if you haven't already.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 4Agree Agree x 1 (list)

  12. Post #532
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,830 Posts
    So if it response with...
    Code:
    require[[mysqloo]]...
    Its working?
    Code:
    require([[mysqloo]])
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1Dumb Dumb x 1 (list)

  13. Post #533
    Gold Member
    Surf3rDud3's Avatar
    October 2011
    15 Posts
    Code:
    require([[mysqloo]])
    Its showing...

    Code:
    require ( [[mysqloo]] )...
    Im on a wild goose chase...
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #534
    Stop trying to do this in game and just put it straight into your script. You can either use-

    require("mysqloo")
    require('mysqloo')
    require([[mysqloo]])
    

    I really don't see how you can muck that up.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 4 (list)

  15. Post #535
    c-unitV3's Avatar
    October 2011
    50 Posts
    Stop trying to do this in game and just put it straight into your script. You can either use-

    require("mysqloo")
    require('mysqloo')
    require([[mysqloo]])
    

    I really don't see how you can muck that up.
    require[[mysqloo]] should work too, just as require"mysqloo" should work.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 2 (list)

  16. Post #536
    Terminal Shell Founder
    mr.wolf's Avatar
    July 2010
    820 Posts
    I smell a troll =/
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 1Agree Agree x 1 (list)

  17. Post #537
    require[[mysqloo]] should work too, just as require"mysqloo" should work.
    Lets not confuse the poster now.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 3 (list)

  18. Post #538
    c-unitV3's Avatar
    October 2011
    50 Posts


    It works, and yes, the only reason I posted this picture was to show off my own steamworks module :)
    Reply With Quote Edit / Delete Windows 7 United States Show Events Winner Winner x 3Friendly Friendly x 1Dumb Dumb x 1Optimistic Optimistic x 1 (list)

  19. Post #539

    October 2011
    50 Posts
    Hey, myself and 2 other people have been debugging the hell out of this function, and we can NOT figure out what's wrong with it

    function DeleteServer(ply)
    	print("Running Delete Server")
    	local playerID= ply:UniqueID()
    	print(playerID)
    	local query = databaseObject:query("DELETE FROM servers WHERE Owner_ID = '"..playerID.."'")
    	query.onSuccess = function() print("Deleted server from database") end
    	query.onError = function() print("Error deleting server from database") end
    	query.onFailure = function() print("Failed to delete server from database") end
    	query.start()
    	print("Server should have been deleted")
    end
    

    It's being called from another function, which is running fine, and its being called. Here's the console output:
    Code:
    Running Delete Server
    **players uID snipped out**
    Server should have been deleted
    Invalid object! (not userdata)
    Does anyone have any idea what's up with this function? The same script has 4 other select, insert and update functions, and all of those work fine.

    In case anyone is wondering, one of the functions in the same script is inserting data into the same table with the players uID. As you can see, it isn't running the .onSuccess or .onError functions, and status() gives another Invalid Object
    Reply With Quote Edit / Delete Mac United States Show Events

  20. Post #540
    query.start()

    should be:

    query:start()
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Winner Winner x 2 (list)

  21. Post #541

    October 2011
    50 Posts
    query.start()

    should be:

    query:start()
    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.
    Reply With Quote Edit / Delete Mac United States Show Events Friendly Friendly x 2 (list)

  22. Post #542
    CyberGmod Founder PropHuntv2 Home
    Phoenixf129's Avatar
    May 2009
    1,004 Posts
    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!
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  23. Post #543
    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!
    No issues here.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 2 (list)

  24. Post #544
    www.garryspin.com
    LuaMilkshake's Avatar
    December 2007
    361 Posts
    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!
    I was having these issues while experimenting with sourcenet3, would you happen to be using that as well?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  25. Post #545

    July 2011
    580 Posts
    Could someone help me, MySql worked perfectly on windows, but now on ubuntu, it doesnt?
    Reply With Quote Edit / Delete Mac United States Show Events

  26. Post #546
    CyberGmod Founder PropHuntv2 Home
    Phoenixf129's Avatar
    May 2009
    1,004 Posts
    I was having these issues while experimenting with sourcenet3, would you happen to be using that as well?
    yeah, turns out it was the DB itself, being corrupt. Hehe, resetting and dropping all tables worked fine
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  27. Post #547
    www.garryspin.com
    LuaMilkshake's Avatar
    December 2007
    361 Posts
    Could someone help me, MySql worked perfectly on windows, but now on ubuntu, it doesnt?
    Are you using the Linux version of the module?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #548

    July 2011
    580 Posts
    yes
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  29. Post #549

    July 2011
    222 Posts
    Lol, So im trying to figure this one out

    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 )

    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?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #550
    Ploo's Avatar
    December 2009
    364 Posts
    Why is it that connection can be made from the very start but no query will be ran until a player joins?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  31. Post #551
    Why is it that connection can be made from the very start but no query will be ran until a player joins?
    Queries can be ran, however the results / actions won't be parsed until a player / bot joins due to various reasons (performance mostly).
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 2 (list)

  32. Post #552

    December 2011
    2 Posts
    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 ;-)
    Reply With Quote Edit / Delete Windows 7 France Show Events

  33. Post #553
    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 ;-)
    mysqloo uses headers and functions specific to Garrysmod so it wouldn't be possible afaik.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  34. Post #554

    December 2011
    2 Posts
    Bad news

    Thanks
    Reply With Quote Edit / Delete Windows 7 France Show Events

  35. Post #555

    February 2009
    29 Posts
    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).


    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
    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
    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
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #556
    Mercior's Avatar
    March 2005
    54 Posts
    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!
    Reply With Quote Edit / Delete Windows 7 Show Events Dumb Dumb x 1Agree Agree x 1 (list)

  37. Post #557
    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).
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 2 (list)

  38. Post #558
    www.garryspin.com
    LuaMilkshake's Avatar
    December 2007
    361 Posts
    Someone needs to fix the OP since the list tag was removed.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 2 (list)

  39. Post #559

    January 2012
    131 Posts
    Is there a function alike to PHP's mysql_insert_id in this library?
    Reply With Quote Edit / Delete Windows 7 Estonia Show Events

  40. Post #560
    JustSoFaded's Avatar
    December 2011
    432 Posts
    Is there a function alike to PHP's mysql_insert_id in this library?
    DATABASE_OBJECT:query("INSERT INTO
    Reply With Quote Edit / Delete Windows 7 United States Show Events