55 Replies
is there a question?
I can't seem to accomplish the structure I mentioned
What's wrong with your current code? Seems like it should work. Not sure if mainList should actually be a list, though, but what you have should be functional
Well, I have no way of identifying each list
Sounds like maybe you want a new class
How would I add this class inside a list?
using my variable names, it would be
party.Players.Add(player);I want to have the ability to go through all these player lists, (lets call these parties), so the player can request to join any party with an ID they provide
Yes, that would add a new player
I want to add this whole playerlist to a list, so I can sort through them easily
something like that?
Thank you, this is what I'd use to find the ID, but the question I was trying to ask is, how would I create
parties? To hold all the partiesSpot on. Thank you so much.
sure thing!
does all that make sense?
Right,
var parties has to be inside an running function, but I'd want parties to be global, which means I could access it from all functions (inside single c#), how could I accomplish this?Just declare it outside of a method
I can't declare
var in a class though, only the functions that are inside of the classdon't use var, then.
I'm a bit confused, this would create 1 party inside
parties, and I cannot create/Add new parties outside this classWhat do you mean?
That snippet doesn't create any parties, it's just an empty list
You can create a method to add a new party or to add a player to an existing party
oh, it creates a List that holds PlayerLists
Could also make the parties public, but wasn't sure how you're using it to know if that's appropriate. You could also leave it private and just be able to access it through public methods like
public void AddParty(Party party) and public void AddPlayerToParty(int partyId, BasePlayer player)
I renamed my PlayerList type to Party in my examples. Seems like a more appropriate nameHmm, I can't seem to access the methods I created inside the MyThing class
are they public?
How are you trying to access the methods?
createParty has to be inside of some classIsn't it inside the class "Parties" already?
oh, I mean yes
Oh, yeah, one is, then you have another
createParty method outside of the classthe other method I have is inside an other class
oh okay
All of this code is inside another class

you can't do
Parties.createParty because it's not static
You need an instance of the classYou need an instance of
Parties
Ninja'd lolhaha
please don't go through it twice
that should work
this is just a dictionary
Right, that would be a better idea haha
// it's match instead of party.
Okay, so the match is created successfully with the matchId
Upon trying to enter the match by providing the player & matchId, it doesn't find the match and returns false, any idea why this happens?
looks like you have
matches and _matches. Are you sure you're checking the correct object?Sorry, edit mistake, I have updated it now, that's how it is in my project
Best bet would be to set a breakpoint and see what is in
_matches when in gets to the addPlayerToMatch method.Any() isn't what goes through twice. it's the combination of the two calls .Any() and .FirstOrDefault(). both iterate the collection to find a match
like mentioned, this should really just be a dictionary thoughIn it's current state, I agree, but it wouldn't allow for expansion of a party definition
right
you can still have a cache
because it's empty?
There is a match that is created before this
you're not using that here
It's created here and returns true
also we have properties, use them
I'm cutting off some code, cause I don't wanna clutter everything
you're cutting out critical parts
don't do that or you'll get questions like these
this whole class seems kinda unnecessary...
if it's not printing anything that's because there's nothing there to print
easy as that
I was considering that I retrieve matches wrongfully, and therefore nothing prints. Anyways then, must be something wrong with
createMatch()also i would advise you early on to follow c# conventions
public members are
PascalCase
actually, almost all declarations are PascalCase
methods, public members (properties, and technically fields, but fields should never be public!), types (classes, structs), namespacesOkay, so I think I have gotten to the bottom of this issue
Whenever I call
createMatch(int matchId), I now return _matches. Now, every time a new match is created, the returned _matches only contains the match that is created. Which leaves me to think that, every time the Matches class is used, a new list of _matches is made overwriting/ignoring the old list. How would I go around to fix this issue?
Resolved. This was because I create a new instance of Matches every time I call a method. Thank you everybody, for your help & answers.$close
Use the
/close command to mark a forum thread as answeredWas this issue resolved? If so, run
/close - otherwise I will mark this as stale and this post will be archived until there is new activity.