Jump to content
Fonseca Games

Console Admin Tool

Recommended Posts

I have created a console admin tool, don't have any mods on client side. But every time I type a command, everyone near knows can see on the chat the commands. There is any way to hide those commands, or show just for who type it?

Share this post


Link to post
Share on other sites
15 hours ago, Fonseca Games said:

I have created a console admin tool, don't have any mods on client side. But every time I type a command, everyone near knows can see on the chat the commands. There is any way to hide those commands, or show just for who type it?

Man your awesome unique and etc magic console admin tool is existing since 0.68 DayZ SA and was quickly ported to 1.00 when DZ became enfusion. So don't give yourself the medals that you didn't own.

Edit the chat event check if text is command - do nothing (don't submit to the chat event) if not - submit as chat event. Nothing hard.

Share this post


Link to post
Share on other sites

Don't understand this unnecessary sarcasm and this kind of comments, I'm just trying to get help to finish a tool for my server, if exists some tool that make what I need, share to me please. And never took any 'medals'. But OK. 

I've tried modded the chat and/or chat input, but only on server side made no effect. 

Share this post


Link to post
Share on other sites
On 7/26/2024 at 11:20 AM, Fonseca Games said:

Don't understand this unnecessary sarcasm and this kind of comments, I'm just trying to get help to finish a tool for my server, if exists some tool that make what I need, share to me please. And never took any 'medals'. But OK. 

I've tried modded the chat and/or chat input, but only on server side made no effect. 

It's not sarcasm, it's obvious truth uf you can't accept it, sorry I can help with that.

You know returning to your question you're pleasing me to read your thoughts on distance - that's already sarcasm. Why did i written it. You asked for help and didn't put any code to gelp with. I'm sorry man, but no one can help you with code if only can see the code. That's the funniest part...

So I suggestion you:

Way 1: place the code how didyou called the Admin tool and how do you processing the command.

Way 2: if someone else will respond to your request - type to him in private chat and I guess in Discord he/she or someone in between will help you with you admin tool.

 

Point is: without the code there's nothing to talking about...

Share this post


Link to post
Share on other sites
On 7/27/2024 at 8:25 PM, Sid Debian said:

It's not sarcasm, it's obvious truth uf you can't accept it, sorry I can help with that.

You know returning to your question you're pleasing me to read your thoughts on distance - that's already sarcasm. Why did i written it. You asked for help and didn't put any code to gelp with. I'm sorry man, but no one can help you with code if only can see the code. That's the funniest part...

So I suggestion you:

Way 1: place the code how didyou called the Admin tool and how do you processing the command.

Way 2: if someone else will respond to your request - type to him in private chat and I guess in Discord he/she or someone in between will help you with you admin tool.

 

Point is: without the code there's nothing to talking about...

Ok, so sorry.

Follow an example of my code, it's very simple. Basically I keep monitoring the onEvent on mission server for the ChatMessageEventTypeID, and then check if is a valid command and execute it.
The only difference to the original code, is that I splited in other files to keep organized, but this is the concept, follow the same principle of the older versions of admin chat commands.
I've tried to don't call the super function when received a valid command, but didn't worked. 

 

class AdmMissionServer : MissionServer
{

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

        if (eventTypeId == ChatMessageEventTypeID)
		{
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );

            if (chat_params.param2 == "") return ;
            
            PlayerBase player = GetPlayer(chat_params.param2);
            if(player == NULL) return ;

            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);

            switch (command)
            {
                case "heal":    { /*Do Heal function*/ break;}
                case "tp":      { /*Teleport function */ break;}
            }
        }
	}
}

 

Share this post


Link to post
Share on other sites
12 hours ago, Fonseca Games said:

Ok, so sorry.

Follow an example of my code, it's very simple. Basically I keep monitoring the onEvent on mission server for the ChatMessageEventTypeID, and then check if is a valid command and execute it.
The only difference to the original code, is that I splited in other files to keep organized, but this is the concept, follow the same principle of the older versions of admin chat commands.
I've tried to don't call the super function when received a valid command, but didn't worked. 

 


class AdmMissionServer : MissionServer
{

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

