How do I make chat and commands appear in the console?
#1

Hello all. I'm fairly new to PAWN and I'd like to know, if it's possible, how to log the chat so it appears in my admin console that I have when I start the server (along with any commands inputted on the server).

Basically, I want to make it so if I type "hi" on the server, It'd appear in the console. Also, if I do a command, such as /v infernus to spawn an infernus, it appears in the console. Would I have to add this all in myself per command? Is there an easy shortcut to just make chat messages appear in the console?

Thanks!
Reply
#2

Read this and you will know how:

https://sampwiki.blast.hk/wiki/Server.cfg
Reply
#3

If your using ZCMD. Make use of...
OnPlayerCommandPerformed(playerid, cmdtext[], success)
Reply
#4

Create a new file in scriptfiles folder named cmd.txt & copy the lines below & paste it in anywhere in script but not under any callbacks.

pawn Код:
OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
  new File:log = fopen("cmd.txt", io_write);
    if(log)
    {
new str[56], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"%s has used %s command. \r\n",name,cmdtext);
        fwrite(log, str);
        fclose(log);
    }
}
This is untested, but it works. Try it.
Reply
#5

Here if you only want to make them appear in console.
pawn Код:
#include zcmd

public OnPlayerText(playerid, text[])
{
    printf("Text:%s Says: %s",pName, text);
    return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    printf("CMD: %s Used: %s",pName,cmdtext);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)