Hello,
After a lot of fiddling and looking at others netcode... Mainly from DarkBASIC, I came up with this...
using System;
using System.Collections.Generic;
using System.Text;
namespace ChatTest
{
class Program : CDGDK
{
public static string strName;
public static string strIncoming;
public static string strSendout;
static void MainChat()
{
oDBCore.Print("Press control to send a message");
while (oDBP.LoopGDK)
{
if (oDBMultiplayer.NetMessageExists() == 1)
{
oDBMultiplayer.GetNetMessage();
if (oDBMultiplayer.NetMessageType() == 3)
{
strIncoming = oDBMultiplayer.NetMessageString();
}
}
if (oDBInput.ControlKey() == 1)
{
Write();
}
oDBCore.Sync();
}
}
static void Start()
{
if (oDBMultiplayer.NetGameExists() == 1)
{
oDBMultiplayer.JoinNetGame(1, strName);
}
else
{
oDBMultiplayer.CreateNetGame("Chat", strName, 200);
}
oDBMultiplayer.SendNetMessageString(0, strName + " Has Joined!");
oDBCore.Print(strName + " Has Joined!");
MainChat();
}
static void Main()
{
if (!InitializeDGDK("<AuthKey>"))
return;
oDBCore.Print("Please enter your username:");
strName = oDBCore.Input();
Start();
}
static void Write()
{
oDBCore.Print("type in your message to send:");
strSendout = oDBCore.Input();
oDBMultiplayer.SendNetMessageString(0, strSendout);
}
}
}
However... It has yet to work for me and I dont see why not. Could people please test it or add to it.
At the moment, it loads and everything seems to go perfect apart from...
if (oDBMultiplayer.NetGameExists() == 1)
{
oDBMultiplayer.JoinNetGame(1, strName);
}
else
{
oDBMultiplayer.CreateNetGame("Chat", strName, 200);
}
Here... it always makes a new NetGame regardless... Seems to ask for IP after its made one.. not before it looks for one... odd...
Well, thanks in advance guys... My game is almost done :p