        if (eventTypeId == ChatMessageEventTypeID)
		{
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );

            if (chat_params.param2 == "") return ;
            
            PlayerBase player = GetPlayer(chat_params.param2);
            if(player == NULL) return ;

            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);

            switch (command)
            {
                case "heal":    { /*Do Heal function*/ break;}
                case "tp":      { /*Teleport function */ break;}
            }
        }
	}
}

 

Right. You always shall call OnChat, BUT, but, you shall call it with the special way.

In your case: Swich - statement shall has "default" case - it's matters coz if text isn't the command - we can call super.OnEvent(eventTypeId,params);, BUT if we have the command - that's the case we shall process the command and shall override the OnEvent case with the trick, we shall reassign the params and set chat_params.param3 as "" (aka empty string) and only then we can call super.OnEvent...

So I suggest you to move to the end of the function the calling of super.OnEvent, when we already have correctly prepared data for submitting. And then your command will be committed silently (without the submitted text), but your admin call will be processed as it supposed to be but will not submitted to everyone eyes in range of 25 - 30 meters around you.

Try to play with that approach, I think you can make it work as you wished to work!

Share this post


Link to post
Share on other sites
Posted (edited)
On 7/31/2024 at 12:47 PM, Sid Debian said:

Right. You always shall call OnChat, BUT, but, you shall call it with the special way.

In your case: Swich - statement shall has "default" case - it's matters coz if text isn't the command - we can call super.OnEvent(eventTypeId,params);, BUT if we have the command - that's the case we shall process the command and shall override the OnEvent case with the trick, we shall reassign the params and set chat_params.param3 as "" (aka empty string) and only then we can call super.OnEvent...

So I suggest you to move to the end of the function the calling of super.OnEvent, when we already have correctly prepared data for submitting. And then your command will be committed silently (without the submitted text), but your admin call will be processed as it supposed to be but will not submitted to everyone eyes in range of 25 - 30 meters around you.

Try to play with that approach, I think you can make it work as you wished to work!

When you say 'call with a special way' you mean by RPC the OnChat?
Oh, I've tested changed the channel but didn't think to make the message empty, I'll try and let you know. tnks

Edited by Fonseca Games

Share this post


Link to post
Share on other sites
On 7/31/2024 at 12:47 PM, Sid Debian said:

Right. You always shall call OnChat, BUT, but, you shall call it with the special way.

In your case: Swich - statement shall has "default" case - it's matters coz if text isn't the command - we can call super.OnEvent(eventTypeId,params);, BUT if we have the command - that's the case we shall process the command and shall override the OnEvent case with the trick, we shall reassign the params and set chat_params.param3 as "" (aka empty string) and only then we can call super.OnEvent...

So I suggest you to move to the end of the function the calling of super.OnEvent, when we already have correctly prepared data for submitting. And then your command will be committed silently (without the submitted text), but your admin call will be processed as it supposed to be but will not submitted to everyone eyes in range of 25 - 30 meters around you.

Try to play with that approach, I think you can make it work as you wished to work!

Not sure if I did correct, but on the way I tried didn't worked.

 

class AdmMissionServer : MissionServer
{

    override void OnEvent(EventType eventTypeId, Param params)  
	{
        if (eventTypeId == ChatMessageEventTypeID)
		{
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );

            if (chat_params.param2 == "") return ;
            
            PlayerBase player = GetPlayer(chat_params.param2);
            if(player == NULL) return ;

            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);
			
			bool isValidCmd = true;
            switch (command)
            {
                case "heal":    { /*Do Heal function*/ break;}
                case "tp":      { /*Teleport function */ break;}
				default :{
					isValidCmd = false;
				}
            }
			if (isValidCmd)
			{
				ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
                Param new_params = new Param4<int, string, string, string>( chat_params.param1, chat_params.param2, "", chat_params.param4 );
                super.OnEvent(eventTypeId, new_params);
			}
            else
            {
                  super.OnEvent(eventTypeId, params);
            }
        }
		else
		{
			super.OnEvent(eventTypeId, params);
		}
	}
}

