[Scripting] Adding new cups in script files

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [Scripting] Adding new cups in script files

      This article shows some trick about adding domestic cups in external script files. It includes examples for the ScriptStudio script editor, but the output code (original FIFAM script format) is included too.

      In the UCP Season patch there's no way to edit database in the regular way, which also means that there's no way to edit domestic competitions. On the other hand, it's possible to edit continental and international competitions, because they are stored in external script files in the "script" folder. These external scripts are a bit different from scripts in .sav files (Editor database files). But the most important thing that domestic competitions can be placed in these files too!

      As an example, we will create a new cup in Germany, where U-18 teams of Bundesliga and Bundesliga 2 teams will play in 6 rounds. Talking more specific, we need to create a cup (DB_CUP) wit type of League Cup (LE_CUP) in Germany (country ID 21). As said before, the format for scripts in external files is different, so we need to do something to "enable" that format. This done in this way: we write a competition as a part of WorldCup (so it will use format for external files), but we also replace the generated signature of created competition ("255, WORLD_CUP") in the output code with the desired one ("21, LE_CUP"). It's also important that we need to use cup indexes from 1 to 3, because the index 0 can't be used (the competition { XX, LE_CUP, 0 } is always deleted before the country database is read). In the example we use index 1 for the cup.

      C Source Code

      1. #name "Germany U-19 Cup"
      2. #replace "{ 255, WORLD_CUP" "{ 21, LE_CUP" // replace WorldCup ID with German Cup ID
      3. comp WorldCup { // we use "WorldCup" mode to enable cup format for continental/international scripts
      4. league_cup index 1 "DFB-Junioren-Vereinspokal" teams 36 /* generate 6 matchdays (every week (7 days)) */ matchdays [20-55^7] {
      5. format [1EP+8,1EP+28,1EP,1EP,1EP,1EP] // 8 teams playing pre-round, 32 teams in knockout stage (28+4)
      6. getTabLevelXToY(1, 1, 24) // get all teams on level 1 (Bundesliga)
      7. getTabLevelXToY(2, 1, 24) // get all teams on level 2 (Bundesliga 2)
      8. changeTeamTypes(YouthA) // change teams to youth A (u-18)
      9. }
      10. }
      Display All

      The output code is following:

      Brainfuck Source Code

      1. ; ----------------------------------------------------
      2. ; Compiled with ScriptStudio v0.4.3
      3. ; ----------------------------------------------------
      4. ; Germany U-19 Cup
      5. ; ----------------------------------------------------
      6. 1
      7. ; ----------------------------------------------------
      8. ; "DFB-Junioren-Vereinspokal" ( @@WorldCup_0 )
      9. ; ----------------------------------------------------
      10. %INDEX%WORLD_CUP0
      11. DB_CUP
      12. { 21, LE_CUP, 1 }
      13. DFB-Junioren-Vereinspokal
      14. 36,6,6
      15. %INDEX%MATCHDAYS
      16. 20,27,34,41,48,55
      17. 20,27,34,41,48,55
      18. %INDEXEND%MATCHDAYS
      19. %INDEX%ROUNDINFO
      20. 0,5,8,8,0,4,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      21. 1,6,32,28,4,20,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      22. 2,12,16,0,20,28,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      23. 3,13,8,0,28,32,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      24. 4,14,4,0,32,34,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      25. 5,15,2,0,34,35,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      26. %INDEXEND%ROUNDINFO
      27. 3
      28. 0
      29. 0
      30. 0
      31. 3
      32. GET_TAB_LEVEL_X_TO_Y
      33. 0
      34. 1
      35. 24
      36. GET_TAB_LEVEL_X_TO_Y
      37. 1
      38. 1
      39. 24
      40. CHANGE_TEAM_TYPES, 2 ; YouthA
      41. %INDEXEND%WORLD_CUP0
      42. ; ----------------------------------------------------
      Display All
      And finally, we need to add this code to some of external script files. I'm going to add it into ConfedCup.txt. By default, there's a space for 10 competitions in that file (the first line in the file), and only 6 of them are used. I want to add the code to the end of the file, so I need to use "%INDEX%CONFED_CUP7" header for my competition. Knowing this, I can slightly modify the code by adding 2 lines at the beginning:

      C Source Code

      1. #name "Germany U-19 Cup"
      2. #replace "{ 255, WORLD_CUP" "{ 21, LE_CUP" // replace WorldCup ID with German Cup ID
      3. #blockstartindex 7 // we will add the code to ConfedCup.txt, where 7 is the next free id for competition
      4. #blockname "CONFED_CUP" // we will add the code to ConfedCup.txt
      5. comp WorldCup { // we use "WorldCup" mode to enable cup format for continental/international scripts
      6. league_cup index 1 "DFB-Junioren-Vereinspokal" teams 36 /* generate 6 matchdays (every week (7 days)) */ matchdays [20-55^7] {
      7. format [1EP+8,1EP+28,1EP,1EP,1EP,1EP] // 8 teams playing pre-round, 32 teams in knockout stage (28+4)
      8. getTabLevelXToY(1, 1, 24) // get all teams on level 1 (Bundesliga)
      9. getTabLevelXToY(2, 1, 24) // get all teams on level 2 (Bundesliga 2)
      10. changeTeamTypes(YouthA) // change teams to youth A (u-18)
      11. }
      12. }
      Display All
      So now the output code will transform to:

      Brainfuck Source Code

      1. ; ----------------------------------------------------
      2. ; Compiled with ScriptStudio v0.4.3
      3. ; ----------------------------------------------------
      4. ; Germany U-19 Cup
      5. ; ----------------------------------------------------
      6. ; "DFB-Junioren-Vereinspokal" ( @@WorldCup_0 )
      7. ; ----------------------------------------------------
      8. %INDEX%CONFED_CUP7
      9. DB_CUP
      10. { 21, LE_CUP, 1 }
      11. DFB-Junioren-Vereinspokal
      12. 36,6,6
      13. %INDEX%MATCHDAYS
      14. 20,27,34,41,48,55
      15. 20,27,34,41,48,55
      16. %INDEXEND%MATCHDAYS
      17. %INDEX%ROUNDINFO
      18. 0,5,8,8,0,4,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      19. 1,6,32,28,4,20,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      20. 2,12,16,0,20,28,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      21. 3,13,8,0,28,32,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      22. 4,14,4,0,32,34,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      23. 5,15,2,0,34,35,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      24. %INDEXEND%ROUNDINFO
      25. 3
      26. 0
      27. 0
      28. 0
      29. 3
      30. GET_TAB_LEVEL_X_TO_Y
      31. 0
      32. 1
      33. 24
      34. GET_TAB_LEVEL_X_TO_Y
      35. 1
      36. 1
      37. 24
      38. CHANGE_TEAM_TYPES, 2 ; YouthA
      39. %INDEXEND%CONFED_CUP7
      40. ; ----------------------------------------------------
      Display All
      Now we can add this code at the end in ConfedCup.txt.

      C Source Code

      1. %INDEXEND%CONFED_CUP6
      2. ; ------------------------------------------------------------------ // <------- oriignal script ending
      3. ; ---------------------------------------------------- // <------- our code
      4. ; Compiled with ScriptStudio v0.4.3
      5. ; ----------------------------------------------------
      6. ; Germany U-19 Cup
      7. ; ----------------------------------------------------
      8. ; "DFB-Junioren-Vereinspokal" ( @@WorldCup_0 )
      9. ; ----------------------------------------------------
      10. %INDEX%CONFED_CUP7
      11. DB_CUP
      12. // ...
      13. // ... the rest of the code ...
      14. // ...
      15. %INDEXEND%CONFED_CUP7
      16. ; ----------------------------------------------------
      Display All
      The in-game result:

      The post was edited 4 times, last by Dmitry ().

    • Thanks ,that is what i need. Great Jobe Dude :)


      I added the U19 Cup for Spain and France and it is working
      So you can add 3 extra Cups cause the first Number (10) must be one more than cups are in the script file
      If i change the Number to 11 and put another cup (Like the fa youth cup ) into the script file it will not work.
      Is this file Hard coded?
      Greetings Mathias


      Display Spoiler

      10
      ; ----------------------------------------------------------------------
      ; Pool
      ; ----------------------------------------------------------------------
      %INDEX%CONFED_CUP1
      DB_POOL
      { 255, CONFED_CUP, 0 }
      ; 16 Teams aus Europa
      1 ; ein Pool
      8 ; a 8 Teams
      POOL_SORT_CONTINENT ; Sortierung
      ; wieviele und in welchen Wettbewerben darf der Club nicht stehen,
      ; um in diesen Pool aufgenommen zu werden?
      0
      ; Bonuses
      0
      0
      0
      0
      ; Subst
      0
      0
      ; welche Vorgänger, Nachfolger
      0
      { 255, CONFED_CUP, 1 }, { 255, CONFED_CUP, 2 }
      ; wie setzt sich der Pool zusammen
      8
      GET_HOST
      GET_CHAMP_OR_RUNNER_UP, { 255, WORLD_CUP, 13 }
      GET_CHAMP_OR_RUNNER_UP, { 255, EURO_CUP, 12 }
      GET_CHAMP_OR_RUNNER_UP, { 255, COPA_AMERICA, 8 }
      GET_RANDOM_NATIONAL_TEAM, 2, 1
      GET_RANDOM_NATIONAL_TEAM, 3, 1
      GET_RANDOM_NATIONAL_TEAM, 4, 1
      GET_RANDOM_NATIONAL_TEAM, 5, 1
      %INDEXEND%CONFED_CUP1
      ; ----------------------------------------------------------------------
      ; 2 Gruppen a 4 Mannschaften
      ; ----------------------------------------------------------------------
      %INDEX%CONFED_CUP2
      DB_LEAGUE
      { 255, CONFED_CUP, 1 }
      _ID_GROUP_A
      4
      0
      0
      0
      1
      ROUND_QUARTERFINAL
      100
      100
      ;
      %INDEX%TEAMS
      1,2,3,4
      %INDEXEND%TEAMS
      ;
      %INDEX%MATCHDAYS
      343,346,349
      %INDEXEND%MATCHDAYS
      ;
      %INDEX%FIXTURE
      1,2,3,4
      2,3,4,1
      1,3,2,4
      %INDEXEND%FIXTURE
      ; Bonuses
      0
      0
      0
      0
      ;Transfer
      7
      1459569736
      756
      3
      0
      ;
      { 255, CONFED_CUP, 0 }
      { 255, CONFED_CUP, 3 }
      4
      GET_POOL, { 255, CONFED_CUP, 0 }
      0
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      2
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      4
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      6
      1
      %INDEXEND%CONFED_CUP2
      ; ----------------------------------------
      ; Gruppe 2
      ; ----------------------------------------
      %INDEX%CONFED_CUP3
      DB_LEAGUE
      { 255, CONFED_CUP, 2 }
      _ID_GROUP_B
      4
      0
      0
      0
      1
      ROUND_QUARTERFINAL
      100
      100
      ;
      %INDEX%TEAMS
      1,2,3,4
      %INDEXEND%TEAMS
      ;
      %INDEX%MATCHDAYS
      344,347,350
      %INDEXEND%MATCHDAYS
      ;
      %INDEX%FIXTURE
      1,2,3,4
      2,3,4,1
      1,3,2,4
      %INDEXEND%FIXTURE
      ; Bonuses
      0
      0
      0
      0
      ;Transfer
      7
      1459569736
      756
      3
      0
      ;
      { 255, CONFED_CUP, 0 }
      { 255, CONFED_CUP, 3 }
      4
      GET_POOL, { 255, CONFED_CUP, 0 }
      1
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      3
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      5
      1
      GET_POOL, { 255, CONFED_CUP, 0 }
      7
      1
      %INDEXEND%CONFED_CUP3
      ; -------------------------------------------------------------------
      ; Halbfinale
      ; -------------------------------------------------------------------
      %INDEX%CONFED_CUP4
      DB_ROUND
      { 255, CONFED_CUP, 3 }
      _ID_SEMIFINAL
      4
      ROUND_SEMIFINAL
      ; Spieltage
      353
      353
      BEG_1ST_LEG, BEG_WITH_EXTRA_TIME, BEG_WITH_PENALTY, BEG_END
      0
      0
      0
      ; Bonuses
      0
      0
      0
      0
      ; Subst
      3
      0
      ; Vorgänger
      { 255, CONFED_CUP, 1 }, { 255, CONFED_CUP, 2 }
      ; Nachfolger
      { 255, CONFED_CUP, 4 }, { 255, CONFED_CUP, 5 }
      4
      GET_TAB_X_TO_Y, { 255, CONFED_CUP, 1 }
      1
      1
      GET_TAB_X_TO_Y, { 255, CONFED_CUP, 1 }
      2
      1
      GET_TAB_X_TO_Y, { 255, CONFED_CUP, 2 }
      2
      1
      GET_TAB_X_TO_Y, { 255, CONFED_CUP, 2 }
      1
      1
      %INDEXEND%CONFED_CUP4
      ; -------------------------------------------------------------------
      ; Match 3rd place
      ; -------------------------------------------------------------------
      %INDEX%CONFED_CUP5
      DB_ROUND
      { 255, CONFED_CUP, 4 }
      _ID_3RD_PLACE
      2
      ROUND_FINAL
      ; Spieltage
      355
      355
      BEG_1ST_LEG, BEG_WITH_EXTRA_TIME, BEG_WITH_PENALTY, BEG_END
      0
      0
      0
      ; Bonuses
      0
      0
      0
      0
      ; Subst
      3
      0
      ; Vorgänger
      { 255, CONFED_CUP, 3 }
      ; Nachfolger
      0
      1
      GET_LOSER, { 255, CONFED_CUP, 3 }
      %INDEXEND%CONFED_CUP5
      ; -------------------------------------------------------------------
      ; Finale
      ; -------------------------------------------------------------------
      %INDEX%CONFED_CUP6
      DB_ROUND
      { 255, CONFED_CUP, 5 }
      _ID_FINAL
      2
      ROUND_FINAL
      ; Spieltage
      357
      357
      BEG_1ST_LEG, BEG_WITH_EXTRA_TIME, BEG_WITH_PENALTY, BEG_END
      0
      0
      0
      ; Bonuses
      0
      0
      0
      0
      ; Subst
      3
      0
      ; Vorgänger
      { 255, CONFED_CUP, 3 }
      ; Nachfolger
      0
      1
      GET_WINNER, { 255, CONFED_CUP, 3 }
      %INDEXEND%CONFED_CUP6
      ; ------------------------------------------------------------------
      ; ----------------------------------------------------
      ; Compiled with ScriptStudio v0.4.3
      ; ----------------------------------------------------
      ; Germany U-19 Cup
      ; ----------------------------------------------------
      ; "DFB-Junioren-Vereinspokal" ( @@WorldCup_0 )
      ; ----------------------------------------------------
      %INDEX%CONFED_CUP7
      DB_CUP
      { 21, LE_CUP, 1 }
      DFB-Junioren-Vereinspokal U19
      36,6,6
      %INDEX%MATCHDAYS
      20,27,34,41,48,55
      20,27,34,41,48,55
      %INDEXEND%MATCHDAYS
      %INDEX%ROUNDINFO
      0,5,8,8,0,4,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      1,6,32,28,4,20,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      2,12,16,0,20,28,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      3,13,8,0,28,32,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      4,14,4,0,32,34,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      5,15,2,0,34,35,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      %INDEXEND%ROUNDINFO
      3
      0
      0
      0
      3
      GET_TAB_LEVEL_X_TO_Y
      0
      1
      24
      GET_TAB_LEVEL_X_TO_Y
      1
      1
      24
      CHANGE_TEAM_TYPES, 2 ; YouthA
      %INDEXEND%CONFED_CUP7
      ; ----------------------------------------------------
      ; Compiled with ScriptStudio v0.4.3
      ; ----------------------------------------------------
      ; France U-19 Cup
      ; ----------------------------------------------------
      ; Coupe Gambardella U19
      ; ----------------------------------------------------
      %INDEX%CONFED_CUP8
      DB_CUP
      { 18, LE_CUP, 1 }
      Coupe Gambardella U19
      36,6,6
      %INDEX%MATCHDAYS
      20,27,34,41,48,55
      20,27,34,41,48,55
      %INDEXEND%MATCHDAYS
      %INDEX%ROUNDINFO
      0,5,8,8,0,4,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      1,6,32,28,4,20,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      2,12,16,0,20,28,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      3,13,8,0,28,32,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      4,14,4,0,32,34,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      5,15,2,0,34,35,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      %INDEXEND%ROUNDINFO
      3
      0
      0
      0
      3
      GET_TAB_LEVEL_X_TO_Y
      0
      1
      24
      GET_TAB_LEVEL_X_TO_Y
      1
      1
      24
      CHANGE_TEAM_TYPES, 2 ; YouthA
      %INDEXEND%CONFED_CUP8
      ; ----------------------------------------------------
      ; ----------------------------------------------------
      ; Compiled with ScriptStudio v0.4.3
      ; ----------------------------------------------------
      ; Spain U-19 Cup
      ; ----------------------------------------------------
      ; Copa del Rey Juvenil U19
      ; ----------------------------------------------------
      %INDEX%CONFED_CUP9
      DB_CUP
      { 45, LE_CUP, 1 }
      Copa del Rey Juvenil U19
      36,6,6
      %INDEX%MATCHDAYS
      20,27,34,41,48,55
      20,27,34,41,48,55
      %INDEXEND%MATCHDAYS
      %INDEX%ROUNDINFO
      0,5,8,8,0,4,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      1,6,32,28,4,20,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      2,12,16,0,20,28,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      3,13,8,0,28,32,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      4,14,4,0,32,34,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      5,15,2,0,34,35,BEG_1ST_LEG| BEG_WITH_EXTRA_TIME| BEG_WITH_PENALTY,0,0,0,0
      %INDEXEND%ROUNDINFO
      3
      0
      0
      0
      3
      GET_TAB_LEVEL_X_TO_Y
      0
      1
      24
      GET_TAB_LEVEL_X_TO_Y
      1
      1
      24
      CHANGE_TEAM_TYPES, 2 ; YouthA
      %INDEXEND%CONFED_CUP9
      ; ----------------------------------------------------
      Neander Diggi Thala :thumbsup: PsyTrance :P DnB 8o HardCore :D
      https://soundcloud.com/mathias-thalacker

      The post was edited 1 time, last by bs3n: Spoiler eingefügt. Bitte in Zukunft selbst darauf achten, damit das Forum übersichtlich bleibt. ().

    • Dmitry wrote:

      tisi wrote:

      If i change the Number to 11 and put another cup (Like the fa youth cup ) into the script file it will not work.
      It should work. Can you show the whole script with that change?In any case, try also setting this number (the first line) to 100.

      tisi wrote:

      Is it possible to use the cupAlloc.txt file instead of ConfedCup.txt ?
      No.
      So we can add nearly endless competitions/cups per any country? 8o
      Wenn dich das erste Mal jemand Ochse nennt, hau ihm auf die Nase. Wenn dich das zweite Mal jemand Ochse nennt, nenn ihn Vollidiot. Und wenn dich das dritte Mal jemand Ochse nennt, dann wird’s wohl Zeit, sich nach nem Kuhstall umzusehen.
    • planlos wrote:

      So we can add nearly endless competitions/cups per any country?
      Well, you can do it even without using this trick - just by adding cups in country's database (.sav files). But yes, we can add as more as we need.

      The convenience of this method is that you can add cups without touching the country's database. But at the same time, you must do it carefully to avoid possible conflicts (for example, a situation where you add a cup with ID which is already present in country's database).