Lennaerts PHP mysql multiplayer tutorial

4
  • 42 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

multiplayer.capx

Download now 501.64 KB

Stats

11,844 visits, 28,110 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Setting up the MySql Database

You should have access to a database, I will refer to the database simply as database, and call the tables by their given names.

If we take a short moment to contemplate what we need, we will discover our data needs arent that big at all. A short analasys will point out we need the following tables with info:

players : Unique ID code, locations (x,y), angle, state (alive/dead) and lets keep track of kills/killed.

shotsfired : Who shot, who needs to know who shot, when was the shot made, what was the shot angle.

messages : Making game information available to everyone

Giving it a bit more definition:

(tablename)

(column name) - (column type)

Table players:

id - int(11) - primary index, auto increment

playercode - varchar (32)

locx - float

locy - float

playerangle - float

State - varchar(5)

kills - int (11)

killed - int(11)

Table shotsfired:

id - int(11) , primary index, auto increment

shootercode - varchar(32)

playercodes - varchar(32)

angle - float

stamped - Timestamp - default: CURRENT_TIMESTAMP

Table messages:

id - int(11) , primary index, auto increment

playercodes - varchar (32)

message - TEXT

stamped - Timestamp - default: CURRENT_TIMESTAMP

MySql for players table creation:

    CREATE TABLE IF NOT EXISTS `players` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `playercode` varchar(32) NOT NULL,  `locx` float NOT NULL,  `locy` float NOT NULL,  `playerangle` float NOT NULL,  `state` varchar(5) NOT NULL,  `kills` int(11) NOT NULL,  `killed` int(11) NOT NULL,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

MySql for shotsfired table creation:

    
    CREATE TABLE IF NOT EXISTS `shotsfired` (  `id` int(11) NOT NULL AUTO_INCREMENT,   `shootercode` varchar(32) NOT NULL,  `playercodes` varchar(32) NOT NULL,  `angle` float NOT NULL,  `stamped` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    

MySql for messages table creation:

    CREATE TABLE IF NOT EXISTS `messages` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `playercodes` varchar(32) NOT NULL,  `message` text NOT NULL,  `stamped` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;    

Those are the tables, simple huh.

If you have added these tables, we are good to go to set up the php side of things.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!