[RELEASE] Chat Based Admin Tool-set

ChawDinky

New Member
Attention
I am not the creator and take no credit for this mod


Dayz Chat Based Admin Tool-set
by DaOne


Download Here
Installation:

-Download and extract the files AdminTool.c into your mission folder dayzOffline.chernarusplus

- Locate the following class in the file init.c

C:
class CustomMission: MissionServer{ }

In the vanilla "init.c" it should be located around line 30 OR 35

68747470733a2f2f692e6779617a6f2e636f6d2f34656139623565353866363163383563303135633630353031613230376633622e706e67


- Just under the open curly bracket add the following line:

C:
#include "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\AdminTool.c"

It Should look like this:

68747470733a2f2f692e6779617a6f2e636f6d2f38336363623465363765376537636361626263393634653033663936653730342e706e67


- Under that new line you just added, copy and paste the following:

C:
override void OnInit()
{
        AdminTool();
        string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\";
        FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt", FileMode.READ);
        if (AdminUIDSFile != 0)
    {
                string line_content = "";
                while ( FGets(AdminUIDSFile,line_content) > 0 )
                {
                        m_AdminList.Insert(line_content,"null"); //UID , NAME
                        Print("Adding Admin: "+ line_content + " To the Admin List!");
                }
                CloseFile(AdminUIDSFile);
         }
}

NOTE: If you get any errors on startup relating to " override void OnInit() already exists " Check if the function is already there from other mods you have installed. If so, simply copy the code within the

C:
override  void OnInit()
{
}

And place it into the already existing override void OnInit()

Make sure that the path matches where your Admin.txt file is

C:
string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\";

- Save and exit out of init.c

- Create a new text file in your mission folder (default: dayzOffline.chernarusplus). Name it: Admins.txt Open it and add the steam 64 ID's of your admins. You can obtain the 64 ID using: Steam IO

Should look like this:

68747470733a2f2f692e6779617a6f2e636f6d2f38386631643761636337643133353237396531353430306333653436626232662e706e67


Save and exit. Run the server and in game login as admin using the #login Password command.

Here is a list of the commands you can use: Commands List (UPDATED!)

(The godmode feature is currently not implemented, will be added in future updates)
 
Last edited:
hi,

I have this problem:
Can’t compile mission init script!

$CurrentDir:mpmissions\dayzOffline.chernarusplus\init.c(33): Opened scope at the end of file, missing ‘}’ ?

But not missing! So i dont know what is the problem! Can u help me pls? THX!
 
Got this to work. I'll post the files soon.

AdminTool.c

Add this to the same directory where init.c is located, unless you want to change the path when importing AdminTool.c to init.c.

Create a file called Admin.txt in the same directory as AdminTool.c and init.c. Add your IDs the same way as instructed in the original post.

Now, some modifications in init.c:

Add this at the very top of your init.c file.

C++:
#include "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\AdminTool.c"

Then add this straight after the opening bracket in CustomMission

C++:
protected ref AdminTool m_adminTool;

To your OnInit method, add this

C++:
m_adminTool = new AdminTool(this);
m_adminTool.Init();

Also, override the OnEvent method in CustomMission. Add this somewhere inside the CustomMission class

C++:
override void OnEvent(EventType eventTypeId, Param params)
{
    super.OnEvent(eventTypeId, params);

    PlayerIdentity identity;
    switch (eventTypeId)
    {
        case ChatMessageEventTypeID:
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
            if (chat_params.param1 == 0 && chat_params.param2 != "")
            {
                Param4<int, string, string, string> request_info = new Param4<int, string, string, string>(chat_params.param1, chat_params.param2, chat_params.param3, chat_params.param4);
                m_adminTool.RequestHandler(request_info);
                break;
            }
    }
}
 
Last edited:
download is broken, can someone re-up?

/edit
NVM - got it from Merg

/edit2

what is " Init method " or where to find it? Cant see it inside my init

/edit3

How to add custom command "/kick all"?
 
Last edited:
/edit2

what is " Init method " or where to find it? Cant see it inside my init

My bad, it's the OnInit method in your MissionServer implementation. So for example:

