Kategorie: Network
/ League
Ab Engineversion: 5.0 OC
SetLeagueProgressData
Beschreibung
Sets the league progress data. This function can be used to store a per-scenario per-user data string in the league. The function is available for both melee and custom settlement leagues. The data is stored between league games and can later be retrieved using GetLeagueProgressData().
Syntax
bool SetLeagueProgressData(string new_data, int player_id);
Parameter
- new_data:
- New data string for this player in this scenario.
- player_id:
- ID of player whose progress data shall be set. Use GetPlayerID() to get the ID of a joined player.
Anmerkung
Each scenario may store up to 2048 characters. The string may only contain alphanumeric characters plus space (" ") and underscore ("_"). Invalid characters will be removed by the league and not returned when GetLeagueProgressData is called after the next scenario start.
Beispiel
func SetLeagueProgressScore(int plr, int new_progress) { // Safety: Valid players only var plrid = GetPlayerID(plr); if (!plrid) return; // Progress must be between 0 and 25 new_progress = BoundBy(new_progress, 0, 25); // Get old progress from previous round var progress_string = GetLeagueProgressData(plrid); if (progress_string && GetLength(progress_string)) { var old_progress = GetChar(progress_string)-GetChar("A"); // If old progress was better than new progress, keep old progress new_progress = Max(old_progress, new_progress); } // Set new progress SetLeagueProgressData(Format("%c", GetChar("A") + new_progress)); SetLeaguePerformance(new_progress); return true; }
Helper script for a scenario that is using custom scoring in the league. LeagueProgressData is used to remember the last progress and ensure that progress never decreases.
Siehe auch: GetLeagueProgressData, SetLeaguePerformance