Basically the change is this, here I tested make the user empty as well, but still see the messages around.

ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
Param new_params = new Param4<int, string, string, string>( chat_params.param1, "", "", chat_params.param4 );
super.OnEvent(eventTypeId,new_params);

 

Share this post


Link to post
Share on other sites
19 hours ago, Fonseca Games said:

Not sure if I did correct, but on the way I tried didn't worked.

 


class AdmMissionServer : MissionServer
{

    override void OnEvent(EventType eventTypeId, Param params)  
	{
        if (eventTypeId == ChatMessageEventTypeID)
		{
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );

            if (chat_params.param2 == "") return ;
            
            PlayerBase player = GetPlayer(chat_params.param2);
            if(player == NULL) return ;

            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);
			
			bool isValidCmd = true;
            switch (command)
            {
                case "heal":    { /*Do Heal function*/ break;}
                case "tp":      { /*Teleport function */ break;}
				default :{
					isValidCmd = false;
				}
            }
			if (isValidCmd)
			{
				ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
                Param new_params = new Param4<int, string, string, string>( chat_params.param1, chat_params.param2, "", chat_params.param4 );
                super.OnEvent(eventTypeId, new_params);
			}
            else
            {
                  super.OnEvent(eventTypeId, params);
            }
        }
		else
		{
			super.OnEvent(eventTypeId, params);
		}
	}
}

Basically the change is this, here I tested make the user empty as well, but still see the messages around.


ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
Param new_params = new Param4<int, string, string, string>( chat_params.param1, "", "", chat_params.param4 );
super.OnEvent(eventTypeId,new_params);

 

So man how about that approach:
 

Spoiler

class AdmMissionServer : MissionServer {
	Param4<int, string, string, string> GenerateEmptyData(ChatMessageEventParams chat_params) {
		Param4<int, string, string, string> returning = new Param4<int, string, string, string>;
		returning.param1 = chat_params.param1;
		returning.param2 = chat_params.param2;
		returning.param3 = "";
		returning.param4 = chat_params.param4;
		return returning;
	}
    override void OnEvent(EventType eventTypeId, Param params) {
        if (eventTypeId == ChatMessageEventTypeID) {
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
            if (chat_params.param2 == "") return;
            PlayerBase player = GetPlayer(chat_params.param2);// WRONG, this param2 return not PlayerBase-instance, but PlayerName (string) and the bset what do you can do with that info is requiest all players on server and check names. If name is found -> get PLayerBase instance and break the loop
            if(player == NULL) return; // <- in current state Casing String -> PlayerBase will be always NULL`
            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);
			switch (command) {
                case "heal": { 
					/*Do Heal function*/
					Call_Heal();
					params = GenerateEmptyData();	// override current data, coz we want to hide ours CMD
					break;
				}
                case "tp": {
					/*Teleport function */ 
					Do_Telepyh();
					params = GenerateEmptyData();	// override current data, coz we want to hide ours CMD
				}
            }
			super.OnEvent(eventTypeId, params);
        } else {
			super.OnEvent(eventTypeId, params);
		}
	}
}

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
On 8/2/2024 at 10:36 PM, Sid Debian said:

So man how about that approach:
 

  Hide contents


class AdmMissionServer : MissionServer {
	Param4<int, string, string, string> GenerateEmptyData(ChatMessageEventParams chat_params) {
		Param4<int, string, string, string> returning = new Param4<int, string, string, string>;
		returning.param1 = chat_params.param1;
		returning.param2 = chat_params.param2;
		returning.param3 = "";
		returning.param4 = chat_params.param4;
		return returning;
	}
    override void OnEvent(EventType eventTypeId, Param params) {
        if (eventTypeId == ChatMessageEventTypeID) {
            ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
            if (chat_params.param2 == "") return;
            PlayerBase player = GetPlayer(chat_params.param2);// WRONG, this param2 return not PlayerBase-instance, but PlayerName (string) and the bset what do you can do with that info is requiest all players on server and check names. If name is found -> get PLayerBase instance and break the loop
            if(player == NULL) return; // <- in current state Casing String -> PlayerBase will be always NULL`
            string message = chat_params.param3, prefix, param0, command;
            TStringArray tokens = new TStringArray;
            message.Split(" ", tokens); 
            int count = tokens.Count();
            param0 = tokens.Get(0);
            param0.ParseStringEx(prefix); 
            if(prefix != "!") return ;
            param0.ParseStringEx(command);
			switch (command) {
                case "heal": { 
					/*Do Heal function*/
					Call_Heal();
					params = GenerateEmptyData();	// override current data, coz we want to hide ours CMD
					break;
				}
                case "tp": {
					/*Teleport function */ 
					Do_Telepyh();
					params = GenerateEmptyData();	// override current data, coz we want to hide ours CMD
				}
            }
			super.OnEvent(eventTypeId, params);
        } else {
			super.OnEvent(eventTypeId, params);
		}
	}
}

 

 