C++:
class CustomMission : MissionServer
{
    override void OnInit()
    {

    }
    
}
 
Where do i insert this:
m_adminTool = new AdminTool(this);
m_adminTool.Init();


Thats my class custom mission until void OnInit()...

Code:
class CustomMission: MissionServer
#include "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\scripts\\plugins\\AdminTool.c"
{
    protected ref AdminTool m_adminTool;

    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            int rndHlt = Math.RandomInt(55,100);
            itemEnt.SetHealth("","",rndHlt);
        }
    }
    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
       
        GetGame().SelectPlayer(identity, m_player);
       
        return m_player;
    }
    override void OnInit()
    {
        AdminTool();
        string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\";
        FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt", FileMode.READ);
        if (AdminUIDSFile != 0)
    {
                string line_content = "";
                while ( FGets(AdminUIDSFile,line_content) > 0 )
                {
                        m_AdminList.Insert(line_content,"null"); //UID , NAME
                        Print("Füge ID: "+ line_content + " zur Adminliste hinzu!");
                }
                CloseFile(AdminUIDSFile);
         }
    }


Like this doesnt work...

Code:
    override void OnInit()
    {
        m_adminTool = new AdminTool(this);
        m_adminTool.Init();
        AdminTool();
        string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\";
        FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt", FileMode.READ);
        if (AdminUIDSFile != 0)
    {
                string line_content = "";
                while ( FGets(AdminUIDSFile,line_content) > 0 )
                {
                        m_AdminList.Insert(line_content,"null"); //UID , NAME
                        Print("Füge ID: "+ line_content + " zur Adminliste hinzu!");
                }
                CloseFile(AdminUIDSFile);
         }
    }
 
Where do i insert this:



Thats my class custom mission until void OnInit()...

Code:
class CustomMission: MissionServer
#include "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\scripts\\plugins\\AdminTool.c"
{
    protected ref AdminTool m_adminTool;

    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            int rndHlt = Math.RandomInt(55,100);
            itemEnt.SetHealth("","",rndHlt);
        }
    }
    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
      
        GetGame().SelectPlayer(identity, m_player);
      
        return m_player;
    }
    override void OnInit()
    {
        AdminTool();
        string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\";
        FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt", FileMode.READ);
        if (AdminUIDSFile != 0)
    {
                string line_content = "";
                while ( FGets(AdminUIDSFile,line_content) > 0 )
                {
                        m_AdminList.Insert(line_content,"null"); //UID , NAME
                        Print("Füge ID: "+ line_content + " zur Adminliste hinzu!");
                }
                CloseFile(AdminUIDSFile);
         }
    }


Like this doesnt work...

Code:
    override void OnInit()
    {
        m_adminTool = new AdminTool(this);
        m_adminTool.Init();
        AdminTool();
        string m_AdminListPath = "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\";
        FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt", FileMode.READ);
        if (AdminUIDSFile != 0)
    {
                string line_content = "";
                while ( FGets(AdminUIDSFile,line_content) > 0 )
                {
                        m_AdminList.Insert(line_content,"null"); //UID , NAME
                        Print("Füge ID: "+ line_content + " zur Adminliste hinzu!");
                }
                CloseFile(AdminUIDSFile);
         }
    }

Try removing everything else from OnInit except


Code:
m_adminTool = new AdminTool(this);
m_adminTool.Init();

The init method inside AdminTool already loads the admins from the Admins.txt file. Also, check the path variable (m_AdminListPath) inside AdminTool.c and make sure that it matches the path where you have your Admins.txt file.
 
Im getting this error:
dLlHfab.png


My init.c:

