//as a happy reminder: Do not show password or email for anti-hacks
using System;
using PlayerIOClient;
using System.Threading;
using System.Collections.Generic;
namespace DeathMark
{
class MainClass
{
public static Connection con;
static Client client;
static Dictionary<int, Player> Players = new Dictionary<int, Player>();
static bool GamePaused;
static int GameState;
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("Deathmark");
try
{
client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "email", "password", null);
con = client.Multiplayer.JoinRoom("PWsDwXr3S-b0I", null);
}
catch (Exception i)
{
Console.WriteLine(i.ToString());
}
con.OnMessage += OnMessage;
con.Send("init");
Thread.Sleep(-1);
}
private static void Play() {
if (GamePaused == false) {
Thread.Sleep(17);
for (int a = 1; a < 26; a++) {
con.Send("b", 0, 37 + a, 55, 189);
//Console.WriteLine(37 + a); WORKS
}
}
Thread.Sleep(0);
}
private static void OnMessage(object sender, Message m)
{
switch (m.Type) {
case "init":
con.Send("init2");
break;
case "init2":
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Connected!");
GamePaused = false;
/*
* 1; Awaiting
* 2; Running
*/
GameState = 1;
Play();
con.Send("say", "[Bot] Connected!");
break;
case "add":
// Players[m.GetInt(0)].
Player player = new Player(m.GetInt(0), m.GetString(1));
Players.Add(player.Id, player);
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(m[1]);
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.Write(" joined! ");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("(Rank " + Players[m.GetInt(0)].Rank + ")");
if (Players[m.GetInt(0)].Rank == 5) {
con.Send("say", "/giveedit " + Players[m.GetInt(0)].Username);
con.Send("say", "/setteam " + Players[m.GetInt(0)].Username + " 6");
} else if (Players[m.GetInt(0)].Rank == 4) {
con.Send("say", "/giveedit " + Players[m.GetInt(0)].Username);
con.Send("say", "/setteam " + Players[m.GetInt(0)].Username + " 6");
} else if (Players[m.GetInt(0)].Rank == 3) {
con.Send("say", "/giveedit " + Players[m.GetInt(0)].Username);
} else if (Players[m.GetInt(0)].Rank == 2){
con.Send("say", "/givegod " + Players[m.GetInt(0)].Username);
} else if (Players[m.GetInt(0)].Rank == 0){
} else {
}
break;
case "left":
Players.Remove(m.GetInt(0));
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(m[1]);
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine(" left!");
break;
case "say":
string[] arg = m.GetString(1).Split(' ');
//Owner Only
if (Players[m.GetInt(0)].Rank == 5) {
if (arg[0] == "!save") {
con.Send("save");
con.Send("say", "[Bot] World Saved!");
}
}
// Adminstrator Commands
if (Players[m.GetInt(0)].Rank == 4 || Players[m.GetInt(0)].Rank == 5) {
// Which player is now edited?
string user = arg[1];
int editing = 0;
foreach(KeyValuePair<int,Player> p in Players)
{
if (p.Value.Username == user)
{
editing = p.Value.Id;
break;
}
}
// Commands
if (arg[0] == "!givecoins") {
int x = Int32.Parse(arg[2]);
Players[editing].Coins = Players[editing].Coins + x;
}
}
// Staff Commands
if (Players[m.GetInt(0)].Rank == 3 || Players[m.GetInt(0)].Rank == 4 || Players[m.GetInt(0)].Rank == 5) {
if (arg[0] == "!kick" && arg[1] != "botanatly") {
con.Send("say", "/kick " + arg[1] + " Kicked by " + Players[m.GetInt(0)].Username);
con.Send("say", "/forgive " + arg[1]);
} else if (arg[0] == "!ge") {
con.Send("say", "/giveedit " + arg[1]);
} else if (arg[0] == "!re") {
con.Send("say", "/removeedit " + arg[1]);
} else if (arg[0] == "!gg") {
con.Send("say", "/givegod " + arg[1]);
} else if (arg[0] == "!rg") {
con.Send("say", "/removegod " + arg[1]);
} else if (arg[0] == "!ld") {
con.Send("reset");
}
}
// Operation
if (Players[m.GetInt(0)].Rank == 2 || Players[m.GetInt(0)].Rank == 3 || Players[m.GetInt(0)].Rank == 4 ||
Players[m.GetInt(0)].Rank == 5) {
if (arg[0] == "!game") {
if (arg[1] == "start") {
con.Send("say", "[Bot] Game started!");
con.Send("say", "/name LavaLand [On]");
} else if (arg[1] == "pause") {
con.Send("say", "[Bot] Game paused!");
con.Send("say", "/name LavaLand [Off]");
} else if (arg[1] == "end") {
con.Send("say", "[Bot] Goodbye!");
con.Send("say", "/name LavaLand [Off]");
con.Disconnect();
Environment.Exit(0);
}
}
}
// Everyone
if (arg[0] == "!c") {
con.Send("say", "/pm " + Players[m.GetInt(0)].Username + " You have got " + Players[m.GetInt(0)].Coins + " coins!");
}
if (arg[0] == "!h") {
if (arg[1] == "c") {
con.Send("say", "/pm " + Players[m.GetInt(0)].Username + " Command '!c' gives you your current amount of coins");
} else if (arg[1] == null) {
con.Send("say", "/pm " + Players[m.GetInt(0)].Username + " Commands: !h <str>\n!c");
}
}
break;
}
}
}
class Player {
public int Id = 0;
public string Username = "Unknown";
public int Rank;
public int Coins;
public Player(int _Id, string _Username) {
Id = _Id;
Username = _Username;
// Give rank
/*
* 5 = Root Adminstrator [Edit Access, Yellow Team, Staff Commands, 9999 Coins]
* 4 = Adminstrator [Edit Access, Yellow Team, Staff Commands, 1000 Coins]
* 3 = Moderator [Edit Access, Staff Commands, 100 Coins]
* 2 = Operator [God Mode, 50 Coins]
* 1 = Normal
* 0 = Banned [Gets Kicked]
*/
if (Username == "eeanatoly") {
Rank = 5;
Coins = 9999;
/*} else if () {
Rank = 4;
Coins = 1000;*/
/*} else if () {
Rank = 3;
Coins = 100;*/
/*} else if () {
Rank = 2;
Coins = 50;*/
} else if (Username == "vitalijus" || Username == "kittro36") {
Rank = 0;
} else {
Rank = 1;
Coins = 0;
}
}
}
}