Official Everybody Edits Forums

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.

#1 2015-04-28 02:16:34, last edited by SirJosh3917 (2015-04-28 20:33:25)

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

[Code] Starting off a bot.

So do use the following piece of code, all you need to do is paste it in your static Class Program {} (console/form) part of your program. This should work fine, if not; you most likely placed it in the wrong place.
You will also have to add 2 using statements:
using PlayerIOClient;
using System.Threading;

You will also have to add the PlayerIOClient to the references.

All you need to do is configure it. (in the #region Configure)
I would recommend closing the regions, and here are some things to know about using it:

Joining:
Use the Join() function to join servers.
Join("[email protected]", "MyPassword", "WorldID");

Finding out if a player is admin.
if( IsAdmin(PlayerID) )

Adding/Removing admins
AddAdmin(PlayerID);
RemoveAdmin(PlayerID);

Finding out if a player is a mod.
If( IsMod(PlayerID) )

Adding/Removing Mods
AddMod(PlayerID);
RemoveMod(PlayerID);

Getting the PlayerID of a player by name
int RandomPersonsId = PlayerIdOf("PlayerName");

Building Blocks
Foreground = 0
Background = 1
Layer is the Foreground or Background
BuildBlock(X_Position, Y_Position, Block_ID, Layer);

I really hope this is helpful //forums.everybodyedits.com/img/smilies/big_smile.
This should get you off your feet after you use it. //forums.everybodyedits.com/img/smilies/cool

***
NOTICE:
Only use if you are at least a little experienced in bot making, and can make your own bot without needing any code.
***

#region BotStarter
#region Configure
public static string BotName = "ExampleBot";
public static string CommandStart = ".";
public static int MaxArraySize = 10000;
//MaxArraySize = (10000 = 10,000 = 10 Thousand)
#endregion
#region Variables
public static Connection con;
public static Client client;
public static string rot13 = "";
public static string[] players = new string[MaxArraySize];
public static string[] mods = new string[MaxArraySize];
public static string[] admins = new string[MaxArraySize];
#endregion
#region Player IO Messages
static void OnMessage(object sender, PlayerIOClient.Message m)
{
    switch (m.Type)
    {
		case "init":
		rot13 = Derot(m.GetString(5));
		con.Send("init2");
		Say("Connected.");
		break;
		case "add":
		players[m.GetInt(0)] = m.GetString(1);
    break;
		case "say":
			int PlayerID = m.GetInt(0);
			string Command = m.GetString(1);
			if (Command.StartsWith(CommandStart))
			{
				string CommandIssuer = players[m.GetInt(0)];
				var Cmds = Command.Split(' ');
				Cmds[0] = Cmds[0].Substring(1, Cmds[0].Length - 1);
				//Regular Player Commands
				switch (Cmds[0])
				{
					case "playercommand":
						Say("Hello " + CommandIssuer + "!");
						break;
				}
				//Mod Commands (Admins can also use)
				if(IsMod(PlayerID) || IsAdmin(PlayerID))
				{
					switch(Cmds[0])
					{
						case "modcommand":
							Say("Hellp Mod " + CommandIssuer + "!");
							break;
						case "addmod":
							int WhoToAdd = PlayerIdOf(Cmds[1]);
							//If the player was not found, PlayerIdOf returns -1.
							if(WhoToAdd == -1)
							{
								Say("That player doesn't exist!");
							} else {
								AddMod(WhoToAdd);
							}
							break;
						case "buildblock":
							int X_Position = 10;
							int Y_Position = 10;
							int Block_ID = 9;
							int Background = 1;
							int Foreground = 0;
							BuildBlock(X_Position, Y_Position, Block_ID, Foreground)
					}
				}
				//Admin Commands
				if(IsAdmin(PlayerID))
				{
					switch(Cmds[0])
					{
						case "admincommand":
							Say("Hellp Admin " + CommandIssuer + "!");
							break;
						case "addadmin":
							int WhoToAdd = PlayerIdOf(Cmds[1]);
							//If the player was not found, PlayerIdOf returns -1.
							if(WhoToAdd == -1)
							{
								Say("That player doesn't exist!");
							} else {
								AddAdmin(WhoToAdd);
							}
							break;
					}
				}
			}
		break;
    }
}
#endregion
#region Functions
public static void BuildBlock(int x, int y, int block_id, int bgorfg)
{
	con.Send(rot13, bgorfg, x, y, block_id);
}
public static int PlayerIdOf(string who)
{
	int counter = 0;
	int returnvalue = -1;
	foreach(string i in players)
	{
		if(i == who)
		{
			returnvalue = counter;
		}
		counter += 1;
	}
	return returnvalue;
}
public static bool IsAdmin(int id)
{
	if(admins[id] == players[id])
	{
		return true;
	} else {
		return false;
	}
}
public static bool IsMod(int id)
{
	if(mods[id] == players[id])
	{
		return true;
	} else {
		return false;
	}
}
public static void AddAdmin(int id)
{
	admins[id] = players[id];
}
public static void RemoveAdmin(int id)
{
	admins[id] = "";
}
public static void AddMod(int id)
{
	mods[id] = players[id];
}
public static void RemoveMod(int id)
{
	mods[id] = "";
}
public static void Join(string email, string pass, string worldid)
{
    client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", email, pass, null);
    con = client.Multiplayer.JoinRoom(worldid, null);
    con.OnMessage += OnMessage;
    con.Send("init");
}
public static void Say(string text)
{
	Thread.Sleep(100);
    con.Send("say", BotName + "> " + text);
	Thread.Sleep(100);
}
public static string Derot(string worldKey)
{
    char[] array = worldKey.ToCharArray();

    for (int i = 0; i < array.Length; i++)
    {
int number = array[i];

if (number >= 'a' && number <= 'z')
{
    if (number > 'm')
number -= 13;
    else
number += 13;
}
else if (number >= 'A' && number <= 'Z')
{
    if (number > 'M')
number -= 13;
    else
number += 13;
}

array[i] = (char)number;
    }

    return new string(array);
}
#endregion
#endregion

Enjoy! https://wiki.everybodyedits.com/images/c/c0/069_LOL

Offline

Wooted by: (2)

#2 2015-04-28 02:50:20

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: [Code] Starting off a bot.

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

Offline

Wooted by: (2)

#3 2015-04-28 03:00:58

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: [Code] Starting off a bot.

Hexagon wrote:

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

^This

Also, why can't people just code it the "normal" way instead of using these? Shouldn't they learn that way before other stuff?


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#4 2015-04-28 03:02:11

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

Hexagon wrote:

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

Well... Actually that's a good question.
The reason i use it is... well... No level has had 1,000,000 players join in total.
Nor has a bot been online that long
so its only reasonable...
100 thousand is also reasonable, but not 10 thousand.
Think of it as the only level a player can join...
And as if everybody loves that level.
From my perspective, I think its reasonable; 1 million.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Offline

#5 2015-04-28 03:03:17, last edited by SirJosh3917 (2015-04-28 20:34:57)

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

Xfrogman43 wrote:
Hexagon wrote:

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

^This

Also, why can't people just code it the "normal" way instead of using these? Shouldn't they learn that way before other stuff?

The answer to that is - well this is for professionals and both beginners.
The professionals can use this if their too lazy to be re-coding bots (like me),
and the beginners can use it as a base.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

EDIT:

ninjasupeatsninja wrote:

The professionals can use this if their too lazy to be re-coding bots (like me),

Notice how i called myself a professional...
i didn't mean to do that - i just meant

ninjasupeatsninja wrote:

their too lazy to be re-coding bots (like me)

part. sorry for the misunderstanding

Offline

#6 2015-04-28 03:11:36

rgl32
Member
Joined: 2015-02-15
Posts: 543

Re: [Code] Starting off a bot.

ninjasupeatsninja wrote:
Xfrogman43 wrote:
Hexagon wrote:

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

^This

Also, why can't people just code it the "normal" way instead of using these? Shouldn't they learn that way before other stuff?

The answer to that is - well this is for professionals and both beginners.
The professionals can use this if their too lazy to be re-coding bots (like me),
and the beginners can use it as a base.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Well the thing is, and I know some people don't learn this way but, programming is pretty hands on, you gotta test and re-test stuff to make it work the way you want it to. You gave them a ton of things, and it's honestly the largest 'beginner' post about a guide that I have seen here. I'm not saying it's not good to give people some things, but if people are even somewhat interested in this, they should not be spoon-fed all the information all the material, and learn through trial and error, not just given a code to put into a program. Just my 2 cents.

Offline

#7 2015-04-28 03:13:25

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

rgl32 wrote:
ninjasupeatsninja wrote:
Xfrogman43 wrote:
Hexagon wrote:

Sorry, this is probably a stupid question but why do you need an array size of one million? Isn't that a bit...big?

^This

Also, why can't people just code it the "normal" way instead of using these? Shouldn't they learn that way before other stuff?

The answer to that is - well this is for professionals and both beginners.
The professionals can use this if their too lazy to be re-coding bots (like me),
and the beginners can use it as a base.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Well the thing is, and I know some people don't learn this way but, programming is pretty hands on, you gotta test and re-test stuff to make it work the way you want it to. You gave them a ton of things, and it's honestly the largest 'beginner' post about a guide that I have seen here. I'm not saying it's not good to give people some things, but if people are even somewhat interested in this, they should not be spoon-fed all the information all the material, and learn through trial and error, not just given a code to put into a program. Just my 2 cents.

No - when I say beginner, I mean a semi-experienced person who knows how to make a basic bot by hand.
Anyways, thank you for making me classifying that.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Offline

#8 2015-04-28 06:09:07

darkblades
Member
From: New MLG City/Weed Town
Joined: 2015-03-21
Posts: 122

Re: [Code] Starting off a bot.

It's too complicated for me. I used a way easier method to handle users and say messages and isgod/ismod


Sample Text.

Doritos/Mountain Dew eater.
420 No scoping 69 scrubs per day
Always smoke weed everyday.

Known for: #getrekt Bot (possible revive with new stuff?)

Offline

#9 2015-04-28 11:23:06, last edited by den3107 (2015-04-28 11:28:30)

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [Code] Starting off a bot.

ninjasupeatsninja wrote:
Hidden text

Well... Actually that's a good question.
The reason i use it is... well... No level has had 1,000,000 players join in total.
Nor has a bot been online that long
so its only reasonable...
100 thousand is also reasonable, but not 10 thousand.
Think of it as the only level a player can join...
And as if everybody loves that level.
From my perspective, I think its reasonable; 1 million.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Make it easy, make it fast, make it lightweight:
Use Dictionary or List.

ninjasupeatsninja wrote:
Hidden text

No - when I say beginner, I mean a semi-experienced person who knows how to make a basic bot by hand.
Anyways, thank you for making me classifying that.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

Since other persons than you use it, I suggest commenting everything.
Other people don't think the way you do and you shouldn't expect them to learn how you think.
Commenting makes sure they understand it before having to go through a lot of trouble.

P.s. I do think it's nice somebody made something like this, although I won't use it, since I always want to use as less stuff made by others than I think is reasonable (meaning I won't make my own physics).

Offline

#10 2015-04-28 11:52:03, last edited by DarkDragon4900 (2015-04-28 11:53:22)

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: [Code] Starting off a bot.

ninjasupeatsninja wrote:
Hidden text

The answer to that is - well this is for professionals and both beginners.
The professionals can use this if their too lazy to be re-coding bots (like me),
and the beginners can use it as a base.
Thank you for your post :)

You might wanna make a template if adding the joining code and all every time you create a new project isn't your thing.
Beginners would rather use finished apis too.
Sharing is caring, though.
Use his code if you want. Else leave :p it's not a big deal, really.

Offline

#11 2015-04-28 15:11:39

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: [Code] Starting off a bot.

"The professionals can use this if their too lazy to be re-coding bots (like me),"

I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.

Offline

#12 2015-04-28 17:02:32

Mylo
Master Developer
From: Drama
Joined: 2015-02-15
Posts: 829

Re: [Code] Starting off a bot.

Come on. He put some effort into this. And most of you guys trash it seither because you would not use it or because beginners wouldn't "learn" anything.

You don't have to use it. And maybe someone even looks into his code and learns something or finds use for it. There are a lot of silent readers and not everyone comments on a post though. Ninjasupeatsninja, keep it up :3

Offline

#13 2015-04-28 17:26:12

goeyfun
Member
From: Mighty Japan
Joined: 2015-02-18
Posts: 667

Re: [Code] Starting off a bot.

There's a lot of alternative methods //forums.everybodyedits.com/img/smilies/tongue


Ug3JzgO.png

Offline

#14 2015-04-28 18:26:04

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: [Code] Starting off a bot.

Mylo wrote:

Come on. He put some effort into this. And most of you guys trash it seither because you would not use it or because beginners wouldn't "learn" anything.

No, if you are trying to teach, you should do some research and make sure you are teaching the correct things. Laziness is no excuse for professionals.

Now what we haven't done is to teach him why this is wrong and what alternative there are.

Let's do the maths here:
Strings are reference types, each reference takes 8 bytes on 64-bit.
You have three arrays using 1 million references.
That is 3 * 1 000 000 * 8 = 21 000 000 aka about 21MB of ram.
21 MB of ram is a lot!

How about using a List<> instead? I'm pretty sure it is easier to explain a List to a beginner (a set of items sorted in a specific order) than it is to explain an array (a drawer with 1 million slots).
A HashSet<int> (a list of checkboxes for every possible userId, you can tick or untick them) would be the best way if you are concerned about performance.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Wooted by: (3)

#15 2015-04-28 20:17:18

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

DarkDragon4900 wrote:
ninjasupeatsninja wrote:
Hidden text

The answer to that is - well this is for professionals and both beginners.
The professionals can use this if their too lazy to be re-coding bots (like me),
and the beginners can use it as a base.
Thank you for your post //forums.everybodyedits.com/img/smilies/smile

You might wanna make a template if adding the joining code and all every time you create a new project isn't your thing.
Beginners would rather use finished apis too.
Sharing is caring, though.
Use his code if you want. Else leave //forums.everybodyedits.com/img/smilies/tongue it's not a big deal, really.

Oh shoot, now that i realized that - I said professionals (like me) - I didn't mean professional.
And I do see your points, but for me I prefer having something to paste in.

Offline

#16 2015-04-28 20:18:43

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

Processor wrote:
Mylo wrote:

Come on. He put some effort into this. And most of you guys trash it seither because you would not use it or because beginners wouldn't "learn" anything.

No, if you are trying to teach, you should do some research and make sure you are teaching the correct things. Laziness is no excuse for professionals.

Now what we haven't done is to teach him why this is wrong and what alternative there are.

Let's do the maths here:
Strings are reference types, each reference takes 8 bytes on 64-bit.
You have three arrays using 1 million references.
That is 3 * 1 000 000 * 8 = 21 000 000 aka about 21MB of ram.
21 MB of ram is a lot!

How about using a List<> instead? I'm pretty sure it is easier to explain a List to a beginner (a set of items sorted in a specific order) than it is to explain an array (a drawer with 1 million slots).
A HashSet<int> (a list of checkboxes for every possible userId, you can tick or untick them) would be the best way if you are concerned about performance.

Oh. Ok, but I don't use List<>s, i use arrays. But this surely is a terrible, terrible post.

Offline

#17 2015-04-28 20:19:46

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

Mylo wrote:

Come on. He put some effort into this. And most of you guys trash it seither because you would not use it or because beginners wouldn't "learn" anything.

You don't have to use it. And maybe someone even looks into his code and learns something or finds use for it. There are a lot of silent readers and not everyone comments on a post though. Ninjasupeatsninja, keep it up :3

Thank you for your post //forums.everybodyedits.com/img/smilies/smile, but at the same time the other posts are helpful.
I might update this.

Offline

#18 2015-04-28 20:20:46

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

Processor wrote:
Mylo wrote:

Come on. He put some effort into this. And most of you guys trash it seither because you would not use it or because beginners wouldn't "learn" anything.

No, if you are trying to teach, you should do some research and make sure you are teaching the correct things. Laziness is no excuse for professionals.

Now what we haven't done is to teach him why this is wrong and what alternative there are.

Let's do the maths here:
Strings are reference types, each reference takes 8 bytes on 64-bit.
You have three arrays using 1 million references.
That is 3 * 1 000 000 * 8 = 21 000 000 aka about 21MB of ram.
21 MB of ram is a lot!

How about using a List<> instead? I'm pretty sure it is easier to explain a List to a beginner (a set of items sorted in a specific order) than it is to explain an array (a drawer with 1 million slots).
A HashSet<int> (a list of checkboxes for every possible userId, you can tick or untick them) would be the best way if you are concerned about performance.

And also processor, did you notice that you could configure the max array size?
I'm sure you did, and some people might not think it needs to be that high.

Offline

#19 2015-04-28 20:28:41

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

darkblades wrote:

It's too complicated for me. I used a way easier method to handle users and say messages and isgod/ismod

It's ok, you don't have to use it; i mean, why even bother with it if you think it's complicated? .

Offline

#20 2015-04-28 20:29:31

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

capasha wrote:

"The professionals can use this if their too lazy to be re-coding bots (like me),"

I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.

Like what (besides arrays that i could be using <list>s)?

Offline

#21 2015-04-28 20:30:42

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

goeyfun wrote:

There's a lot of alternative methods //forums.everybodyedits.com/img/smilies/tongue

Of course! This is just for people who don't want to re-code stuff and who would prefer using something that is... well... ok-ish to use. It does include some features and functionality that is useful...

Offline

#22 2015-04-28 20:34:07

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: [Code] Starting off a bot.

7 posts after eachother wow,

capasha wrote:
"The professionals can use this if their too lazy to be re-coding bots (like me),"
I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.
Like what (besides arrays that i could be using <list>s)?

depends on the bot of course


if you can read this....good for you

Offline

#23 2015-04-28 21:33:34

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

ewoke wrote:

7 posts after eachother wow,

capasha wrote:
"The professionals can use this if their too lazy to be re-coding bots (like me),"
I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.
Like what (besides arrays that i could be using <list>s)?

depends on the bot of course

Well... Arrays are just as good, right? Plus it does have the function PlayerIdOf("player name") (as an int)... i don't see any reason not to use arrays.

Offline

#24 2015-04-28 21:38:08

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: [Code] Starting off a bot.

ninjasupeatsninja wrote:
ewoke wrote:

7 posts after eachother wow,

capasha wrote:
"The professionals can use this if their too lazy to be re-coding bots (like me),"
I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.
Like what (besides arrays that i could be using <list>s)?

depends on the bot of course

Well... Arrays are just as good, right? Plus it does have the function PlayerIdOf("player name") (as an int)... i don't see any reason not to use arrays.

sure but you could use if (list.Contains("name")) without even writing a function for it


if you can read this....good for you

Offline

#25 2015-04-28 23:29:45

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Code] Starting off a bot.

ewoke wrote:
ninjasupeatsninja wrote:
ewoke wrote:

7 posts after eachother wow,

capasha wrote:
"The professionals can use this if their too lazy to be re-coding bots (like me),"
I would build a new one from the beginning instead of using yours. Yours have some things that isn't even needed.
Like what (besides arrays that i could be using <list>s)?

depends on the bot of course

Well... Arrays are just as good, right? Plus it does have the function PlayerIdOf("player name") (as an int)... i don't see any reason not to use arrays.

sure but you could use if (list.Contains("name")) without even writing a function for it

Well... I don't mind writing a function once whatsoever. Eh, whats the point of rewriting the code anyways?

Offline

goeyfun1430383231500061

Board footer

Powered by FluxBB

[ Started around 1714196633.0506 - Generated in 0.101 seconds, 11 queries executed - Memory usage: 1.93 MiB (Peak: 2.26 MiB) ]