Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

MySQL and RMXP

Seto

Member

Hello,
I would like to access (read and write) a MySql database directly from my game. I would like to know if any one has done this before or if they could help me. I am hoping there is already a .dll or a library that could help to do this which would make this alot easier. since I am new to ruby I don't know were to look.

The reason behind wanting to do this is so I can make my game online with out the need for a sever running on my computer. I know this would be laggy but I am not putting the whole game online just some mini games that would only need to read and write basic data from the database. I will also allow players to battle each other with the default battle system that comes with rmxp. (I have already worked out how I am going to do it). And even if I can't make the game online I would like to be able to upload stats onto my website which I can also easily do with the MySQL database.

Thanks for taking time to read this post and please don't be too mean when replying.
 

e

Sponsor

There's probably a workaround. setsockopt basically sets up the socket for a given protocol or system; basically, set socket options.

It seems the Winsock module supports the method setsockopt; so adding a quick function to the Socket class would do:

Code:
class Socket
  def setsockopt(level, optname, optval)
    Winsock.setsockopt(@fd, level, optname, optval)
  end
end

Dunno if that'd work, but that'd be the gist of it. Maybe it'll need some tweaking.
 

Seto

Member

Thanks,
I added the script and the error is gone now but it causes another error lol, I am going to fiddle around with a bit and see if I can get it to work, I think its just the spot in the script i added it to. If I can't I will post the error here and see if anyone can help :D. Thanks again everyone
 

Seto

Member

So far I keep getting errors with it, your piece of script works but there seems to be another function missing from the scocket script. Or it just plain clashes. I will keep working with it a post the errors as soon as I get the chance :D
 

Seto

Member

Ok thanks for offering to help there are two errors I get,
One when I add the script at the button and one if I add anywere else.

At the bottom I get:

Script 'socket' line 175: Runtimeerror occured.
Wrong number of parameters: expected 5, got 4.

This is block that includes line 175
  #--------------------------------------------------------------------------
  # * Set Socket Options
  #--------------------------------------------------------------------------
  def self.setsockopt(*args)
    Win32API.new(DLL, "setsockopt", "pllpl", "l").call(*args)
  end

This is the error I get when I add the script anywere else:

Script 'socket' line 558: NoMethodError ocurred.
undefined method 'sockaddr_in' for Socket::Socket:Class

This is the block that includes 588

  #--------------------------------------------------------------------------
  # â—
 

Seto

Member

The game you posted is exatcly what I want to do exept I am getting the same error as before.
Script "Mysql" line 106 nomethoderror occurred
undefined method 'setsockopt' for #<TCPSocket:0x16f2328 @fd=967>

Did it work for you?

I added the piece of script I got from etheon but then I get another error which is the same as before expect with Win32, the error is:
Script 'Win32' line 101: Runtimeerror occured.
Wrong number of parameters: expected 5, got 4.

This is the lines 100 to 102
  def self.setsockopt(*args)
    Win32API.new(DLL, "setsockopt", "pllpl", "l").call(*args)
  end 


It is looking more and more like this is going to work. Online rpg system here I come lol.
 
In order to use MySQL directly into RMXP, you have to remove the requirements for the net.so ruby file. I don't believe anyone here has so or knows how to, so for the time being, unless you succeed with a winapi, there is no way to do it [believe me, I tried]
 

Seto

Member

Wow so many replies so quickly,
Thanks again etheon, I will try the script you posted asap and see if it works. I had a quick look at the script and with this, the piece of script you posted before and the socket library there might be a chance to get this working :D.

Well I will check back and give the resualts as soon as I can.
 

Seto

Member

Sorry for not posting in so long,
I don't think I am smart enough to get this going I am going to put in a script request and hope to god someone is able to help.

Thanks for all you help everyone I never imagined that there would be so many people who were willing to help me out.

*Edit*

Umm were do I post script requests? I just had a look and couldn't seem to find the right place.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top