[Include] Message3.inc (prevent chat spam and keep chat clean)
#1

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:
  • Creates an indiviual textdraw for cetian messages
  • prevents chat spam of unwanted messages
Requirements:
  • zcmd.inc // #include this into your gamemode before the Message2.inc (without this the include will not function).
  • sscanf2.inc // #include this into your gamemode before the Message2.inc (without this the include will not function).
  • foreach.inc // #include this into your gamemode before the Message2.inc (without this the include will not function).
  • sscanf.dll/.so // Dont forget to put this in your plugin folder and write on the line "plugins" on your server.cfg.
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:
  • /msgpos - Usage /msgpos [Custom X] [Custom Y].
  • /defaultmsg
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!
Reply
#2

great work +rep
Reply
#3

muito bom parabens.
Reply
#4

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

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.
Reply
#6

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.
Reply
#7

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?
Reply
#8

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
Reply
#9

Nice job and also this is a pretty unique idea.
Reply
#10

Add a pastebin link.
Reply
#11

Good job
Reply
#12

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

Looks nice. I'll check this.
Reply
#14

Nice work i really needed something like this. +rep
Reply
#15

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;
}
Reply
#16

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...
Reply
#17

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


Forum Jump:


Users browsing this thread: 1 Guest(s)