The same, I'm still able to see the cmds close.

I don't know how the messages are sent from the sender to the server and other players, but looks like they aren't managed by this event.

Edited by Fonseca Games

Share this post


Link to post
Share on other sites
16 hours ago, Fonseca Games said:

The same, I'm still able to see the cmds close.

I don't know how the messages are sent from the sender to the server and other players, but looks like they aren't managed by this event.

Man that's the point. You wil always see the message because if it will not appear then script was blocked.

You may try to remove the calling of super onevent by termination of eventhandler, like script called and done no any other options, but that might be an issue related to server performance. Like skipping the command...

 

Override is like: case "/heal": {

Call_Heal(); return;

} break;

 

In that case will not called super.onevent and message will be ignored but the issue is you can't validate that command was executed, ao add personal chat message "I'm still alive, alive!!!" - to be sure that case is passed.

Share this post


Link to post
Share on other sites
17 hours ago, Fonseca Games said:

The same, I'm still able to see the cmds close.

I don't know how the messages are sent from the sender to the server and other players, but looks like they aren't managed by this event.

But to be honest better implement the SteamID checking and that will save a lot of time for you.

And then it will not needed anymore to hide the message. Because SteamID is unique for account idk like passport id or driver license id...

Share this post


Link to post
Share on other sites
1 minute ago, Sid Debian said:

But to be honest better implement the SteamID checking and that will save a lot of time for you.

And then it will not needed anymore to hide the message. Because SteamID is unique for account idk like passport id or driver license id...

If you mean for checking if that player could type that cmd, I already do this, I have a list of SteamID like 'Admins', only them have the hability to execute the cmds. The point is, I don't want other players see the cmd when the adms execute the command near, on this case they even don't know that the adms are online.
 

11 minutes ago, Sid Debian said:

Man that's the point. You wil always see the message because if it will not appear then script was blocked.

You may try to remove the calling of super onevent by termination of eventhandler, like script called and done no any other options, but that might be an issue related to server performance. Like skipping the command...

 

Override is like: case "/heal": {

Call_Heal(); return;

} break;

 

In that case will not called super.onevent and message will be ignored but the issue is you can't validate that command was executed, ao add personal chat message "I'm still alive, alive!!!" - to be sure that case is passed.

I already tried this, to return without call the super function, didn't work as well.

I think this isn't possible without a mod on client side.
Do you know if I can detect a key press on server side? because this is could be an option to 'hide' cmds.

Share this post


Link to post
Share on other sites
29 minutes ago, Fonseca Games said:

If you mean for checking if that player could type that cmd, I already do this, I have a list of SteamID like 'Admins', only them have the hability to execute the cmds. The point is, I don't want other players see the cmd when the adms execute the command near, on this case they even don't know that the adms are online.
 

I already tried this, to return without call the super function, didn't work as well.

I think this isn't possible without a mod on client side.
Do you know if I can detect a key press on server side? because this is could be an option to 'hide' cmds.

I wished to make that approach but met an issue, there's no way to override CustomMission on server-side within support of ChatEvent. And anyway if look through The logic of calling will be like:
Client (message) -> Server (CustomMission -> OnEvent) -> Server (MissionServer) -> RPC to each online client -> (Client-side) OnRPC -> OnChatMessage.

I'd tryed to catch MissionServer->OnEvent and was no luck, may be I've done something wrong but anyway I need to explore that and yet has no time for it 😄

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

×