AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Chat Revamp API V1.2b (https://forums.alliedmods.net/showthread.php?t=299509)

eyal282 07-16-2017 19:52

Chat Revamp API V1.2b
 
1 Attachment(s)
I did not perfectly test it but there isn't a reason it won't work. My current suspicion is that SayText may be sent more than once per chat.

This plugin revamps the chat ( say/_team ) and allows with a single forward and a single native, allowing to stop a player from receiving chat from a specific player and even eavesdrop to team chat.

Despite being API, there are built in features.

API Forward:

Code:

public client_ChatPrintByPlayer(sender, receiver, bool:WillSend, bool:TeamChat, Message[], MessageTags[])

sender = player sending the chat message.

receiver = player receiving the chat message.

bool:WillSend = true if the message will be sent at all ( might be altered if return 2 is applied, causing eavesdropping of team chat only ).

bool:TeamChat = true if the chat is team chat.

Message[] = The message the sender wrote that the receiver is going to receive.

MessageTags[] = The tags accompanied with the message. Completely useless if you don't wish to block the message with return 1 and use the native to resend the message with censorship for example.

return 0 to ignore, return 1 to block the receiver from receiving the chat, return 2 to receive the chat even if it's team chat.

API Native:

Code:


native print_special_colorchat(index, sender, Message[], MessageTags[]);

index = index receiving the message.
sender = player sending the message. Used to display his name and team color.
Message[] = Message to send. Only this should be altered in general.
MessageTags[] = The tags accompanied with the message.

Current functions outside of API:

Code:


say /blockchat <target> - blocks / unblocks target from chatting to you. Doesn't affect ADMIN_IMMUNITY. You can't send chat messages to blocked targets in addition to receiving them.

say /stopchat - blocks / unblocks all chat messages. Doesn't affect chat sent by ADMIN_IMMUNITY.

Dead to alive chat modified by cvar.

Team chat disable by cvar. In disable of team chat, all team chats are sent as normal chats.

Allow blocking players from chatting by cvar.

Allow blocking the general chat by cvar.

CVARs:

Note: All cvars are set in the beginning of the map.

Code:

chat_revamp_enabled - Enables entire plugin. Default 1.
chat_allow_dead_to_alive - Allows dead player to chat alive players if set to 1. Default 0.
chat_allow_team_chat - Allows player to chat to their team if set to 1. Default 1.
chat_allow_block - Allows player to block chat from specific players if set to 1. Doesn't apply on sending ADMIN_IMMUNITY. Default 1.
chat_allow_stop_chat - Allows player to disable receiving chat. Doesn't apply on sending ADMIN_IMMUNITY. Default 1.

Sorry for giving a plugin that might not even work but it'll take a day for people to evaluate whether or not it's working ( I generally need a server with 2 real players to test it properly ).

Mistrick 07-18-2017 13:13

Re: Chat Revamp API V1.1b
 
Why do you do all stuff in hook message?

https://github.com/s1lentq/ReGameDLL....cpp#L726-L770

Say command generate message for all players on server. One command -> 32(max) messages.
In hook you do cycle with send message for players and block original message but then you can get another 31 messages, again own cycle for players. You did chat spammer.
Why your stock func for SayText send message in unreliable channel? You can lost messages.

Ayman Khaled 07-18-2017 14:12

Re: Chat Revamp API V1.1b
 
use pcvars instead.

edon1337 07-18-2017 14:44

Re: Chat Revamp API V1.1b
 
Quote:

Originally Posted by Ayman Khaled (Post 2536176)
use pcvars instead.

And how are you going to use pcvars in his situation?

Ayman Khaled 07-18-2017 15:56

Re: Chat Revamp API V1.1b
 
if i'm not wrong :/

PHP Code:

new enabledeadtoalive;

public 
plugin_init()
{
    
enable register_cvar("chat_revamp_enabled""1");
    
deadtoalive register_cvar("chat_allow_dead_to_alive""0");

}

public 
plugin_cfg()
{
    if(!
get_pcvar_num(enable))
        
pause("a");
        
    else
    {
        
pDeadChat get_pcvar_num(deadtoalive);
    }



edon1337 07-18-2017 17:37

Re: Chat Revamp API V1.1b
 
Quote:

Originally Posted by Ayman Khaled (Post 2536209)
if i'm not wrong :/

PHP Code:

new enabledeadtoalive;

public 
plugin_init()
{
    
enable register_cvar("chat_revamp_enabled""1");
    
deadtoalive register_cvar("chat_allow_dead_to_alive""0");

}

public 
plugin_cfg()
{
    if(!
get_pcvar_num(enable))
        
pause("a");
        
    else
    {
        
pDeadChat get_pcvar_num(deadtoalive);
    }



Sorry, my mistake, I didn't actually pay attention to the code, you're right.

eyal282 07-18-2017 18:45

Re: Chat Revamp API V1.1b
 
I suspect that whenever someone writes in the chat, it's printed x times players connected.

HamletEagle 07-19-2017 03:10

Re: Chat Revamp API V1.1b
 
You can ALWAYS use pcvars(and you must)

eyal282 07-19-2017 07:02

Re: Chat Revamp API V1.1b
 
Quote:

Originally Posted by HamletEagle (Post 2536277)
You can ALWAYS use pcvars(and you must)

Will be done. Is it possible that the chat is printed more than once equal to the players connected?:nono:

Ayman Khaled 07-19-2017 07:16

Re: Chat Revamp API V1.1b
 
Quote:

Originally Posted by eyal282 (Post 2536311)
Will be done. Is it possible that the chat is printed more than once equal to the players connected?:nono:

Quote:

Originally Posted by Mistrick (Post 2536163)
In hook you do cycle with send message for players and block original message but then you can get another 31 messages, again own cycle for players. You did chat spammer.



All times are GMT -4. The time now is 09:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.