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-10 11:58:46, last edited by madiik (2015-04-10 13:01:45)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

"left" PlayerIO.Message not working properly

if (m.Type == "left")
            {
                EEName Player = Players.Find(
                    delegate(EEName plr)
                    {
                        return plr.UserId == m.GetInt(0);
                    }
                );
                if (Player != null)
                {
                    if (PlayersPlaying.Contains(Player))
                        PlayersPlaying.Remove(Player);
                    Players.Remove(Player);
                }
            }

Why won't this work properly? Sometimes it just tends to, not remove players?

Also, EEName is a class for EE Players, wich stores wins, userid and name. Any help?

List<EEName> Players = new List<EEName>();
List<EEName> PlayersPlaying = new List<EEName>(); //used to determine who is currently on map in Volcanic Earth


shh i have returned

Offline

#2 2015-04-10 12:45:16

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

Re: "left" PlayerIO.Message not working properly

What are
PlayersPlaying
Player
and Players
I can help if you state those.


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#3 2015-04-10 13:01:34

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

Xfrogman43 wrote:

Player

wtf.

EEName Player = Players.Find(
                    delegate(EEName plr)
                    {
                        return plr.UserId == m.GetInt(0);
                    }
                );

shh i have returned

Offline

#4 2015-04-10 13:38:43

Srna
Member
Joined: 2015-02-26
Posts: 220

Re: "left" PlayerIO.Message not working properly

U made it all complicated, just do Player.Remove(m.GetInt(0));
.-.

Offline

#5 2015-04-10 14:01:32

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

Your answer is useless as you cannot REMOVE an integer, but only an EEName class. pls.


shh i have returned

Offline

#6 2015-04-10 14:48:36, last edited by darkblades (2015-04-10 14:56:22)

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

Re: "left" PlayerIO.Message not working properly

you need to make a dictionary called "names" so that it works on every case.
the dictionary you use will be integer,string.
your int is the id of the player in number
your string is the name of the player in text
on case add, add it into the names
so that when your player leaves remove it from the names using the id. I think @srna wanted to mean


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

#7 2015-04-10 15:25:50

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

darkblades wrote:

you need to make a dictionary called "names" so that it works on every case.
the dictionary you use will be integer,string.
your int is the id of the player in number
your string is the name of the player in text
on case add, add it into the names
so that when your player leaves remove it from the names using the id. I think @srna wanted to mean

How would this make the code any different? I use a List with a class. It changes nothing.

I believe it is the "left" message that does not stack when some things lag, but I believe I might have a mistake in my code so I asked the forums.


shh i have returned

Offline

#8 2015-04-10 15:41:17

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

Re: "left" PlayerIO.Message not working properly

do people even debug nowadays?


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

Offline

#9 2015-04-10 16:15:57, last edited by Zumza (2015-04-10 16:21:01)

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: "left" PlayerIO.Message not working properly

That delegate looks suspicious to me.
Post the Players.Find method.

Also, about the list remove, you should override equaly in EEName class to work properly.


Everybody edits, but some edit more than others

Offline

Wooted by:

#10 2015-04-10 16:44:55, last edited by madiik (2015-04-10 16:45:17)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

Zumza wrote:

That delegate looks suspicious to me.
Post the Players.Find method.

Also, about the list remove, you should override equaly in EEName class to work properly.

public bool Equals(EEName other)
    {
        return this.UserName == other.UserName;
    }

