SA-MP Forums Archive
[Include] Message3.inc (prevent chat spam and keep chat clean) - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Message3.inc (prevent chat spam and keep chat clean) (/showthread.php?tid=580535)



Message3.inc (prevent chat spam and keep chat clean) - Jakwob - 06.07.2015

This include was created to help people keep their chat box on the server clean and only for chat. i have made all other messages that are not to do with players chatting to other players into textdraws so the chat is only for chat purposes, with the include you can send Usage, Error, Info, Adverts and Admin messages. Everyone has there own way they play so i added so each player can position their own messages to their own desire.

At the top of your code use #include <message3>

Features: Requirements:
Message Styles:
Код:
MSG_STYLE_ERROR    1
MSG_STYLE_INFO     2
MSG_STYLE_USAGE    3
MSG_STYLE_ADVERT   4
MSG_STYLE_ADMIN    5
Functions:
pawn Код:
SendServerMessage(playerid, msgstyle, const message[]);
CreateMessageTextDraw(playerid); // Place under OnPlayerConnect(playerid) Otherwise the textdraws will not show
DestroyMessageTextDraw(playerid); // Place Under OnPlayerDisconnect(playerid, reason) Otherwise the textdraws will not show
Commands:
Example:
pawn Код:
CMD:goto(playerid, params[])
{
    new pID,Float:Pos[3], string[50];
    if(pInfo[playerid][Adminlvl] < 3) return SendServerMessage(playerid, MSG_STYLE_ERROR ,"You are not high enough admin level!");  // New Code!!
    if(sscanf(params, "u", pID)) return SendServerMessage(playerid, MSG_STYLE_USAGE,"Usage: /goto [ID]");  // New Code!!
    if(pID == IPI) return SendServerMessage(playerid, MSG_STYLE_ERROR,"Player is not connected!"); // New Code!!
    GetPlayerPos(pID,Pos[0],Pos[1],Pos[2]);
    SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
    SetPlayerInterior(playerid,GetPlayerInterior(pID));
    format(string,sizeof(string),"Admin %s has teleported to you",GetName(playerid));
    SendServerMessage(playerid, MSG_STYLE_INFO, str);  // New Code!!
    return 1;
}
MSG_STYLE_ADMIN Example
pawn Код:
CMD:atalk(playerid, params[])
{
    new text[128];
    if(sscanf(params, "s[128]", text)) return SendServerMessage(playerid, MSG_STYLE_USAGE, "/atalk [text]");
    SendServerMessage(playerid, MSG_STYLE_ADMIN, text);
    return 1;
}
ScreenShot:






Please post your views on this include, the good, the bad and Suggestions are all welcomed.

Thanks for taking time to look at my work!


Re: Message3.inc (prevent chat spam and keep chat clean) - simo0000 - 14.07.2015

great work +rep


Re: Message3.inc (prevent chat spam and keep chat clean) - iTakelot - 14.07.2015

muito bom parabens.


Re: Message3.inc (prevent chat spam and keep chat clean) - ExTaZZ69 - 14.07.2015

it looks great. Good job! Simple but very usefull include.


Re: Message3.inc (prevent chat spam and keep chat clean) - Crayder - 14.07.2015

Again, as suggested in the others, you should add an optional pre-define position. So if a user defines MSG_POS, you will use their custom position instead of your default.


Re: Message3.inc (prevent chat spam and keep chat clean) - Jakwob - 15.07.2015

Thanks for the comments guys

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Again, as suggested in the others, you should add an optional pre-define position. So if a user defines MSG_POS, you will use their custom position instead of your default.
As it states in the topic there is a command so every player can have there own custom position or they can have the default position. I did it that way as everyone has there own views.


Re: Message3.inc (prevent chat spam and keep chat clean) - Crayder - 15.07.2015

Quote:
Originally Posted by Jakwob
Посмотреть сообщение
As it states in the topic there is a command so every player can have there own custom position or they can have the default position. I did it that way as everyone has there own views.
I know that. What I'm saying is, the server owner may want it to have a different default position. What if a server owner already has textdraws there? It wouldn't be up to the players then, would it?


Re: Message3.inc (prevent chat spam and keep chat clean) - Jakwob - 15.07.2015

Quote:
Originally Posted by Crayder
Посмотреть сообщение
I know that. What I'm saying is, the server owner may want it to have a different default position. What if a server owner already has textdraws there? It wouldn't be up to the players then, would it?
Thanks for the suggestion and I will add it right way and will be in the next update


Re: Message3.inc (prevent chat spam and keep chat clean) - AchievementMaster360 - 15.07.2015

Nice job and also this is a pretty unique idea.


Re: Message3.inc (prevent chat spam and keep chat clean) - SickAttack - 15.07.2015

Add a pastebin link.


Re: Message3.inc (prevent chat spam and keep chat clean) - BladeFire - 15.07.2015

Good job


Re: Message3.inc (prevent chat spam and keep chat clean) - Jakwob - 17.07.2015

Thanks guys for the comments and pastebin link will be added tomorrow.


Re: Message3.inc (prevent chat spam and keep chat clean) - Juliusz - 17.07.2015

Looks nice. I'll check this.


Re: Message3.inc (prevent chat spam and keep chat clean) - LeXuZ - 18.07.2015

Nice work i really needed something like this. +rep


Re: Message3.inc (prevent chat spam and keep chat clean) - zT KiNgKoNg - 27.07.2015

Hi Jakwob,

Just thought you'd find this a little helpful, instead of making someone use format() before showing the message how about implementing something along the lines of the code below (I haven't tested it, but something I whipped up as an example), to format and display the message.

pawn Код:
stock CreateFormattedText(playerid, const msg[], {Float,_}:...)
{
    static
        string[144];

    if (numargs() == 2)
    {
        return msg; // Or add the code to display the message here
    }
    else
    {
        new args = numargs();

        while (--args >= 2)
        {
            #emit LCTRL 5
            #emit LOAD.S.alt args
            #emit SHL.C.alt 2
            #emit ADD
            #emit ADD.C 12
            #emit LOAD.I
            #emit PUSH.pri
        }
        #emit PUSH.S msg
        #emit PUSH.C 144
        #emit PUSH.C string

        #emit LOAD.S.pri 8
        #emit PUSH.pri
        #emit SYSREQ.C format

        return string; // Or add the code to display the message here

        #emit LCTRL 5
        #emit SCTRL 4
        #emit RETN
    }
    return 1;
}



Re: Message3.inc (prevent chat spam and keep chat clean) - n0minal - 27.07.2015

Quote:
Originally Posted by iTakelot
Посмотреть сообщение
muito bom parabens.
You must speak english on this board.

@OnTopic: Seems nice and useful, it reduces a lot of useless messages in chat and keep the screen clean

PS: Post the script on pastebin so it would be easier to analyse the source code and give you more tips about what is wrong or could be better...


Re: Message3.inc (prevent chat spam and keep chat clean) - Jakwob - 08.08.2015

I have added it to my github so it's more accessible. Thanks for the feed back