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.
case "add":
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(e.GetInt(1) + " joined!");
break;
Or might it be because i joined the world with a 2nd acount?
NOTE: This can only be received by the world owner.
Btw, it is probably the case that you placed it somewhere wrong. We can't do much without the whole thing code though :/
Ingame: marten22 My steam: MartenM
Offline
The reason you doesn't get the add message is because you don't use con.Send("init2") inside case "init":
Anyway. parameter 1 is a string, not integer. Do you even read the protocol?
Offline
The reason you doesn't get the add message is because you don't use con.Send("init2") inside case "init":
private static void OnMessage(object sender, Message e) { switch (e.Type) { case "init": con.Send("init2"); break; case "init2": Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Connected! I am EEANATOLY's bot."); con.Send("say", "This is DeathMark. I am EEANATOLY's bot."); break; } }
Where did you get that info from?
Ingame: marten22 My steam: MartenM
Offline
you are trying to get Integer, but you need a string.
e.GetString(1)
EDIT: wow guys you ae fast! posted 3 replies before me
Offline
capasha wrote:The reason you doesn't get the add message is because you don't use con.Send("init2") inside case "init":
Part of AnatolyEE's code from other topic wrote:private static void OnMessage(object sender, Message e) { switch (e.Type) { case "init": con.Send("init2"); break; case "init2": Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Connected! I am EEANATOLY's bot."); con.Send("say", "This is DeathMark. I am EEANATOLY's bot."); break; } }
Where did you get that info from?
I didn't have access to all his code, the reason I wrote it.
you are trying to get Integer, but you need a string.
e.GetString(1)
EDIT: wow guys you ae fast! posted 3 replies before me
Instead of e.GetString(1) you can use e[1].
Offline
You must be the owner of the world to get data. And as far as I know, you must work with the ID, not the username.
Offline
MartenM wrote:capasha wrote:The reason you doesn't get the add message is because you don't use con.Send("init2") inside case "init":
Part of AnatolyEE's code from other topic wrote:private static void OnMessage(object sender, Message e) { switch (e.Type) { case "init": con.Send("init2"); break; case "init2": Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Connected! I am EEANATOLY's bot."); con.Send("say", "This is DeathMark. I am EEANATOLY's bot."); break; } }
Where did you get that info from?
I didn't have access to all his code, the reason I wrote it.
Gosha wrote:you are trying to get Integer, but you need a string.
e.GetString(1)
EDIT: wow guys you ae fast! posted 3 replies before me
Instead of e.GetString(1) you can use e[1].
why nobody told me about that earlier:<
Offline
You must be the owner of the world to get data. And as far as I know, you must work with the ID, not the username.
No, you do also get the username at [1]. https://github.com/Tunous/EverybodyEdit … #rm-access
Bots are the same as players, if you can do it on your account (like see who is in a world) a bot can do it too.
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
Okay, everything works nicely.
But this line seems to be ignored:
con.Send("say","/pm" + e[1] + " Welcome to Death Mark!");
Why can't i send PMs?
Use space after "/pm" :^)
Offline
Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");
Offline
Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");
not everyone has the fancy net 4.6.2 mister
Offline
Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");
I can do that, too, but i like more the way i currently do.
Gosha wrote:Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");not everyone has the fancy net 4.6.2 mister
Then it's time to upgrade from Windows XP, which has been deprecated.
There's no excuse to refuse upgrading frameworks unless you're in a professional setting that prohibits it.
*u stinky*
Offline
ninjasupeatsninja wrote:Gosha wrote:Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");not everyone has the fancy net 4.6.2 mister
Then it's time to upgrade from Windows XP, which has been deprecated.
There's no excuse to refuse upgrading frameworks unless you're in a professional setting that prohibits it.
Aside from the valid linux/iOS reasons, money also is one.
Obviously you can just get an illegal crack of Windows, but not everybody knows how to do that, some are afraid of the possible consequences and others simply don't feel good about getting illegal software.
Offline
How to get the poster's name instead of his Id?
And how to connect to a non-running room?
PlayerIOClient.PlayerIOError: There is no room running with that id
at PlayerIOClient.Internal.identifier142+identifier842.Call_[identifier207,identifier211,PlayerIOError] (Int32 method, PlayerIOClient.Internal.identifier207 args) [0x00000] in <filename unknown>:0
at PlayerIOClient.Internal.identifier142+identifier842.Call[identifier207,identifier211,PlayerIOError] (Int32 method, PlayerIOClient.Internal.identifier207 args) [0x00000] in <filename unknown>:0
at PlayerIOClient.PlayerIO+ClientImpl+LogoutChannel.Call[identifier207,identifier211,PlayerIOError] (Int32 methodId, PlayerIOClient.Internal.identifier207 args) [0x00000] in <filename unknown>:0
at PlayerIOClient.Internal.identifier142.JoinRoom (System.String roomId, System.Collections.Generic.Dictionary`2 joinData, Boolean isDevRoom) [0x00000] in <filename unknown>:0
at PlayerIOClient.Internal.identifier940.JoinRoom (System.String roomId, System.Collections.Generic.Dictionary`2 joinData) [0x00000] in <filename unknown>:0
at DeathMark.MainClass.Main (System.String[] args) [0x00042] in /home/anatoly/EE/DeathMark/DeathMark/Program.cs:22
Create a class Player
in Programm class create new Dictinary and name it Players.
in Message.Type == "add"
write these lines
In Message.Type == "left"
write this
now you have a list of all players in the world.
now, if you have players id you can get it's Username.
Players[PLACEIDHERE].Username
Extra stuff:
In Message.Type == "say"
you can use these lines
string Sender = Players[m.GetInt(0)].Username;
string[] arg = m.GetString(1).Split(' ');
now you can see the chat.
Sender = player who said something in chat
arg = what player said.
arg[0] - 1st word
arg[1] - 2nd word
and so on
Offline
▲all code
▼class Player
▼Dictionary
▼Add Players
▼Player has left
I would recommend to add this to all the add/check/and remove things than use the dictionary.
if(Players.ContainsKey(m.getInt(0)))
Ingame: marten22 My steam: MartenM
Offline
<snip>
Props for posting images and not text for people just to copy and paste.
<snip>
Extra stuff:
In Message.Type == "say"
you can use these linesstring Sender = Players[m.GetInt(0)].Username; string[] arg = m.GetString(1).Split(' ');
now you can see the chat.
Sender = player who said something in chat
arg = what player said.
arg[0] - 1st word
arg[1] - 2nd word
and so on
You should've provided an explanation of this. I'll go through line by line so he understands.
string Sender = Players[m.GetInt(0)].Username;
Based off of your Dictionary<uint, Player>, you can use that to retrieve data back from a user. That being said, you can store far more information about a user than only their username and id, as Remmoze pointed out.
string[] arg = m.GetString(1).Split(' ');
This line of code gets takes the message that was sent, and splits it into what's called an array.
For example if I did "Hello, I am Emalton" it would then create this:
{ "Hello,", "I", "am", "Emalton" }
That being said you can use that to create commands.
string First_Chunk = arg[0];
The [0] in the code below tells the bot to get the first part of the array, which is "Hello," in this case.
Using this logic, you can do:
if (First_Chunk == "Hello,") // If the first word is equal to "Hello,"
{
Do Stuff
}
The two slashes are comment lines; the compiler ignores what is written on the same line after it. They are purely used for your reference.
--
As proficient bot programmers, we must explain what we are doing, and not to simply spoon feed code. Explain what you are doing so people don't get overwhelmed / ask tons of questions.
I suggest you learn C# before you dive into bots.
EDIT:
And how to connect to a non-running room?
PlayerIOClient.PlayerIOError: There is no room running with that id
You must create it then.
Instead of JoinRoom use CreateJoinRoom like below:
Client client = ...;
Connection derp = client.Multiplayer.CreateJoinRoom(YourRoomID, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, new Dictionary<string, string>(), new Dictionary<string, string>());
The first parameter, or "YourRoomID" is the RoomID you put in. To get it, do /roomid in game.
The second parameter, or "Everybodyedits" + client.BigDB.Load("config", "config")["version"] is called the room type.
(almost) Each time EE pushes out an update, they update the room type. It always begins with Everybodyedits, but the number at the end will change. Use client.BigDB.Load("config", "config")["version"] to load the latest number from the database. "config", "config" Table and key and the ["version"] is the property.
The remaining parameters you may leave as below:
true, new Dictionary<string, string>(), new Dictionary<string, string>());
true = Visibility
And the two dictionaries are roomdata and joindata.
Offline
Client client = ...; Connection derp = client.Multiplayer.CreateJoinRoom(YourRoomID, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, new Dictionary<string, string>(), new Dictionary<string, string>());
The first parameter, or "YourRoomID" is the RoomID you put in. To get it, do /roomid in game.
The second parameter, or "Everybodyedits" + client.BigDB.Load("config", "config")["version"] is called the room type.
(almost) Each time EE pushes out an update, they update the room type. It always begins with Everybodyedits, but the number at the end will change. Use client.BigDB.Load("config", "config")["version"] to load the latest number from the database. "config", "config" Table and key and the ["version"] is the property.The remaining parameters you may leave as below:
true, new Dictionary<string, string>(), new Dictionary<string, string>());true = Visibility
And the two dictionaries are roomdata and joindata.
ok thank you for your explanation but dont reinvent wheels
string WorldID = "World-ID-Here";
con = client.Multiplayer.CreateJoinRoom((WorldID.ToLower().StartsWith("ow") ? WorldID.Replace("-", " ") : WorldID), (WorldID.ToLower().StartsWith("bw") ? "Beta" : "Everybodyedits" ) + client.BigDB.Load("config", "config")["version"], true, null, null);
very good code that still works
Offline
very good code that still works
ok thank you for your contribution but wouldn't it be better to explain things?
I suppose we should explain ternary operators... and why you care about "ow" (does actual "ow" (not "OW") even exist?) or "bw"... and what benefit you see from replacing the Dictionary with null...
Offline
and what benefit you see from replacing the Dictionary with null...
You don't use the dictionary yourself, all it'll do by providing one is add a tiny bit certain memory.
Besides, who knows what PlayerIO does in the background with that dictionary, resulting in more memory and cpu usage.
Obviously it's a micro optimisation by providing null (if it even is an optimisation).
Eitherway: You're not doing anything with the player insight, so why provide it data? (even though it's empty).
So question back at you:
What benefit do you see by replacing null with a dictionary..?
Offline
What benefit do you see by replacing null with a dictionary..?
I really don't see a difference. Typing "null" is faster for me.
I'm simply asking ninja to appreciate the level of detail Emalton provided, rather than shunning it with a somewhat confusing line of code.
Offline
The bot itself is only getting a username via "init". In my case how do I add the bot acount to the list?
[ Started around 1732736401.297 - Generated in 0.209 seconds, 13 queries executed - Memory usage: 1.9 MiB (Peak: 2.21 MiB) ]