1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Tweaks Crash server with Loadrules

Discussion in 'Modding [KAG]' started by marcel5, May 9, 2016.

  1. marcel5

    marcel5 Horde Gibber
    1. Zen Laboratories

    Messages:
    20
    Hello to all. I am doing a modification in which I wish the server will run CTF, TDM, CTF, TDM ... but does not reach the third round and already broke the server. someone with knowledge could take a look at the code to min ?

    SwitchGame.as
    Code:
    void onInit(CRules@ this) {}
    
    void onTick(CRules@ this)
    {
        if (this.isGameOver() && this.gamemode_name == "CTF") { GameTDM();}
        else if (this.isGameOver() && this.gamemode_name == "Team Deathmatch") { GameCTF();}
    }
    
    void GameCTF(){
    
        RegisterFileExtensionScript("Scripts/MapLoaders/LoadPNGMap.as", "png");
        LoadRules("Rules/CTF/gamemode.cfg");
        LoadMapCycle("Rules/CTF/mapcycle.cfg");
        sv_mapcycle_shuffle = false;
        LoadNextMap();
    }
    
    void GameTDM(){
    
        RegisterFileExtensionScript("Scripts/MapLoaders/LoadTDMPNG.as", "png");
        LoadRules("Rules/TDM/gamemode.cfg");
        LoadMapCycle("Rules/TDM/mapcycle.cfg");
        sv_mapcycle_shuffle = false;
        LoadNextMap();
       
    }
    Create a mode with this file and add in the scripts= the gamemode.cfg of TDM and CTF.

    In the debug when breaking the server appears

    Code:
    Program received signal SIGSEGV, Segmentation fault.
    asScript::canRun (this=0x3059) at ../Scripting/asScript.cpp:342
    342     ../Scripting/asScript.cpp: Arquivo ou diretório não encontrado.
    --- Double Post Merged, May 10, 2016, Original Post Date: May 9, 2016 ---
    UP !
    Updated file, added a methodology that attempts to clear the values, this causes that lasts about 6 rounds and after the server breaks!

    Code:
    void onInit(CRules@ this) {}
    
    void onTick(CRules@ this)
    {
        if (this.isGameOver() && this.gamemode_name == "CTF") { GameTDM();}
        else if (this.isGameOver() && this.gamemode_name == "Team Deathmatch") { GameCTF();}
    }
    
    void GameCTF(){
    
        Clear();
    
        RegisterFileExtensionScript("Scripts/MapLoaders/LoadPNGMap.as", "png");
        LoadRules("Rules/CTF/gamemode.cfg");
        LoadMapCycle("Rules/CTF/mapcycle.cfg");
        sv_mapcycle_shuffle = false;
        LoadNextMap();
    }
    
    void GameTDM(){
    
        Clear();
       
        RegisterFileExtensionScript("Scripts/MapLoaders/LoadTDMPNG.as", "png");
        LoadRules("Rules/TDM/gamemode.cfg");
        LoadMapCycle("Rules/TDM/mapcycle.cfg");
        sv_mapcycle_shuffle = false;
        LoadNextMap();
       
    }
    
    void Clear(){
            RegisterFileExtensionScript("Scripts/MapLoaders/CustomBlocks.as", "png");
        LoadRules("../Mods/SwitchGame/cleargame.cfg");
        LoadMapCycle("../Mods/SwitchGame/clearmapcycle.cfg");
    
    }
    clearmapcycle.cfg
    Code:
    mapcycle = "";
    cleargame.cfg
    Code:
    # config file for game rules
    # rules name: CLEAR
    # rules description:
    
    teams                                             = team1.cfg;
    
    gamemode_name                                     = CLEAR
    gamemode_info                                     = CLEAR
    
    scripts                                           = SwitchGame.as;
    Someone know how to clear the memory of the rules loaded in gamemode.cfg ?