Jump to content
efeberk

Online Database System(PHP + MYSQL)

Recommended Posts

Online Database System

by efeberk

Version : 1.0.5

 

 

Introduction
 

 

It will enable player interacts with your MYSQL database. So players can have accounts or you can create some ranking tables or you can make a mailing system that players can send message to another player etc...
 
I can give many samples. And I prepared a useful demo that introduce you how does ODS work exactly.
 
Actually It is not like MMO script, doesn't require any machine that must be open 24h.
 
I made a photo about procedure with my newbie design :P
 
t5his6.png
I used php + mysql but I don't say that you must use them. You can use asp.net + access database of course because this script just requesting(GET) to the webpages. I said GET because I didn't make a script for posting. But php has a parameter like $_GET so it works like posting datas :)
 
Also I recorded a video that how to install this system to your hosting + your game. You need to have a hosting (free or paid) to store database and php files. I don't support free webhostings because they putting their ads on your php files. So it will cause of some errors on game. Let's see in the video:
 
Video has been blocked for a while.
 
Also I made many systems these you know on some MMORPG games. They are:
 
Login / Register
Ranking Table - Players racing
Guild System - Players cooperating
Couple System - Players flirting
Rental Shops - Players gaining
Bazaar System - Players trading
 
I also added a location API that finds your real country when you talk with a guy ;p Try it on demo.
 
You don't need to use custom scripts on your games. I just prepared them to show you what can you do with this system. Core scripts work on all RGSS version but custom scripts are only work on RGSS3. There is a guide about SQL injection in scripts. Look this in the demo.
 
