SA-MP Forums Archive
How do I make chat and commands appear in the console? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I make chat and commands appear in the console? (/showthread.php?tid=542914)



How do I make chat and commands appear in the console? - Zion22be - 23.10.2014

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!


Re: How do I make chat and commands appear in the console? - ThePhenix - 23.10.2014

Read this and you will know how:

https://sampwiki.blast.hk/wiki/Server.cfg


Re: How do I make chat and commands appear in the console? - Guest4390857394857 - 23.10.2014

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


Re: How do I make chat and commands appear in the console? - Guest4390857394857 - 23.10.2014

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.


Re: How do I make chat and commands appear in the console? - gurmani11 - 23.10.2014

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;
}