Raised This Month: $159 Target: $400
 39% 

All chat with Simple Chat Processor


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blaacky
Senior Member
Join Date: Oct 2012
Old 09-06-2013 , 06:55   All chat with Simple Chat Processor
Reply With Quote #1

I can't use the popular all chat plugin because it doesn't work well when formatting player names with simple chat processor (SCP). Names just show up like chat-yellow. I tried making an all chat plugin with SCP but it acts very weird. For every player on a team, it will say the chat message that many times for everyone. So if 5 people are on a team and someone types "hi", it will say "hi" to everyone 5 times. Anyone know how to fix this?

Link to SCP: https://sourcemod.net/showthread.php?t=198501

PHP Code:
public Action:OnChatMessage(&authorHandle:recipientsString:name[], String:message[])
{
    if(
GetMessageFlags() & CHATFLAGS_ALL)
    {
        
ClearArray(recipients);
        for(new 
i=1i<=MaxClientsi++)
        {
            if(
IsClientInGame(i))
            {
                
PushArrayCell(recipientsi);
            }
        }
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;


Last edited by blaacky; 09-06-2013 at 08:38.
blaacky is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-06-2013 , 14:51   Re: All chat with Simple Chat Processor
Reply With Quote #2

heyy. hunter x hunter guy! try something like this:
Code:
#include <cstrike>
#include <sourcemod>
#include <sdktools>
#include <scp>
#include <smlib>

new bool:newmessage = false;

public OnPluginStart(){

	AddCommandListener(onsay, "say");

}


public Action:onsay(client, const String:command[], argc){

	newmessage = true;

}


public Action:OnChatMessage(&author, Handle:recipients, String:name[], String:message[])
{
	if(newmessage && GetMessageFlags() & CHATFLAGS_ALL && !IsPlayerAlive(author))
	{
		for(new i=1; i<=MaxClients; i++)
		{
			if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
			{
				PushArrayCell(recipients, i);
			}
		}
		newmessage = false;
		return Plugin_Changed;
	}
	newmessage = false;
	
	return Plugin_Continue;
}
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 09-06-2013 , 20:32   Re: All chat with Simple Chat Processor
Reply With Quote #3

Thanks it works. I don't know how my code was wrong and I don't know why your's is right but it works so whatever. Is it because the newmessage bool blocks all the other messages?

Last edited by blaacky; 09-06-2013 at 20:33.
blaacky is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-06-2013 , 21:47   Re: All chat with Simple Chat Processor
Reply With Quote #4

yes, right. if i'm not wrong, the simple chat processor hooks every message a client receives, not every message sent. so, if you add everyone to the array everytime the function is called, you will send every client a single message n times, if there was n players receiving the message by default.
but, if you just add the people who wouldn't receive a message just a single time, then, everyone would receive it just one time. that's possible to do achieve because the command hook "say" happens before the message be received by any client and, so, you can add everyone who wouldn't receive your message(who are the alive people, if you are dead), only at the first time the scp calls your function.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:57.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode