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 2016-11-25 17:02:46, last edited by Anatoly (2016-11-25 17:03:15)

Anatoly
Guest

case "add": not called when someone joins

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?

#2 2016-11-25 17:05:44, last edited by MartenM (2016-11-25 17:06:33)

MartenM
Member
From: The Netherlands
Joined: 2016-03-31
Posts: 966
Website

Re: case "add": not called when someone joins

Github wrote:

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 :/

The github


lm3hgg8.jpg

Ingame: marten22        My steam: MartenM

Offline

#3 2016-11-25 17:06:48, last edited by capasha (2016-11-25 17:08:20)

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

Re: case "add": not called when someone joins

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

#4 2016-11-25 17:08:31

MartenM
Member
From: The Netherlands
Joined: 2016-03-31
Posts: 966
Website

Re: case "add": not called when someone joins

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?


lm3hgg8.jpg

Ingame: marten22        My steam: MartenM

Offline

#5 2016-11-25 17:09:28, last edited by Gosha (2016-11-25 17:10:46)

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,202

Re: case "add": not called when someone joins

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

Wooted by:

#6 2016-11-25 17:38:26, last edited by capasha (2016-11-25 17:40:12)

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

Re: case "add": not called when someone joins

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].

Offline

#7 2016-11-25 18:58:36

drunkbnu
Formerly HG
Joined: 2017-08-16
Posts: 2,306

Re: case "add": not called when someone joins

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

#8 2016-11-25 19:08:45

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,202

Re: case "add": not called when someone joins

capasha wrote:
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

#9 2016-11-25 19:59:07, last edited by Koya (2016-11-25 19:59:17)

Koya
Fabulous Member
From: The island with those Brits
Joined: 2015-02-18
Posts: 6,310

Re: case "add": not called when someone joins

HG wrote:

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.


Po9cnQh.png

PLNQVL8.png
Thank you eleizibeth ^

1SYOldu.png

I stack my signatures rather than delete them so I don't lose them
giphy.gif

WfSi4mm.png

Offline

Wooted by:

#10 2016-11-25 20:00:26

Anatoly
Guest

Re: case "add": not called when someone joins

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?

#11 2016-11-25 20:20:57

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,202

Re: case "add": not called when someone joins

Use space after "/pm" :^)

Offline

#12 2016-11-25 20:24:16

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,202

Re: case "add": not called when someone joins

Also, it's easier to work with $
con.Send("say", $"/pm {e[1]} message");

Offline

Wooted by: (3)

#13 2016-11-25 22:01:50

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

Re: case "add": not called when someone joins

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

Offline

Wooted by: (4)

#14 2016-11-26 15:04:43

Anatoly
Guest

Re: case "add": not called when someone joins

Gosha wrote:

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.

#15 2016-11-26 15:16:49

XxAtillaxX
Member
Joined: 2015-11-28
Posts: 4,202

Re: case "add": not called when someone joins

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.


signature.png
*u stinky*

Offline

#16 2016-11-26 18:04:32

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

Re: case "add": not called when someone joins

XxAtillaxX wrote:
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

Wooted by:

#17 2016-11-27 18:24:26, last edited by Anatoly (2016-11-27 18:51:24)

Anatoly
Guest

Re: case "add": not called when someone joins

How to get the poster's name instead of his Id?

V8ubDJw.png

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 

#18 2016-11-27 19:09:01

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,202

Re: case "add": not called when someone joins

Create a class Player

iQPPzM4.png


in Programm class create new Dictinary and name it Players.

Mapit2j.png

in Message.Type == "add"
write these lines

TaPEqaB.png

In Message.Type == "left"
write this

lQ1btHA.png


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

all code

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

Wooted by:

#19 2016-11-27 19:21:58

MartenM
Member
From: The Netherlands
Joined: 2016-03-31
Posts: 966
Website

Re: case "add": not called when someone joins

Remmoze wrote:

▲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)))

lm3hgg8.jpg

Ingame: marten22        My steam: MartenM

Offline

#20 2016-11-27 23:42:42, last edited by John (2016-11-27 23:48:53)

John
Member
Joined: 2019-01-11
Posts: 1,972

Re: case "add": not called when someone joins

Remmoze wrote:

<snip>

Props for posting images and not text for people just to copy and paste. //forums.everybodyedits.com/img/smilies/smile

Remmoze wrote:

<snip>
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

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:

AnatolyEE wrote:

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.


PW?scale=2

Offline

Wooted by:

#21 2016-11-28 01:06:18, last edited by SirJosh3917 (2016-11-30 05:18:50)

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

Re: case "add": not called when someone joins

Emalton wrote:
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

#22 2016-11-28 02:50:05

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,852

Re: case "add": not called when someone joins

ninjasupeatsninja wrote:

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

#23 2016-11-28 17:12:21

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

Re: case "add": not called when someone joins

hummerz5 wrote:

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

#24 2016-11-28 17:29:25

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,852

Re: case "add": not called when someone joins

den3107 wrote:

What benefit do you see by replacing null with a dictionary..?

I really don't see a difference. Typing "null" is faster for me. //forums.everybodyedits.com/img/smilies/smile

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

#25 2016-11-28 18:29:35

Anatoly
Guest

Re: case "add": not called when someone joins

The bot itself is only getting a username via "init". In my case how do I add the bot acount to the list?

Tomahawk1480695043637978

Board footer

Powered by FluxBB

[ Started around 1711648818.8295 - Generated in 0.287 seconds, 10 queries executed - Memory usage: 1.88 MiB (Peak: 2.19 MiB) ]