Core + Custom scripts won't effect your base scripts. I mean if you are using Tanketai SBS or Gubid's TBS(actually I didn't try), it won't be problem I think. But I don't say with %100. So any problems/errors/bugs can be posted on this thread. 
 
Core Script ( I prefer play demo to understand something)

 
=begin
===============================================================================
 EFE's Request Script
 Version: RGSS & RGSS2 & RGSS3
 Special thanks : Ryex, Gustavo Bicalho, Kubiwa Taicho
===============================================================================
 This script will allow to request to some servers WITHOUT posting.(Only GET)
--------------------------------------------------------------------------------
Used WINAPI functions:

WinHTTPOpen
WinnHTTLConnect
WinHTTPOpenRequest
WinHTTPSendRequest
WinHTTPReceiveResponse
WinHttpQueryDataAvailable
WinHttpReadData

Call:

EFE.request(host, path, post, port)

host : "www.rpgmakervxace.net" (without http:// prefix)
path : "/forum/login.php" ( the directory path of your php file )
post : "username=kfdsfdsl&password=24324234"
port : 80 is default.

=end

module EFE
  
  # I took this method from Gustavo Bicalho's WebKit script. Special thanks him.
  def self.to_ws(str)
    str = str.to_s();
    wstr = "";
    for i in 0..str.size
      wstr += str[i,1]+"\0";
    end
    wstr += "\0";
    return wstr;
  end
  
  
  
  EFES_WINAPI = Win32API.new('ods', 'naber', 'pp', 'p')
  WinHttpOpen = Win32API.new('winhttp','WinHttpOpen',"PIPPI",'I')
  WinHttpConnect = Win32API.new('winhttp','WinHttpConnect',"PPII",'I')
  WinHttpOpenRequest = Win32API.new('winhttp','WinHttpOpenRequest',"PPPPPII",'I')
  WinHttpSendRequest = Win32API.new('winhttp','WinHttpSendRequest',"PIIIIII",'I')
  WinHttpReceiveResponse = Win32API.new('winhttp','WinHttpReceiveResponse',"PP",'I')
  WinHttpQueryDataAvailable = Win32API.new('winhttp', 'WinHttpQueryDataAvailable', "PI", "I")
  WinHttpReadData = Win32API.new('winhttp','WinHttpReadData',"PPIP",'I')
  #WinHttpWriteData = Win32API.new('winhttp','WinHttpWriteData',"PPIP",'I')

  def self.request2(host, path, post="")
    pr = path
    if(post != "")
      pr = pr + "?" + post
    end
    pr = pr.to_s
    a = EFES_WINAPI.call(to_ws(host), to_ws(pr))
    return a
  end
  
  def self.request(host, path, post="",port=80)
    p = path
    if(post != "")
      p = p + "?" + post
    end
    p = p.to_s
    pwszUserAgent = ''
    pwszProxyName = ''
    pwszProxyBypass = ''
    httpOpen = WinHttpOpen.call(pwszUserAgent, 0, pwszProxyName, pwszProxyBypass, 0)
    if httpOpen
      httpConnect = WinHttpConnect.call(httpOpen, to_ws(host), port, 0)
      if httpConnect
        httpOpenR = WinHttpOpenRequest.call(httpConnect, nil, to_ws(p), "", '',0,0)
        if httpOpenR
          httpSendR = WinHttpSendRequest.call(httpOpenR, 0, 0 , 0, 0,0,0)
          if httpSendR
            httpReceiveR = WinHttpReceiveResponse.call(httpOpenR, nil)
            if httpReceiveR
              received = 0
              httpAvailable = WinHttpQueryDataAvailable.call(httpOpenR, received)
              if httpAvailable
                ali = ' '*1024
                n = 0
                httpRead = WinHttpReadData.call(httpOpenR, ali, 1024, o=[n].pack('i!'))
                n=o.unpack('i!')[0]
                return ali[0, n]
              else
                msgbox_p("Error about query data available")
              end
            else
              msgbox_p("Error when receiving response")
            end
          else
            msgbox_p("Error when sending request")
          end
            
        else
          msgbox_p("Error when opening request")
        end
          
      else
        msgbox_p("Error when connecting to the host")
      end
        
    else
      msgbox_p("Error when opening connection")
    end
  end
end

 

 

 

 
Screenshots(12)

textbox.PNG
 
createchar.PNG
 
ranking.PNG
 
couplestatus.PNG
 
mailbox.PNG
 
maildetails.PNG
 
guildicon.PNG
 
yourguild.PNG
 
bazaarbuy.PNG
 
bazaarsell.PNG
 
Stalls.PNG
 
rentalshop.PNG

 
Known bugs

-

 
Download Demo(Compiled) : Not available
Edited by efeberk

Share this post


Link to post
Share on other sites

When VX Ace was originally released, I wondered if SQL databases could be integrated to allow for online games and record-tracking. Nice work!

Share this post


Link to post
Share on other sites

Can you interact with the others online here? I mean is can you see each other real time?

and also will it work with KHAS Sapphire action system? :3

thanks its a cool system

Share this post


Link to post
Share on other sites

First, this script looks like it could be amazing!!!

 

And I would also like to know if it's possible to interact with others in real-time with this. Would it be possible to make that? Or would it be possible to make like an online card game type thing (like almost all the Moba mobile games. IE: Fantasica)

 

Edit: Fantasica was a bad example, since it has many aspects of gameplay. But would people be able to trade and see each other is more or less what I'm asking, along with making leader boards and stuff.)

Edited by KevinFrost

Share this post


Link to post
Share on other sites

Can you interact with the others online here? I mean is can you see each other real time?

 

and also will it work with KHAS Sapphire action system? :3

 

thanks its a cool system

 

Did you try to interact with KHAS ABS? Try and if you got any error, open it here :)

 

Actually I don't know what included in Khas ABS. If a new system has been included like "Item Enchant" or "Different stats in status", you need add them to cor script or my script won't save them on the database.

 

 

First, this script looks like it could be amazing!!!

 

And I would also like to know if it's possible to interact with others in real-time with this. Would it be possible to make that? Or would it be possible to make like an online card game type thing (like almost all the Moba mobile games. IE: Fantasica)

 

Edit: Fantasica was a bad example, since it has many aspects of gameplay. But would people be able to trade and see each other is more or less what I'm asking, along with making leader boards and stuff.)

 

What do you mean with "interact with others in real time"? If you wanna make a PvP game like a card game or something, I think you should use different script because it doesn't work async. I mean that : in pvp games, you should check datas every 1 frame or 10 frames but this script doesn't allow it because if you do it, it will freeze much in game :)

 

You can google it : RGSS WebKit.

 

This script works async. You can find out what you want with this script.

Edited by efeberk

Share this post


Link to post
Share on other sites

A noob question, I can't seem to make an account :/ It just says that for every username that it is in use (I did try various names as well as mere jibberish). Is it that I need some separate account on something, or am I just missing something far too obvious?

 

EDIT: Nevermind, I was trying to do so on the opened version :P I got it working now.

 

