Jump to content
Sign in to follow this  
AXEL777

Logging question (how this work?)

Recommended Posts

1. Create a clear server game
2. Add a my some code from this line in init.c server mission

#include "$CurrentDir:mpmissions\my_mission_server.chernarusplus\mycode_functions.c"

with code file:

class My_Functions_MissionServer
{        
    void My_Functions_MissionServer()
    {
        Write_Log("Build My_Functions_MissionServer");
    //    Print("Build My_Functions_MissionServer TECT");
    }
    void ~My_Functions_MissionServer()
    {
        Write_Log("DeBuild My_Functions_MissionServer");
    }
    void Write_Log(string message)
    {
        Print(message);
    }

}
static ref My_Functions_MissionServer g_My_Functionss_MissionServer = new ref My_Functions_MissionServer();
//static ref My_Functions_MissionServer g_My_Functionss_MissionServer;
static ref My_Functions_MissionServer GetMy_Functions()
{
    if ( !g_My_Functionss_MissionServer )
    {
         g_My_Functionss_MissionServer = new ref My_Functions_MissionServer();
    }
    
    return g_My_Functionss_MissionServer;
}

3. Add in default init.c in block

class CustomMission: MissionServer

a new block

void OnInit ()
    {
        super.OnInit();
        GetMy_Functions().CreateCustomDirsServer(); //Creating Directories for Server Functions
    }

4. Start server game and have in script.log:

SCRIPT       : string message = 'Build ZoS_Functions_MissionServer'

5. Change this

Write_Log("Build My_Functions_MissionServer");

on this code

Print("Build My_Functions_MissionServer TECT");

6. Start server game
7. Is a have in scripts.log this:

SCRIPT       : Build ZoS_Functions_MissionServer

Why undo 5 stage is have log messages with: string message = '  and after 5 stage i am have a normal logging? How this work?

Share this post


Link to post
Share on other sites

The following is the definition of the Print method taken from "1_Core/proto/EnDebug.c":

//!Prints content of variable to console/log
proto void Print(void var);

And this is the definition of the ToString method taken from "1_Core/proto/EnString.c":

//! Return string representation of variable
	static proto string ToString(void var, bool type = false, bool name = false, bool quotes = true);

Based on your result and the little bit of information I can gather in these classes, I would assume that when you pass a reference, it calls the ToString method on a string which results in printing the definition of the string rather than the value as you can see above. What weird is however, is that they have the same exact method as you (PrintString down below) and it probably works because they use that as well. Might have to do with the implementation of the Print method somehow or for some reason. But the following examples will fix your issue.

In "1_Core/proto/EnScript.c" you have the following code:

//!Helper for passing string expression to functions with void parameter. Example: Print(String("Hello " + var));
string String(string s)
{
	return s;
}

So if you would change your code into the following, it should work:

    void Write_Log(string message)
    {
        Print(String(message));
    }

EnScript.c also has this code:

//!Helper for printing out string expression. Example: PrintString("Hello " + var);
void PrintString(string s)
{
	Print(s);
}

So this might work as well:

    void Write_Log(string message)
    {
        PrintString(message);
    }

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Reaaly, worked

void Write_Log(string message) 
	{
		//Print(message);
		Print(String(message));
	}

this worked

and this

void Write_Log(string message) 
	{
		//Print(message);
		PrintFormat("%1", message);
	}

worked normal to

Thanks for reply

Edited by AXEL777

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
Sign in to follow this  

×