Plug-in to support LU Season

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Plug-in to support LU Season

Post by FiringSquad »

In case you're not aware, there's a League that's creating quite a bit of excitement and activity.
https://leaguesunited.org/season

There's a small problem though.

It's hard to know which player is on which team.
I don't have a suitable development environment available, so I was wondering if someone could be so kind as to jump in and help.

The details are held in a Google Sheet.
See here The Sheet.

It's possible to access the sheet with a simple URL call.
e.g.

Code: Select all

https://sheets.googleapis.com/v4/spreadsheets/1DuNttGSSXWrVFcKVL61tiBVT6ezQFSSMHDhgLWll3mQ/values/Team%20Rosters!B:B?key=<MyApiKey-removed>
Which gets the contents of the B column.

Code: Select all

{
  "range": "'Team Rosters'!B1:B1000",
  "majorDimension": "ROWS",
  "values": [
    [
      "Orange Peanut"
    ],
    [
      "02345-xowu"
    ],
    [
      "brick2"
    ],
    [
      "CNT-FAI"
    ],
    [
      "Cole l"
    ],
    [
      "Crazy pal pig"
    ],
    [
      "etigah"
    ],
    [
      "Fear"
    ],
    [
      "FiringSquad"
    ],
    [
      "Frank the Tank"
    ],
    [
      "Hogfish"
    ],
    [
      "Ivano"
    ],
    [
      "Luz Mala"
    ],
    [
      "mammouth (mathiaz)"
    ],
    [
      "Mega EE"
    ],
    [
      "peracottaro"
    ],
    [
      "possum jenkins"
    ],
    [
      "quantumfoam"
    ],
    [
      "RIP"
    ],
    [
      "Shuist"
    ],
    [
      "THACO21"
    ],
    [
      "tox"
    ],
    [
      "zaa"
    ]
  ]
}
If you want to use this method, you'll need to sign up to Google Console and create an API Key. The Free Tier is enough. Don't publish your key though, as you don't want it to be used nefariously.

Alternatively, the sheet can be downloaded as a CSV and just process it locally within the plug-in.
The sheet will be updated as new players join.
Not sure how frequently this changes.

Doesn't need to be too fancy.

Something like

Code: Select all

/LU
LeaguesUnited Players on this server:
Orange Peanut: Orange Peanut, FiringSquad, zaa
Gaboot: leviathan, catay
Moroni:
plop: lep
Of course, you can feel free to make it fancier if you wish. :-)

Any takers?
User avatar
Zehra
Private First Class
Private First Class
Posts: 743
Joined: Sun Oct 18, 2015 3:36 pm
Location: Arctic
Contact:

Re: Plug-in to support LU Season

Post by Zehra »

It seems a bit complex though and might be a bit excessive. (Possibility of lots of repeated calls, despite the data not changing frequently.)

Storing the content locally within a flat file database might be a good option.(Or SQLite or similar, but this might be a bit excessive.)

We can cache this is store the player data in a few arrays and look it up there and if anything changes, we update the flat file.
Around 30-40 entries per team should be alright at this point.(Unless we get a sudden influx of players.)
The team leaders and admins should be able to update/adjust the records as well.

If flat file is used for the database, I'd store the data with the following notion:

Code: Select all

BZID<TAB>TEAMID<TAB>PLAYER-CALLSIGN
We can do this safely or even adjust it differently, since player's callsigns do not carry tabs.

Code: Select all

std::string playerCallsigns[4][40];
unsigned long playerBZID[4][40];
int playerTeam[4][40];
You'd still need to keep track of the highest number in each array.
Also, some string length adjustments, so messages may be properly formatted.
(This all up to developer preference, not going into specific detail here.)

What can then be done, is to also hold the some of the relative values on player join and reset on part.
The logic looks somewhat like the following:

Code: Select all

OnJoin
  ifPlayerIsInTeam
  playerTeam[player] is Team
else
  playerTeam[player] is negative.
This would be stored in an array, so we don't look up all players on each "query".
Also, on the join event, we can announce the player team or group or as an option.(Might be a useful feature.)

So in the end, a plug-in somewhat like the following might result:

Code: Select all

Sample Plug-in
data{
// team info
string [4][40] // player callsigns in teams
num [4][40] // player bzids
team [4][40] // player teams
// some minor details
num [4]// max slots of callsigns, bzids and teams
num [4]// team leaders bzids
string [4] // team leaders callsigns
num [200] // isPartofTeam
string [200] // playerCallsign
num [200]// length of callsign
num[4] // players of team joined on server
// still keep a default callsign/bzid in case of error. 
// and some variables for counting, but depending on implementation, they may be local variables.
}

OnJoin
  if(playerisverified)
      lookup teams and bzid...
      add to isPartofTeam with data.
      add to playerCallsign
      add to length of callsign
      add to players of team online
      // do stuff
  else
    isPartofTeam is false.
end

OnPart
  resetLookupData//isPartofTeam, playerCallsign, length of callsign and misc.
  
onSlashCommand
  if (see players)
    listPlayers in lists.

  if (add player to team)
    if (playerisadmin or team leader)
      add player to team info

  if (current players)
    // perform lookup if team has players online
    // add player to string, if callsign length addition does not make string too long
    // send message with string, continue/repeat process until we are finished with list.
    
  if (current teams)
    // list teams player count on servers
  
  if (current players in team)
    // list current players from x team
Which is something I'd probably write if I was going to do it.

But then again, this might be complete overkill for a single query.
Still, it might be worth looking into.

-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Re: Plug-in to support LU Season

Post by FiringSquad »

The simpler the better :-)

I imagine the teams will be small enough to hold in memory.

The API call should definitely not be called every time. I just thought it might be useful for initialisation.
Post Reply