SA-MP Forums Archive
[FilterScript] Chat System - 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)
+--- Thread: [FilterScript] Chat System (/showthread.php?tid=558831)



Chat System - nezo2001 - 19.01.2015

Chat System
Here is a chat system that contains the most chat command if anyone have any suggest or found any bug feel free to post here

Commands:
/pm (To Send a private message to a player)
/pms (Toggle between block and unblock private messages)
/wc (Virtual world chat)
* nezo2001 (To put your name before the wrods like that "Nezoo is showing an example for you ")
/shout (To shout like "Stop"! (nezoo shout))
/mute (To prevent player to chat in the main chat 'With Timer' "For Rcon only you can change this to your admin information")
/unmute (To enable him to talk in the chat and kill the timer "Same as above")
/w (whisper which show the message for the near player only with radius 100 "You can change it")
/cc (Car chat to chat with the player in the car only

How to change to your admin information:
Just change this:
PHP код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"You can't use this command"); 
To:
PHP код:
if(PlayerInfo[playerid][pAdmin] == 0)  return SendClientMessage(playeridCOLOR_RED"You can't use this command"); //Here change it to your information 
Edit: I forget to put the link
Link: http://pastebin.com/x2C7wnNA

As i said if you found any bug or you have any suggest feel free to post it here.

Please leave a feedback,
Ahmed_Nezoo


Re: Chat System - mitchellfunny1069 - 19.01.2015

Nice


Re: Chat System - CalvinC - 20.01.2015

Sorry to say this, but this filterscript has alot of faulths...
First of all, the indentation is really quite bad.
Second off, you're creating variables at the top of commands when not needed.

pawn Код:
CMD:mute(playerid, params[])
{
        new targetid, minutes, reason[128], string[128];
        new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new name2[MAX_PLAYER_NAME];
    GetPlayerName(targetid, name2, sizeof(name));
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
        if(muted[targetid] == true) return SendClientMessage(playerid, COLOR_RED, "Player is already muted");
        if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "/mute (id) (minutes) (reason)");
        format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", name, name2, minutes, reason);
        SendClientMessageToAll(COLOR_RED, string);
        mutetimer =     SetTimerEx("Unmute", minutes*60000, false, "i", targetid);
        muted[targetid] = true;
        return 1;
}
You could easily optimise this, you're creating the variables at the top, therefore it will create the variables even if something went wrong.
Like if the targetid isn't connected, the player isn't admin, the targetid is already muted or if you didn't insert a targetid.
It will still create the variables, it would be way better to create the variables as the functions in the command gets executed, not the stuff that checks and cancels the command.
Like this:
pawn Код:
CMD:mute(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
    new targetid;
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
    if(muted[targetid] == true) return SendClientMessage(playerid, COLOR_RED, "Player is already muted");
    new minutes, reason[128];
    if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "/mute (id) (minutes) (reason)");
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(targetid, name2, sizeof(name));
    format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", name, name2, minutes, reason);
    SendClientMessageToAll(COLOR_RED, string);
    mutetimer = SetTimerEx("Unmute", minutes*60000, false, "i", targetid);
    muted[targetid] = true;
    return 1;
}
Also fixed your indentation, but this way would be more optimised.

You could also optimise your script because you're using "else" when it's not needed.
Example:
pawn Код:
CMD:pms(playerid, params[])
{
        if(pm[playerid] == false)
        {
            pm[playerid] = true;
            SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
        }
        else
        {
        pm[playerid] = false;
            SendClientMessage(playerid, 0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
        }
        return 1;
}
Using a switch in these occasions would be much better, and more optimised.

pawn Код:
CMD:pms(playerid, params[])
{
    switch(pm[playerid])
    {
        case false:
        {
            pm[playerid] = true;
            SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
        }
        case true:
        {
            pm[playerid] = false;
            SendClientMessage(playerid, 0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
        }
    }
    return 1;
}



Re: Chat System - nezo2001 - 20.01.2015

This two commands scripted by my mate because i was having exams


Re: Chat System - hossa - 25.01.2015

Well, your mate should've shared them, not you.


Re: Chat System - AroNix - 25.01.2015

Nice !
It is great for servers that do not have something and looking ..


Re: Chat System - MaxOkay - 20.02.2015

Nice
+REP,rep me back.if you want


Re: Chat System - SoNikMells - 20.02.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
pawn Код:
CMD:pms(playerid, params[])
{
    switch(pm[playerid])
    {
        case false:
        {
            pm[playerid] = true;
            SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
        }
        case true:
        {
            pm[playerid] = false;
            SendClientMessage(playerid, 0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
        }
    }
    return 1;
}
...xD

PHP код:
CMD:pms(playeridparams[])
{
    
pm[playerid] = pm[playerid] ? false true;
    return 
SendClientMessage(playerid0xEE128960pm[playerid]
        ? (
"Private Messages blocked! You will no longer receive messages from other players")
        : (
"Private Messages unblocked! You can receive messages from other players"));