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.
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 .
This should get you off your feet after you use it.
***
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!
Offline
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?
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
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
Offline
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
EDIT:
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
their too lazy to be re-coding bots (like me)
part. sorry for the misunderstanding
Offline
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
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
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 postWell 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
Offline
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
▼Hidden textWell... 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
Make it easy, make it fast, make it lightweight:
Use Dictionary or List.
▼Hidden textNo - 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
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
▼Hidden textThe 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
"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
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
Offline
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
ninjasupeatsninja wrote:▼Hidden textThe 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 postYou 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 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
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
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 , but at the same time the other posts are helpful.
I might update this.
Offline
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
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
"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
There's a lot of alternative methods
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
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
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
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
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
[ Started around 1732483115.0609 - Generated in 0.149 seconds, 12 queries executed - Memory usage: 1.93 MiB (Peak: 2.26 MiB) ]