Acum este oficial, noul Gothic Multiplayer a fost lansat. Germanul Mainclain pune la dispozitie un nou multiplayer, acesta a publicat si open source, astfel permite tuturor celor interesati sa vada cum este sincronizat Gothic Multiplayer.
Orice altceva, cum ar fi chat-ul, vremea, calculul dmg-ului ruleaza in fisierele serverului, oferind o posibilitate usoara de utilizat si programat.
Limbajul de programare folosit de aceasta data este C#.
Link Oficial: Gothic II Untold Chaper
Momente ale zilei+ploaie. Author: Mainclain. (DayTime.cs)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GUC.Server.Scripting;
using GUC.Server.Scripting.Objects;
namespace GUC.Server.Scripts
{
class DayTime
{
protected long timeStart = 0;
public void Init()
{
timeStart = DateTime.Now.Ticks;
Timer timer = new Timer(10000 * 1000* 3);//Alle 3 Sekunden!
timer.OnTick += new Events.TimerEvent(onTick);
timer.Start();
}
int day = -1;
public void onTick()
{
long time = DateTime.Now.Ticks - (timeStart);
time *= 24*48;//*1 => Echt-Zeit! *24 => 1Stunde => 1 Tag
TimeSpan ts = new TimeSpan(time);
World.setTimeFast(ts.Days, (byte)ts.Hours, (byte)ts.Minutes);
if (ts.Days > day && ts.Hours > 12)
{
day = ts.Days;
//Calculating Rain:
Random rand = new Random();
double startRain = 12.0 + rand.NextDouble() * 23;
startRain %= 24.0;
double maxEndTime = 36.0 - startRain;
if (startRain < 12.0)
maxEndTime = 12.0 - startRain;
if (maxEndTime < 1.0)
{
Console.WriteLine("Kein regen heute!");
return;
}
maxEndTime -= 1.0;
double endRain = (startRain + rand.NextDouble() * maxEndTime + 1.0);
byte startHour = (byte)startRain;
byte startMinute = (byte)((startRain - startHour) * 60);
byte endHour = (byte)endRain;
byte endMinute = (byte)((endRain - endHour) * 60);
Console.WriteLine(startHour+":"+startMinute+" | "+endHour+":"+endMinute);
World.setRainTime(World.WeatherType.Snow, startHour, startMinute, endHour, endMinute);
}
}
}
}
Basic Chat System. Author: Mainclain. (Chat.cs)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GUC.Server.Scripting.GUI;
using GUC.Server.Scripting.Objects.Character;
using GUC.Server.Scripting;
namespace GUC.Server.Scripts
{
class Chat
{
protected MessagesBox mB;
protected TextBox tB;
public void Init()
{
tB = new TextBox("", "Font_Old_20_White.TGA", 0, 0x800, 0x0D, 0x54, 0x1B);
mB = new MessagesBox("Font_Old_20_White.TGA", 8, 0, 0);
tB.TextSended += new Events.TextBoxMessageEventHandler(textBoxMessageReceived);
tB.show();
mB.show();
Player.playerSpawns += new Events.PlayerEventHandler(playerSpawn);
Player.playerDisconnects += new Events.PlayerEventHandler(playerDisconnect);
}
public void playerSpawn(Player player)
{
mB.addLine(255, 255, 255, 255, player.Name + " betritt den Server");
}
public void playerDisconnect(Player player)
{
mB.addLine(255, 255, 255, 255, player.Name+" verlässt den Server");
}
public void textBoxMessageReceived(TextBox tb, Player pl, String message)
{
String upperMessage = message.ToUpper();
if (upperMessage.StartsWith("/REVIVE"))
{
pl.revive();
return;
}
mB.addLine(pl, 255, 255, 255, 255, pl.Name + ": " + message);
Player[] players = pl.getNearPlayers(2000);
foreach (Player player in players)
{
mB.addLine(player, 255, 255, 255, 255, pl.Name + ": " + message);
}
}
}
}
In open source, in folderul ServerScripts gasiti multe alte fisiere pentru serverul vostru.
Open source pentru acest multiplayer gasiti aici.
Pentru a putea folosi fisierele din open source este nevoie de compile folosind Visual Studio.
Pentru a configura serverul este nevoie sa mergeti in folderul Server/Config si sa deschideti intr-un editor de text server.config
Code:
<?xml version="1.0"?>
<ServerOptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ServerName>Test-Server</ServerName>
<Port>9054</Port>
<Slots>20</Slots>
<password />
<Modules />
<AdditionalLibs>
<string>Mono.Data.Sqlite.dll</string>
</AdditionalLibs>
<useScriptedFile>false</useScriptedFile>
<generateScriptedFile>true</generateScriptedFile>
</ServerOptions>