This is an excellent script you have here, and I defiantly plan to put it to use! 

 

Edit 2: So I tried to set up the system myself by merely fallowing with the video using the opened download. Despite doing what I believe to be the exact same thing as you, I am being plagued with errors, things like not being able to send/look at mail (Says something about not being able to convert nil to string at line 50 of the mail script), and other such errors. Since I am using the website shown in the video, do you think these errors to this extent are all being caused by the free host?

Edited by Vis_Mage

Share this post


Link to post
Share on other sites

Great script I'll be using this for something.

 

Can you please edit your OP to include legal Terms of Use for your script? Such as if we're allowed to use it in commercial games, if we have to credit someone and who, stuff like that. Thanks. :)

Share this post


Link to post
Share on other sites

Thanks for the script,

 

i would like to ask, is it possible to make an npc that show Top 100 player, and the player able to sort the ranking by playing Time or highest level or Achievement score ?

 

and is it possible to make the game auto update the data every 30 min...? or the player must go and talk to npc that will update his data to the database to view them in the ranking NPC, 

 

 

Thanks.

Share this post


Link to post
Share on other sites

There is Scene_Ranking on the demo. You should set a variable as what you want(playingtime, highest level etc...) and you can show them on Scene_Ranking

Thanks gonna test it soon...

Share this post


Link to post
Share on other sites

well, i managed to put the scripts, and everything work, but some scripts don't work with Online database like achievement system
http://www.rpgmakervxace.net/topic/5554-csca-achievements/
 

and also about logdate in the database it show as 1388097084

 

and i have question about Nickname, will the nickname effect the character name or it's just the nickname that will be used in online ranking or other system, because when i played the demo the name of the character changed, i am not sure if it's because of character creation, but i have removed character creation from the game.

 

also, about editing the database, how the player new information update into the database? because when i tried it in my game, i get 40k Gold but it's not updated in the databse, also when i get exp it's also not updated in the database.

 

also the level, hp, mp, item, skill and steps not updated, do i add the VARIABLE to Game Infos & Datas in scripts like the other ?

 

also if i want to add new field in the database do i need to add new custom script ?

 

and here a better way to login and register, if you can manage to add this to your script

http://www.rpgmakervxace.net/topic/6803-perfect-password-protection-title-screen/

 

i think this  better because it's easy to use. when player start the game he dont need to see New Game, exit

 

all he need to see is the Login and Register and forget password button which will ask him to input the email he added when he register.

 

well, you need to add one more thing when player register... currently it's username, password, nickname. i think you should add email so he can restore his password easily by clicking forget password, than enter his email and he will see his password in the screen. with message like " your password is ******** which was registered with this email ********** " < something like that

if the email is not used " this email is not used". 

 

 

Thanks

waiting for your reply

Edited by OffeNDer

Share this post


Link to post
Share on other sites

Logdate has been prepared to prevent multi logins. When you use "checkMultiLogin(nickname_variable)", it will check if logDate changed. If true, it will close game.

 

Nickname is the name of the character. I mean it's actor's name.

 

If you wanna send new informations to the database, You need to know basic ruby & php & mySQL. There is a method named "updatePlayer" in Functions script. Look there and you will see all required datas have been sending to the server. You can add a new data on there but it won't finish with it. You also need to edit updatePlayer.php in PHP folder. 

 

Example : If you wanna send ATK parameter to the server. First you need add a new parameter to updatePlayer function in RGSS3. Also you need add a variable on the php file and you need to add it on SQL query. So it will add succesfully to the server. But it doesn't finish :)

 

updatePlayer function is sending datas to the server and refreshPlayer function retrieving datas from server and processing to the actor. So if you add ATK parameter to the structure, you need to add this on refreshPlayer function. It will set 64(example) ATK to the actor when the user logged succesfully.

 

When you need update player in game, you need just use "updatePlayer(nickname_variable)". So it will send all infos these required. You can use it on a parallel process.(every 30 sec it updates or something like that...)

 

If you wanna add an email verification system, you can do it. There are a lot of tutorials for PHP and you can find it easily. I also prepared demo as you saw, you can play it :)

 

For Achivement error, I'm not in home so if you can send a demo or something, i can test it and i can say what is faul exactly :)

Edited by efeberk

Share this post


Link to post
Share on other sites