why are you doing this to me ;(

delegate() works fine.

ewoke wrote:

do people even debug nowadays?

yes. but i can't be sure if its the "left" or my code


shh i have returned

Offline

#11 2015-04-10 17:00:53, last edited by madiik (2015-04-10 17:01:16)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

It is the full code. Stop getting used to switch(m.Type) pls.

it's just

if

no

case "left":

shh i have returned

Offline

#12 2015-04-10 18:17:50

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: "left" PlayerIO.Message not working properly

its your code...


Everybody edits, but some edit more than others

Offline

#13 2015-04-10 18:18:58

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

Zumza wrote:

its your code...

How can you be so sure?

Tell me. A reason is expected.


shh i have returned

Offline

#14 2015-04-10 18:20:13

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

http://forums.everybodyedits.com/viewtopic.php?id=27255

Why don't you make me a one if this one doesn't fit...

if (m.Type == "left")
            {
                EEName Player = Players.Find(
                    delegate(EEName plr)
                    {
                        return plr.UserId == m.GetInt(0);
                    }
                );
                if (Player != null)
                {
                    if (PlayersPlaying.Contains(Player))
                        PlayersPlaying.Remove(Player);
                    Players.Remove(Player);
                }
            }

shh i have returned

Offline

#15 2015-04-10 18:45:43, last edited by Zumza (2015-04-10 18:47:01)

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: "left" PlayerIO.Message not working properly

madiik wrote:
Zumza wrote:

its your code...

How can you be so sure?

Tell me. A reason is expected.

Its your code.
Reason: Nobody else have this 'bug', 'error' or how you want to name it.

madiik (duplicated topic) wrote:

Why don't you make me a one if this one doesn't fit...

Just take ewoke and mine advices and stop duplicating topics insinuating that is a problem outside your code.
Because Im and probably others too, are offended because people like you feel that we are in some way obligated to help, and accept this?


Everybody edits, but some edit more than others

Offline

#16 2015-04-10 18:51:56, last edited by madiik (2015-04-10 19:50:02)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: "left" PlayerIO.Message not working properly

Zumza wrote:
madiik wrote:
Zumza wrote:

its your code...

How can you be so sure?

Tell me. A reason is expected.

Its your code.
Reason: Nobody else have this 'bug', 'error' or how you want to name it.

madiik (duplicated topic) wrote:

Why don't you make me a one if this one doesn't fit...

Just take ewoke and mine advices and stop duplicating topics insinuating that is a problem outside your code.
Because Im and probably others too, are offended because people like you feel that we are in some way obligated to help, and accept this?

If I use a custom class with a List, how else am I supposed to find "something" in that list? delegate is the way to see inside classes.

- oh wait, i could just do LINQ too, but it would still probably be the same.

Players.Find(nm => nm.UserId == m.GetInt(0));


shh i have returned

Offline

#17 2015-04-10 20:21:19, last edited by realmaster42 (2015-04-10 20:21:54)

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: "left" PlayerIO.Message not working properly

madiik wrote:
Zumza wrote:
madiik wrote:
Zumza wrote:

its your code...

How can you be so sure?

Tell me. A reason is expected.

Its your code.
Reason: Nobody else have this 'bug', 'error' or how you want to name it.

madiik (duplicated topic) wrote:

Why don't you make me a one if this one doesn't fit...

Just take ewoke and mine advices and stop duplicating topics insinuating that is a problem outside your code.
Because Im and probably others too, are offended because people like you feel that we are in some way obligated to help, and accept this?

If I use a custom class with a List, how else am I supposed to find "something" in that list? delegate is the way to see inside classes.

- oh wait, i could just do LINQ too, but it would still probably be the same.

Players.Find(nm => nm.UserId == m.GetInt(0));

just dont do all that **** they tell u to do ^
                                                          ||

and code with a simple and shortened way:

public Dictionary<name, id> Players = new Dictionary<name, id>{ };

not sure about name, id but u surely know how to do it

Usage:

Players[m.GetInt(0)]

Add:

Players.AddKey(m.GetString(1), m.GetInt(0))

Left:

Players.RemoveValue(m.GetString(1)) 

or however it's done


http://i.imgur.com/bjvgH5L.png?1

Offline

#18 2015-04-10 20:32:46, last edited by Zumza (2015-04-10 20:33:14)

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: "left" PlayerIO.Message not working properly

marcoantonimsantos wrote:

just dont do all that **** they tell u to do ^
                                                          ||

and code with a simple and shortened way:

public Dictionary<name, id> Players = new Dictionary<name, id>{ };

not sure about name, id but u surely know how to do it

Usage:

Players[m.GetInt(0)]

Add:

Players.AddKey(m.GetString(1), m.GetInt(0))

Left:

Players.RemoveValue(m.GetString(1)) 

or however it's done

madiik want with she's own classes, why you want to limitate her?


Everybody edits, but some edit more than others

Offline

#19 2015-04-10 21:22:22

skullz17
Member
Joined: 2015-02-15
Posts: 6,699

Re: "left" PlayerIO.Message not working properly

                if (Player != null)

I haven't done any coding in a long time, but why would Player ever be null if you've just defined it as something? Also, is there any point in even having that there? Can't you just get rid of that if statement altogether? If you have received the message "left" and you know which player left, then you can just remove them from your PlayersPlaying and your Players straight away.


m3gPDRb.png

thx for sig bobithan

Offline

#20 2015-04-10 21:34:00, last edited by DarkDragon4900 (2015-04-10 21:38:51)

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

Re: "left" PlayerIO.Message not working properly

struct Player { public string Name; public int Wins; public bool isPlaying;}
Dictionary<int, Player> Players = new Dictionary<int, Player>();
Dictionary<string, int> wins = new Dictionary<string, int>();
//...
// TODO: Read the wins file and save it to the wins dictionary.
//...
if (e.Type == "add")
{
Players.Add(e.GetInt(0), new Player(){Name = e.GetString(1), Wins = wins[e.GetString(1)], isPlaying = false});
}
// Set isPlaying to true once the player joins the playing area, and whenever you wanna check, do
// foreach (var player in Players) { if (player.isPlaying) {/*Do whatever you want.*/}}
// Or, if you want a specific player
// foreach (var player in Players) { if (player.isPlaying && player.Name == Players[e.GetInt(0)].Name) {/*More random stuff*/} }
if (e.Type == "left")
{
Players.Remove(e.GetInt(0)); // Player is removed, along with their "isPlaying" status.
}

Offline

#21 2015-04-11 22:57:55, last edited by ewoke (2015-04-11 22:58:54)

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

Re: "left" PlayerIO.Message not working properly

or make a easy void/string

public string getName(int id)
{
       foreach(EEName t in players)
       {
              if(EEName.id == id)
              {
                     return id;
              }
       }
       return null;
}

if(m.Type=="left")
{
do something with getName(m.GetInt(0));
}

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

Offline

Wooted by: (3)
ewoke1428789475493744

Board footer

Powered by FluxBB

[ Started around 1713858747.1479 - Generated in 0.065 seconds, 11 queries executed - Memory usage: 1.69 MiB (Peak: 1.92 MiB) ]