Page 1 of 3

Script.Round : Fetch Score + Alter live modescript_settings

Posted: 17 Nov 2019, 15:57
by Palteza
Hey Undef & all,

I'm updating a private plugin from xaseco to uaseco, I'm struggling where I can gather the Score for a given player at the end of a round (or at the end of a map, but I suppose it's the same).
Since Score from GetCurrentRanking is not available for the Script.Round it seems.

An other question : still for the same mode, is there a way we could alter LIVE (without restarting uaseco, like the modification would be effective on next map), the parameters in modescript_settings.xml (would like to change rounds_per_map, or couple of other parameters). Atm the only way is to change it in the file and restart uaseco to make it updated, if I'm right.

Thanks in advance.

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 17 Nov 2019, 20:32
by undef.de
You do not have to call the methods (like "GetCurrentRanking") from the dedicated server by yourself, all you need UASECO keep that up-to-date for you:
https://www.uaseco.org/development/classes/rankinglist.php#getRankByLogin wrote:

Code: Select all

$login = 'puennt_ennel';
$rank = $aseco->server->rankings->getRankByLogin($login);
$rank is the Class Ranking object.

Just use the chat command

Code: Select all

/modescript reload
to reload the changed settings of your config/modescript_settings.xml :thumbsup:

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 18 Nov 2019, 20:45
by Palteza
All right, get it, thanks !

Little question, if, in modescript_settings.xml, I disable the display of informations such as <checkpoint_time>, <checkpoint_list>, ...., I don't have performance improvement right ?

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 18 Nov 2019, 22:44
by undef.de
Palteza wrote: 18 Nov 2019, 20:45 in modescript_settings.xml, I disable the display of informations such as <checkpoint_time>, <checkpoint_list>, ...., I don't have performance improvement right ?
No, those widgets are made with ManiaScript and work only locally.

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 30 Nov 2019, 18:50
by Palteza
Ok, in my initial question I ask you how to get the round points for a given player, so your answer was perfect (getRankByLogin, then I have access to it $rank->rounds_points).

But if I have to collect these points for a hundred of players in a loop, is this method still good ? In terms of performance I mean. Or is there a more proper way ? Or I'm worrying for nothing ? :D
I mean to be sure to keep the server (and controller) stable with a big amount of players, I don't know where I have to be careful.

edit : aka, is there now an equivelance of the GetCurrentRanking in Script.Rounds, where I can get, in one object, the score (round_points) of every players present in the rankings ?

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 01 Dec 2019, 14:38
by undef.de
In this case you should use this:

Code: Select all

foreach ($aseco->server->rankings->ranking_list as $login => $data) {
		// ...
}
$data contains this:

Code: Select all

'rank'			=> 1,
'login'			=> 'puennt_ennel',
'nickname'		=> '$S$W$F90Gιммє$FF0ツ',
'round_points'		=> 12,
'map_points' 		=> 10,
'match_points'		=> 8,
'best_race_time'	=> 3741,				// Best race time in milliseconds
'best_race_respawns'	=> 2,					// Number of respawn during best race
'best_race_checkpoints'	=> array(1740,2475,3122,3741),		// Checkpoints times during best race
'best_lap_time' 	=> 0,					// Best lap time in milliseconds (only in ModeScript "Laps")
'best_lap_respawns'	=> 0,					// Number of respawn during best lap (only in ModeScript "Laps")
'best_lap_checkpoints'	=> 0,					// Checkpoints times during best lap (only in ModeScript "Laps")
'prev_race_time'	=> 7411,				// Best race time in milliseconds of the previous race
'prev_race_respawns'	=> 3,					// Number of respawn of the previous race
'prev_race_checkpoints'	=> array(2871,3012,4587,7411),		// Checkpoints times of the previous race
'stunts_score'		=> 50,
'prev_stunts_score' 	=> 125,
See also: https://www.uaseco.org/development/classes/ranking.php

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 01 Dec 2019, 20:25
by Palteza
Great, I made my algo with that, thanks again!

Is the only way to display local records (in a proper widget) is via records_eyepiece ?

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 02 Dec 2019, 18:15
by undef.de
As I don't know details on what you want to do, it's a bit difficult for me to advice you what's the best way to code. If you want to display a widget like local records from RecordsEyepiece, then it would be better done in ManiaScript (which runs like JavaScript on the client side).

I was playing around - a long time ago - with the LiveRankingWidget in RecordsEyepiece, that could be a good start for you (but be careful, this code isn't finished yet): https://github.com/undeflabs/UASECO/blo ... .php#L7630

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 04 Dec 2019, 14:06
by Palteza
Yeah if I had the level in coding I would have done few things in ManiaScript (and if there was a proper and deep documentation, or I missed something ?).
But for the local records I will finally simply not display them and try to keep ressources light, this is not an essential info in that format.

Beacause, for the rest of the plugin, i'm coding a bit "in the fog" concerning perfomance side. On php side, and controller/server couple. I have no knowledge.
On controller/server side, what should I worry about ?
Sending too many manialinks too often could be an issue (like, on each endRound, I'm sending a manialink to each player, same on beginRound with an empty manialink to clear) ?

We could hit 80,100 players, even more but we'll maybe put a limit if we meet problems.


edit : To give an example, to add these up/down arrows in that manialink, I added a foreach (of 10 max items) with 3 basic if in it, in an already existing foreach (10 max items). Is this significant ? I could give you a view of the code for general advice, but well, I don't want to abuse of your help.
Image

Re: Script.Round : Fetch Score + Alter live modescript_settings

Posted: 04 Dec 2019, 15:08
by undef.de
Palteza wrote: 04 Dec 2019, 14:06 Yeah if I had the level in coding I would have done few things in ManiaScript (and if there was a proper and deep documentation, or I missed something ?).
No, only something of this exists and that's not really helpful.
Palteza wrote: 04 Dec 2019, 14:06 Because, for the rest of the plugin, i'm coding a bit "in the fog" concerning perfomance side. On php side, and controller/server couple. I have no knowledge.
On controller/server side, what should I worry about ?
Sending too many manialinks too often could be an issue (like, on each endRound, I'm sending a manialink to each player, same on beginRound with an empty manialink to clear) ?

We could hit 80,100 players, even more but we'll maybe put a limit if we meet problems.
If that ManiaLink are build for each player with each different informations on endRound, then you could hit a bottleneck (the dedicated server) real quick. If that Manialink looks for all players the same, then you should send them to all players in one call:

Code: Select all

$widget = '<manialink id="08154711"><quad posn="0 0 0" sizen="10 2" bgcolor="FFFF"></manialink>';
$logins = false;
$aseco->sendManialink($widget, $logins);
Details at https://www.uaseco.org/development/clas ... dManialink

Palteza wrote: 04 Dec 2019, 14:06 edit : To give an example, to add these up/down arrows in that manialink, I added a foreach (of 10 max items) with 3 basic if in it, in an already existing foreach (10 max items). Is this significant ? I could give you a view of the code for general advice, but well, I don't want to abuse of your help.
Image
That looks like you could send that Manialink to all players at once, that "removes" the bottleneck.