Show a what command player uses on irc
#1

Hey, as the title says. I would like to get a simple example on how to show the command player uses through irc.


For example:

A player used /admins in-game. Then on an irc channel for example #commands, a message should appear like "PlayerName[id] typed /admins.

Or

A player used "/pm 0 Hello". Then it should appear on the irc "PlayerName[id] typed /pm 0 Hello!.


How to exactly make a string using the callback :

Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
A simple help and example would work, with few explanations if you please. I am pretty new on scripting, so thanks for the help.
Reply
#2

Anyone? Please?
Reply
#3

24 hour bumps only, and this is likely explained in shorter form in many places.

Firstly, on how to get an output from a players commands in zcmd, and second how to show a string in IRC from the script.

cmdtext in OnPlayerCommandPerformed is what you need to pipe to the IRC Plugin, and then it will show it in IRC...



In real short form, you can simply use cmdtext as the string to send to the IRC channel... That's how simple this is.

Search, and read more about how this all works.
Reply
#4

PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success// The Main function.
// opening bracket
    
if(strlen(cmdtext) && success// if player typed a command and if it is a success.
    
{
        new 
name[MAX_PLAYER_NAME], string[75]; 
        
        
GetPlayerName(playeridnameMAX_PLAYER_NAME); // get the player name to see who typed the command.
        
format(stringsizeof(string), "[CmdTxt]: %s[%i] typed the command: /%s"nameplayeridcmdtext);
        for(new 
0MAX_PLAYERSi++)  // we are making a loop to see who are the admins in game.
        
{
            if(
IsPlayerIRCAdm....) return SendIRCMessage(...); // here is the place where you would add your IRC message to the irc admins.
        
}
    }
    return 
1;
// closing bracket 
Reply
#5

Could anyone help me through discord? My id is #8800. So I won't need to keep posting here a lot of questions. If thats alright.


@topic; Thanks Sew_Sumi and SeanDenZYR. I appreciate it.
Reply
#6

Asking for help privately is not allowed. And its all okay if you post a lot of questions here. The thread's here for that.
Reply
#7

Oh it isn't? Sorry for that.


anyways I can't get that to work SeanDenZYR....


Anyways to explain what I need again...

Like it will be sent to an irc channel, not to an admin or whatsoever.


For example I would like to send to an irc channel named #management

I have this:

Код:
new adminstring[144];
	if(isnull(params)) return SendClientMessage(playerid, -1,"*"COL_GREY" USAGE: /ad [message]") && SendClientMessage(playerid, -1,"*"COL_GREY" FUNCTION: Use admin chat");
	
	format(adminstring, sizeof(adminstring), "* "COL_LIGHTGREEN"[Admin Chat] %s(%d): "COL_WHITE"%s", pInfo[playerid][pUsername], playerid, params);
	SendMessageToAllAdmins(adminstring, -1);

	format(adminstring, sizeof(adminstring), "\x0206[Admin Chat]\x02 \x1D%s[%d]\x1D: %s", pInfo[playerid][pUsername], playerid, params);
   	IRC_GroupSay(gGroupID, IRC_ADMINCHANNEL, adminstring);

	return CMD_SUCCESS;
Now that sends the messege to the set "IRC_ADMINCHANNEL" example is management.... What I would like to know is how if its a player used like "/pm 0 Hi dude". I would like that message to appear on that IRC_ADMINCHANNEL which is #managament like: "PlayerName[id] typed the command /pm 0 Hi dude.
Reply
#8

You're possibly pulling params, instead of cmdtext as we were referring to.

Your params references will only pull out the params of the command, so instead of "/pay 1 100", you'll probably get "1 100".

It'll all be in the format usage. Attempt to reference cmdtext, and to use it as a string.

What's both messages currently displaying??


Also more as to the reason for the non-private help, is that when we fix issues here, there's a trail for anyone who thinks of the same idea, or a concept that uses the same things. It'll also help out if people look here for assistance to fix something that's bugging.
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
What's both messages currently displaying??

Well on the code I sent, it shows that to a channel that

"[Admin Chat]PlayerName[Id]: message".


I want one that will sent is on a channel like "PlayerName[id] typed the command /ad <message here>" and same goes to other, on pm's and on other cmd. Like when they type "/cmds" it'll show "PlayerName[id] typed the command /cmds" I just want an example, so I can simply edit it and put on a script
Reply
#10

I dunno, I put this format
Код:
format(string, sizeof(string), "[CmdTxt]: %s[%i] typed the command: /%s", name, playerid, cmdtext);
to the test via SendClientMessage and got

Quote:

[13:19:07] [CmdTxt]: Wo_Hong_Dong[0] typed the command: //version

Now, /version is a zcmd command I put in to test. I do not think it will pick up anything that is not zcmd, so check that this is all thought of.

You'll have trouble getting the params from the command after it's been passed to OnPlayerCommandPerformed, as that was on the previous section of code. So if you need the params, you'll have to make a player based array, to track the last set of params to pass onto this, but you will run into a problem where the params that were entered for the last param accepting command, will show up for instance, if you have a command after which has no params, and it's used.


For instance, if I had "/pm 1 Hi Dude", then used "/version". If not checked, I'll end up showing in the second command response, "/version 1 Hi Dude" if the array isn't cleared out upon showing in this callback.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)