i know mysql, (not too much), i can learn PHP from tutorials...

 

my last question.... in my game i have party, ( total 4 in-party with the new player ) player 1 is the main, so when i update the data to the database...

 

i log in again and the main character still have the same level 4, but the other start again from 1, can you help me with that....

 

Thanks

Share this post


Link to post
Share on other sites

i know mysql, (not too much), i can learn PHP from tutorials...

 

my last question.... in my game i have party, ( total 4 in-party with the new player ) player 1 is the main, so when i update the data to the database...

 

i log in again and the main character still have the same level 4, but the other start again from 1, can you help me with that....

 

Thanks

 

I didn't add party to the script. So you need add them on your system. You can contact me on skype. Let's talk there.

Share this post


Link to post
Share on other sites

Wow!

 

Pretty Cool Script.

 

I can this script use good in my Game, i have a Homepage with Database ( PHP + MYSQL ), I do not like free provider!

 

But, when i install the Script + MySql i became a "Game Interpreter Error " after the Login-Process, mhh when i Login with a 000webhost.com, with a free Domain, i have not Error's after Login and inGame.

 

But, when i with my Website Connected to the Game, i become some Errors, i can register a Account but i can`t login in the Game.

 

Can you help me? What am I doing wrong?

Share this post


Link to post
Share on other sites

Very cool script!

 

DarkDevilz you can only login or register when you do everything like in the video explained.

In the Demo it doesn't worked for me until i have made my own MYSQL database.

So do everything like in the video and you will be succesfull. :)

 

 

But now my own qoestions:

Accounts:

- How can i delete accounts?

- How can i change the admins password, because name: admin,  pass: admin isn't the Best ;)

- How can the player Loggout without returning to title or end the game?

Bazaar:

- Can you make that the price in the Notebox is the minimum the player can sell it for.

- I wonder if you can make  that some items can only be bought by other players if some requirements are fulfilled (Lvl, character,...)

- How can i set wich items can't be sold at the Bazaar?

- How can i sell armor or weapons?

Shop:

- If i rent a shop for 20000G the players G won't be dicreased. I wonder if i do something wrong?

 

Maybe anyone can help me with some of my question!

Edited by Nik0405

Share this post


Link to post
Share on other sites

Q : How can I delete accounts.

A : Easy. Just connect your MySQL database with phpMyAdmin and delete the row related with the account in "users" table.
 
Q : How can I change admin password
A : Connect your mysql database and open your "users" table and edit admin user row.
 
Q : How can players logout?
A : There is no logout thing in the system.
 
Q : Can you make that the price in the Notebox is the minimum the player can sell it for.
Q : I wonder if you can make  that some items can only be bought by other players if some requirements are fulfilled (Lvl, character,...)
Q : How can i set wich items can't be sold at the Bazaar?
A : I don't prefer to make scripts for special. But if I find a useful and logical script for ODS, I will work for this.
 
Q : How can i sell armor or weapons?
A : You can sell all things.
 
Q : If i rent a shop for 20000G the players G won't be dicreased. I wonder if i do something wrong?
A : Thanks for this. I can't believe how I didn't catch that bug :P I fixed it well and I uploaded new one. Please check the download links. And please share any bug you found :)

Share this post


Link to post
Share on other sites

I followed the video and everything seemed to work, but when I log into the game as admin, admin I get you entered incorrect datas if I register I still get it's already existing.

 

I edited the download version.

 

config

<?php
    $database_host = "mysql10.000webhost.com";
    $database_username = "a6075890_vx";
    $database_password = "removed";
    $database_name = "a6075890_vx";
    
    $START_GOLD = 1000;
    $MAX_BAZAAR = 5;
?>

 

Game & Info data

module SERVER
  HOST = "www.mordor3.hostoi.com"
  PATH = "/orpg/"
end

 

The link does work

http://www.mordor3.hostoi.com/

 

FileZilla connected correctly and I created a orpg folder inside public_html which contains all the php files

 

The SQL database was created and has the user profile of admin admin.  It also contains all the fields, variables, users, guilds, etc.

Edited by mordor

Share this post


Link to post
Share on other sites

i've followed exactly your video. Everything seemed ok but why after i registered and chose a character

i got a message "Coundn't Register". Help me, plz

Was it a host's problem or did i config st wrong?

bo3o.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×