Jump to content
Liven_28

xml/txt/json variables to .cpp

Recommended Posts

Can I acces in a config.cpp file to variable stored in an xml / txt / json file.

I'm making a mode to tweak z health and I would like to make it easy for server admin to tweak the values without having to unpack the .pbo files.

Share this post


Link to post
Share on other sites

Enfusion has a JSON parser built-in. So yes, it's possible.

Edited by IMT

Share this post


Link to post
Share on other sites

Do you know where can I find doc or examples on this subject.
The only things I found concerne .c files not .cpp

Share this post


Link to post
Share on other sites

You have to look into the following file:

DayZServer\dta\scripts\3_Game\tools\JsonfileLoader.c

To load a file to an object:

// Read from file
JsonFileLoader<ref YOUR_CLASS_NAME>.JsonLoadFile( missionFolder + filename + ".json", this );
// Save to file
JsonFileLoader<ref YOUR_CLASS_NAME>.JsonSaveFile( missionFolder + filename + ".json", this );

 

  • Beans 1

Share this post


Link to post
Share on other sites

Thank you for the answer I have already found the solution too
But I'm stuck with another problem, I see you give good answer maybe you can help me

modded class MissionGameplay
{
    PlayerBase player;           

    override void OnKeyPress( int key )
    {
        super.OnKeyPress( key );

        player = g_Game.GetPlayer();       
        PlayerIdentity identity = player.GetIdentity();

        string playerID = identity.GetPlainId();


        if (identity.GetPlainId() == "76561198015051115")
        {
            Print("TestLiven if ID OK ");
        }
        else
        {
            Print("TestLiven if ID NOT ok ");
        }
    }
};

I can get the the "player", the "player identity" but the "PlayerID" is always empty I don't know why

Share this post


Link to post
Share on other sites

You will Not get the PlainId, because this method is called clientside. Only on the Serverside this would work. You have to request your PlainId via RPC when you connect to the Server and store it somewhere. I don't know if this is actually needed, or if this is done somewhere else anyway, but this is the way I got it working. The other solution would be to put this code on the Serverside if it is not necessary on clientside.

LG LBmaster

  • Beans 1

Share this post


Link to post
Share on other sites

Ok, I see, thank you very much, I have new things to try now.

Last question, you seem have some answers

Do you use the debug mode of the workbench scripting tool? I tryed to follow this : https://github.com/maxkunes/Enscript-Workbench-Project-Setup but it didn't work (I reported the issue but sadly no solution find). Or maybe you use another tool? Not being able to use breapoints/step by step execution to see varaibles value make me loose so much time...

Share this post


Link to post
Share on other sites

I don't use the debug mode of the workbench and I did not even know that this exists ^^. I am using notepad++ and try to make as few errors as possible. Not really fun to do things like this, but as far as I heard there is no real alternative and the Workbench is a bit buggy for me.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×