Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
using System;
using System.Collections.Generic;
using PlayerIOClient;
using System.Threading;
namespace flygod
{
class MainClass
{
public static void Main(string[] args)
{
Dictionary<int,string> users = new Dictionary<int,string>();
Console.Write("email: ");
string username = Console.ReadLine();
Console.Write("password: ");
string password = Console.ReadLine();
Console.Write("worldid: ");
string worldid = Console.ReadLine();
Client cli = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw",username,password,null);
Connection con = cli.Multiplayer.CreateJoinRoom(worldid,"everybodyedits217",true,null,null);
con.Send("init");
con.OnMessage += (sender, m) => {
if (m.Type == "init") {
if (!m.GetBoolean(15)) { Console.WriteLine("not owner!"); Environment.Exit(10); }
con.Send("init2");
}
if (m.Type == "add") {
users.Add(m.GetInt(0),m.GetString(1));
}
if (m.Type == "god") {
con.Send("say", (m.GetBoolean(1) ? "/geffect ":"/reffect ") + users[m.GetInt(0)] + " 2");
con.Send("say", (m.GetBoolean(1) ? "/geffect ":"/reffect ") + users[m.GetInt(0)] + " 7");
}
};
Thread.Sleep(-1);
}
}
}
if someone wants they can compile it, but since i dont have any filehosting service i wont be hosting a compiled version, have fun.
Bsd clause 2 license (the part with provided as is is important in this case )
Offline
You didn't even dare on adding a system to hide the password.
For if you need it...
string pw= "";
ConsoleKeyInfo key;
do {
key = Console.ReadKey (true);
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter) pw += key.KeyChar;
else if (key.Key == ConsoleKey.Backspace && pw.Length > 0) pw = pw.Substring (pw.Length - 1);
} while (key.Key != ConsoleKey.Enter);
Offline
i doub't that many people look over your schoulder while you type in your password
Offline
This could crash if a player goes into god before they're added to the dictionary. Use Dictionary.TryGetValue() or slap a try catch in there.
Also you're assuming a constant EE version of 217. Read the version from the DB or avoid the need by using JoinRoom().
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Also you're assuming a constant EE version of 217.
intentional.
Offline
Tomahawk wrote:Also you're assuming a constant EE version of 217.
intentional.
K but then it'll crash messily for subsequent EE versions. If it's intentional, put in error checking so it doesn't just crash.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Era wrote:Tomahawk wrote:Also you're assuming a constant EE version of 217.
intentional.
K but then it'll crash messily for subsequent EE versions. If it's intentional, put in error checking so it doesn't just crash.
Do it yourself.
Offline
Do it yourself.
What a nubby attitude.
Code that's been posted for everyone to copy paste shouldn't crash. It's not my job to fix it.
Or is that why the license is included?
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
... AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
HG wrote:Do it yourself.
What a nubby attitude.
Code that's been posted for everyone to copy paste shouldn't crash. It's not my job to fix it.
Or is that why the license is included?
BSD 2-Clause License wrote:THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
BSD 2-Clause License wrote:... AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
You answered it by yourself.
THIS SOFTWARE IS PROVIDED ... "AS IS"
Offline
You answered it by yourself.
The point is that this forum section should only contain reliable code. Don't defend it.
My turn:
using System;
using System.Collections.Generic;
using PlayerIOClient;
namespace Fast_Godmode
{
class Program
{
static void Main(string[] args)
{
Dictionary<int, string> users = new Dictionary<int, string>();
string name;
bool terminating = false;
Console.Write("Enter email: ");
string email = Console.ReadLine();
Console.Write("Enter password: ");
string password = Console.ReadLine();
Console.SetCursorPosition(0, Console.CursorTop - 1);
Console.WriteLine("Enter password: " + new string('*', password.Length));
Console.Write("Enter room ID: ");
string roomID = Console.ReadLine();
PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", email, password, null, delegate (Client cli)
{
cli.Multiplayer.JoinRoom(roomID, null, delegate (Connection con)
{
con.Send("init");
con.OnMessage += (object sender, Message m) =>
{
if (m.Type == "init")
{
if (!m.GetBoolean(15))
{
con.Disconnect();
Console.Write("\nThe connected bot must be the world owner.\n\nPress any key to exit...");
Console.ReadKey();
Environment.Exit(0);
terminating = true;
}
con.Send("init2");
Console.Write("\nConnected. Press q to exit.");
}
if (m.Type == "add") users.Add(m.GetInt(0), m.GetString(1));
if (m.Type == "left") users.Remove(m.GetInt(0));
if (m.Type == "god" && users.TryGetValue(m.GetInt(0), out name))
{ con.Send("say", (m.GetBoolean(1) ? "/geffect " : "/reffect ") + name + " 2"); }
};
}, delegate (PlayerIOError e)
{
Console.Write("\nRoom connection error:\n\n{0}\n\nPress any key to exit...", e.Message);
terminating = true;
});
}, delegate (PlayerIOError e)
{
Console.Write("\nGame connection error:\n\n{0}\n\nPress any key to exit...", e.Message);
terminating = true;
});
while (!terminating && Console.ReadKey(true).Key != ConsoleKey.Q) ;
}
}
}
Disclaimer: I take full responsibility (but not liability) for any bot crashes that occur. Tell me and I'll fix the code.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
using System;
using static System.Threading.Thread;
namespace FG {
class Program {
static void Main (string[] a) {
string[] p = new string[0];
try {
Connection con = PlayerIO.QuickConnect.SimpleConnect ("everybody-edits-su9rn58o40itdbnw69plyw",a[0],a[1],null).Multiplayer.JoinRoom (a[2], null);
con.Send ("init");
con.OnMessage += delegate (object sender, Message e) {
switch (e.Type) {
case "init":
if (!e.GetBool (15)) Environment.Exit (5);
con.Send ("init2");
break;
case "init2":
Console.WriteLine ("Logged in.");
break;
case "add":
if (e.GetInt (0) > p.Length) Array.Resize (ref p, e.GetInt (0) + 200);
p[e.GetInt (0)] = e.GetString (1);
break;
case "god":
con.Send ("say", (e.GetBool (1) ? "/geffect " : "/reffect ") + p[e.GetInt (0)] + " 2");
break;
}
};
con.OnDisconnect += delegate (object sender, string reason) {
Console.WriteLine (reason);
Environment.Exit (55);
};
Sleep (-1);
} catch (Exception error) {
Console.WriteLine (error.Message);
Environment.Exit (1);
}
}
}
}
NOTE: Line 33 will throw an error, yet it will build fine and you can use it normally. This is an IDE bug, as the class System.Threading.Thread is static and so you can use the functions of it without having to prefix Thread.
Offline
@HG
You say the single-version connection is intended, yet don't state any reason why it'd be intended (then again, nobody asked).
Eitherway: If it's intended as a feature, you should do error handling of some sort, otherwise you'd make the program crash, without the users having any change of recovery or knowledge what happened (you made no claim anywhere that this was intended solely for version 217, or for any version really).
If it's not intended as a feature (for example to limit people from using this on other EE versions), then it's a bug (out of lazyness), since again, no error handling and it's not forward-compatible.
In short:
Just say that you were lazy and it was something you felt like could be useful.
Since you're not giving an actually executable (which you can upload in a hundred places), users probably won't use it, but programmers instead would take your idea (of the effect usage) and use that in their own bots.
In case you meant for it to be ripped by programmers, just tell them it's about the idea of the effect part, and that the connection part isn't something they should b**** about, as it's not the core intention of this post.
(nvm, in short wasn't that short)
Offline
I claimed that it was intended since i wrote it ,
this code is only intended for version 217 since the protocol changes to often, if some people use it for some other version that's not my problem.
besides, i don't really care if programmers use it or not, but tiny examples can be quite good for people starting to learn c# since most finished bots are way more complex then the tiny /working/ code i have put up there.
i also never claimed that this is a final or finished version, i will probably update it sometime.
edit: i do apreciate critizism on my code since i can learn from it, but please do not turn this into a flamethread or make some accusations that i intentionally post broken code, thank you.
edit2: i assumed that it was pretty clear from the code what it was intended for, a hardcoded version is obviously not ment for other versions, especially when it is easy to check for.
Offline
Pages: 1
[ Started around 1732728168.6401 - Generated in 0.100 seconds, 10 queries executed - Memory usage: 1.57 MiB (Peak: 1.75 MiB) ]