C++:
//TREIBJAGD MISSION FILE
void main()
{
    //INIT WEATHER BEFORE ECONOMY INIT------------------------
    Weather weather = g_Game.GetWeather();

    weather.MissionWeather(false);    // false = use weather controller from Weather.c

    weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
    weather.GetRain().Set( 0, 0, 1);
    weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
    
    weather.GetRain().SetLimits( 0, 0.1 );

    //INIT ECONOMY--------------------------------------
    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    //DATE RESET AFTER ECONOMY INIT-------------------------
    int year;
    int month;
    int day;
    int hour;
    int minute;

    GetGame().GetWorld().GetDate(year, month, day, hour, minute);

    if (((month <= 9) && (day < 20)) || ((month >= 10) && (day > 20)))
    {
        month = 9;
        day = 20;
        
        GetGame().GetWorld().SetDate(year, month, day, hour, minute);
    }
    
    //-----------------------X-mas
    array<vector> treePositions = { "6560.29 0 2462.12",
                                    "1652.66 0 14230.71",
                                    "3801.06 0 8847.76",
                                    "9442.32 0 8829.03",
                                    "7903.16 0 12576.52",
                                    "11617.75 0 14663.98",
                                    "12830.08 0 10115.18",
                                    "11221.94 0 12225.89",
                                    "3471.93 0 12988.33",
                                    "13933.42 0 13228.44",
                                    "12022.64 0 9082.89",
                                    "10468.54 0 2373.16",
                                    "2725.48 0 5288.75",
    };
    

    Object treeEntity;
    for ( int i=0; i < treePositions.Count(); i++ )
    {
        vector treePos = treePositions[i];
        float posY = GetGame().SurfaceY(treePos[0], treePos[2]);
        treeEntity = GetGame().CreateObject("ChristmasTree", Vector( treePos[0], posY, treePos[2]), false);

    }
}

class CustomMission: MissionServer
#include "$CurrentDir:\\mpmissions\\dayz.treibjagd.chernarusplus\\scripts\\plugins\\AdminTool.c"
{
    protected ref AdminTool m_adminTool;
    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            int rndHlt = Math.RandomInt(55,100);
            itemEnt.SetHealth("","",rndHlt);
        }
    }
    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
      
        GetGame().SelectPlayer(identity, m_player);
      
        return m_player;
    }
    override void OnInit()
    {
        m_adminTool = new AdminTool(this);
        m_adminTool.Init();
    }
    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
        
        GetGame().SelectPlayer(identity, m_player);
        
        return m_player;
    }
    override void OnEvent(EventType eventTypeId, Param params)
    {
    super.OnEvent(eventTypeId, params);
    PlayerIdentity identity;
    switch (eventTypeId)
    {
        case ChatMessageEventTypeID:
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
            if (chat_params.param1 == 0 && chat_params.param2 != "")
            {
                Param4<int, string, string, string> request_info = new Param4<int, string, string, string>(chat_params.param1, chat_params.param2, chat_params.param3, chat_params.param4);
                m_adminTool.RequestHandler(request_info);
                break;
            }
        }
    }
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
/*
        player.RemoveAllItems();

        EntityAI item = player.GetInventory().CreateInInventory(topsMissionArray.GetRandomElement());
        EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
        EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
*/
        EntityAI itemTop;
        EntityAI itemEnt;
        ItemBase itemBs;
        float rand;
        
        itemTop = player.FindAttachmentBySlotName("Body");
        
        if ( itemTop )
        {
            itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
            if ( Class.CastTo(itemBs, itemEnt ) )
                itemBs.SetQuantity(4);

            SetRandomHealth(itemEnt);
            
            itemEnt = itemTop.GetInventory().CreateInInventory("RoadFlare");
            SetRandomHealth(itemEnt);
        
            itemEnt = itemTop.GetInventory().CreateInInventory("StoneKnife");
            SetRandomHealth(itemEnt);
        }

        rand = Math.RandomFloatInclusive(0.0, 1.0);
        if ( rand < 0.25 )
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Cola");
        else if ( rand > 0.75 )
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Spite");
        else
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
        
        SetRandomHealth(itemEnt);

        rand = Math.RandomFloatInclusive(0.0, 1.0);
        if ( rand < 0.35 )
            itemEnt = player.GetInventory().CreateInInventory("Apple");
        else if ( rand > 0.65 )
            itemEnt = player.GetInventory().CreateInInventory("Pear");
        else
            itemEnt = player.GetInventory().CreateInInventory("Plum");
        
        SetRandomHealth(itemEnt);
    }
};
 
Mission CreateCustomMission(string path)
{
    return new CustomMission();
}
 
Back
Top