Ok, so you sent me a PM describing to make your game online. Have you any experience in scripting? Did you do the research?
Basically, this is how it works. You have a server(which can be written in any programming language you know - suggested to use a dynamic language for better threading and speed) and you need a client script. The client script has to be in python. The client script uses the internet to send packages(Strings, integers, or whatever) to the server. The server process this information and sends it back to all the rest of the clients so they know your position and processes that you are doing.
What is required?
The client: Here’s a ultra simple client…
from socket import*
Controller = GameLogic.getCurrentController()
Owner = Controller.getOwner()
ObjectList = GameLogic.getCurrentScene().getObjectList()
Once = Controller.getSensor("Once")
MouseOver = Controller.getSensor("MouseOver")
Click = Controller.getSensor("Click")
Login = Controller.getActuator("Login")
GameLogic.host = "www.google.ca"
GameLogic.port = 80
GameLogic.socket = socket(AF_INET, SOCK_STREAM)
The server depends greatly on what you have. If you have a python IDE, (you can use IDLE a python GUI) and execute python scripts you write in word or notepad.
Your server will look something like this…
from socket import *
import re, thread
HOST = "localhost"
PORT = 5005
BUF = 1024
ADDR = (HOST, PORT)
server_socket = socket(AF_INET, SOCK_STREAM)
clients = [ ]
found = 0
for client in clients:
if client == user:
found = 1
if not found:
def handle_login(data, client_socket):
groups = re.match('(type=)(.*)( user=)(.*)( passw=)(.*)', data )
user = groups.group(4)
passw = groups.group(6)
if user == passw:
print "-Login attempt with '" + user + "' successful"
client_socket.send("type=login user=" + user +" success=1")
print "-Login attempt with '" + user + "' unsuccessful"
client_socket.send("type=login user=" + user + " success=0")
def handle_chat(data, client_socket):
groups = re.match('(type=)(.*)( from=)(.*)( to=)(.*)( message=)(.*)', data )
sender = groups.group(4)
reciever = groups.group(6)
message = groups.group(8)
print "-Chat message; " + sender + ": " + message
if reciever == "all":
for client in clients:
client = find_client(reciever)
if client != 0:
def handle_client(client_socket, ap):
data = client_socket.recv(BUF)
if not data: a = on_purpose_error
command = re.match('(type=)(.*?)( )(.*)', data ).group(2)
if command == "login":
user = handle_login(data, client_socket)
elif command == "chat":
print "-Client from:", ap, "disconnected"
(client_socket,ap) = server_socket.accept()
print "-Client from:", ap, "connected"
thread.start_new_thread(handle_client, (client_socket, ap))
Once you set up a connection… Your GameLogic.socket.* is basically what you use for all the internet game play. GameLogic. just makes it a global method meaning all scripts can use it. You’ll most likely use GameLogic.socket.send(“text”)… It has to be in the form of a string, you can’t send numbers or anything. So, if you have an integer, just use pythons str(int) method. For example…
GameLogic.socket.send(user+" "+str(LocX)+" "+str(LocY)+"
I can’t really go into further detail… but look it up! You’ll find many resources. I hope this helps.
H Y P E R R E A L