[Include] (AdvancedChat.inc) - Fully Controllable Chat
#1

Hello SA-MP Forums, today I gonna release my Advanced Chat include, this include will make you control chat in all ways with just some few call backs and functions. I've added two optional features in it, Flood Protection & Random Color. Gonna explain how to change them below. Firstly you've to type this at the top of your script.
PHP код:
#include <AdvancedChat> 
Now you'll be able to use all the includes functions and callbacks on your script. I've made this include in the simplest way so beginners and newbies won't be facing any problems while using it.


Callbacks
PHP код:
    forward OnChatInit();
    
forward OnChatEnabled();
    
forward OnChatDisabled();
    
forward OnPlayerMuted(playerid);
    
forward OnPlayerUnMuted(playerid); 
Functions
PHP код:
    ToggleChat(boolToggle);
    
ClearChat();
    
ToggleChatID(boolToggle);
    
TogglePlayerChat(playeridboolToggle);
    
TempPlayerMute(playeridminutes);
    
SendPlayerMessageInPointToAll(playeridmsg[], distanceFloat:xFloat:yFloat:z); 
ToggleChat(bool: Toggle);
Description: Allow/Dis Allow players to use the chat feature.
Example:
PHP код:
    ToggleChat(true); // this will allow players to use chat.
    //Put this somewhere 
ClearChat();
Description: Clear the chat like as it was when the server started.
Example:
PHP код:
    ClearChat(); // This will clear the chat.
    //Put this somewhere 
ToggleChatID(bool: Toggle);
Description: Allow/Dis Allow Showing ID beside the player's name.
Example:
PHP код:
    ToggleChatID(true); // this will allow showing ID beside player's name.
    //Put this somewhere 
TogglePlayerChat(playerid, bool: Toggle);
Description: Allow a specified player to chat or disallow him to.
Example:
PHP код:
    TogglePlayerChat(playeridfalse); // This will make the player not able to chat.
    //Put this somewhere in a command 
TempPlayerMute(playerid, minutes);
Description: Mute a specified player for the minutes you set.
Example:
PHP код:
    TempPlayerMute(playerid2); // This will mute the player for 2 minutes.
    //Put this somewhere in a command 
SendPlayerMessageInPointToAll(playerid, msg[], Float:distance, Float, Float:y, Float:z);
Description: Send a auto message from a player in a specified point to everyone.
Example:
PHP код:
    SendPlayerMessageInPointToAll(playerid"Hello, I'm in 0.0, 0.0, 0.0 Coordinates!"50.00.00.0);
    
//Put this somewhere in a command 
I found it useful so I added it.

Settings
PHP код:
#define RandColor // Comment This line if you want to disable the random colors.
#define FloodProtection 1 //Set it to 0 if you want to disable the anti Flood.
#define MAX_CHAT_LENGHT 128 //Max chat lenght that will appear (More words won't be seen) 
Example (Simple, Not Including All Finctions!)
PHP код:
#include <a_samp>
#include <AdvancedChat>
#include <zcmd>
public OnGameModeInit()
{
    
ToggleChat(true); // This will allow players to chat, set it to false if you
    //don't want to use chat.
    
    
ToggleChatID(true); // This will allow players to chat with their ID beside
    //their name.
    
return 1;
}
CMD:muteme(playeridparams[])
{
    
TogglePlayerChat(playeridfalse); // Now the player won't be able to chat.
    
return 1;
}
CMD:unmuteme(playeridparams[])
{
    
TogglePlayerChat(playeridtrue); // Now the player will be able to chat.
    
return 1;

Pastebin Link
http://pastebin.com/13sHNQc7


This is a BETA version, if you found any bugs feel free to PM me or post it in here!
Reply
#2

Use loop in ClearChat, more efficient, in you code, you used 10 SendClientMessageToAll... not clear total chat. Like this:

pawn Код:
stock ClearChat()
{
    for(new i = 0; i <= 50; i++)
        SendClientMessageToAll(0xFFFFFFFF, "");
}
And, attention to if and else if. You used if & if in boolean condition, use if and else if, is more efficient.
Reply
#3

Quote:
Originally Posted by RogerCosta
Посмотреть сообщение
Use loop in ClearChat, more efficient, in you code, you used 10 SendClientMessageToAll... not clear total chat. Like this:

pawn Код:
stock ClearChat()
{
    for(new i = 0; i <= 50; i++)
        SendClientMessageToAll(0xFFFFFFFF, "");
}
And, attention to if and else if. You used if & if in boolean condition, use if and else if, is more efficient.
Was sleepy that time I was coding it , thanks for pointing them out, updated!

+REP
Reply
#4

I suppose this could be useful great job
Reply
#5

Something to note, distance must be float, not int!

SendPlayerMessageInPointToAll(playerid, msg[], Float:distance, Float, Float:y, Float:z);
Reply
#6

Quote:
Originally Posted by vannesenn
Посмотреть сообщение
Something to note, distance must be float, not int!

SendPlayerMessageInPointToAll(playerid, msg[], Float:distance, Float, Float:y, Float:z);
Thanks. It is anyways :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)