plugins/basechat.sp
changeset 2318 9fd83773631c
parent 2289 44045ead61cd
child 2342 70d4ef38b90e
     1.1 --- a/plugins/basechat.sp	Thu Sep 18 18:42:13 2008 +1200
     1.2 +++ b/plugins/basechat.sp	Tue Sep 23 01:17:15 2008 -0500
     1.3 @@ -114,12 +114,12 @@
     1.4  	
     1.5  	if (msgStart == 1 && CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT)) // sm_say alias
     1.6  	{
     1.7 -		SendChatToAll(name, message);
     1.8 +		SendChatToAll(client, message);
     1.9  		LogAction(client, -1, "%L triggered sm_say (text %s)", client, message);
    1.10  	}
    1.11  	else if (msgStart == 3 && CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT)) // sm_csay alias
    1.12  	{
    1.13 -		PrintCenterTextAll("%s: %s", name, message);
    1.14 +		DisplayCenterTextToAll(client, message);
    1.15  		LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text);		
    1.16  	}	
    1.17  	else if (msgStart == 2 && CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT)) // sm_psay alias
    1.18 @@ -200,10 +200,7 @@
    1.19  	decl String:text[192];
    1.20  	GetCmdArgString(text, sizeof(text));
    1.21  
    1.22 -	decl String:name[64];
    1.23 -	GetClientName(client, name, sizeof(name));
    1.24 -			
    1.25 -	SendChatToAll(name, text);
    1.26 +	SendChatToAll(client, text);
    1.27  	LogAction(client, -1, "%L triggered sm_say (text %s)", client, text);
    1.28  	
    1.29  	return Plugin_Handled;		
    1.30 @@ -219,11 +216,9 @@
    1.31  	
    1.32  	decl String:text[192];
    1.33  	GetCmdArgString(text, sizeof(text));
    1.34 -
    1.35 -	new String:name[64];
    1.36 -	GetClientName(client, name, sizeof(name));
    1.37  	
    1.38 -	PrintCenterTextAll("%s: %s", name, text);
    1.39 +	DisplayCenterTextToAll(client, text);
    1.40 +	
    1.41  	LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text);
    1.42  	
    1.43  	return Plugin_Handled;		
    1.44 @@ -236,17 +231,26 @@
    1.45  		ReplyToCommand(client, "[SM] Usage: sm_hsay <message>");
    1.46  		return Plugin_Handled;  
    1.47  	}
    1.48 -    
    1.49 +	
    1.50  	decl String:text[192];
    1.51  	GetCmdArgString(text, sizeof(text));
    1.52   
    1.53 -	decl String:name[64];
    1.54 -	GetClientName(client, name, sizeof(name));
    1.55 -    
    1.56 -	PrintHintTextToAll("%s: %s", name, text);
    1.57 +	decl String:nameBuf[MAX_NAME_LENGTH];
    1.58 +	
    1.59 +	new maxClients = GetMaxClients();
    1.60 +	for (new i = 1; i <= maxClients; i++)
    1.61 +	{
    1.62 +		if (!IsClientConnected(i) || IsFakeClient(i))
    1.63 +		{
    1.64 +			continue;
    1.65 +		}
    1.66 +		FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
    1.67 +		PrintHintText(i, "%s: %s", nameBuf, text);
    1.68 +	}
    1.69 +	
    1.70  	LogAction(client, -1, "%L triggered sm_hsay (text %s)", client, text);
    1.71 -    
    1.72 -	return Plugin_Handled;    
    1.73 +	
    1.74 +	return Plugin_Handled;	
    1.75  }
    1.76  
    1.77  public Action:Command_SmTsay(client, args)
    1.78 @@ -256,7 +260,7 @@
    1.79  		ReplyToCommand(client, "[SM] Usage: sm_tsay <message>");
    1.80  		return Plugin_Handled;  
    1.81  	}
    1.82 -    
    1.83 +	
    1.84  	decl String:text[192], String:colorStr[16];
    1.85  	GetCmdArgString(text, sizeof(text));
    1.86  	
    1.87 @@ -266,15 +270,28 @@
    1.88  	GetClientName(client, name, sizeof(name));
    1.89  		
    1.90  	new color = FindColor(colorStr);
    1.91 -
    1.92 -	if (color == -1)    
    1.93 -		SendDialogToAll(_, "%s: %s", name, text);
    1.94 -	else
    1.95 -		SendDialogToAll(color, "%s: %s", name, text[len]);
    1.96 +	new maxClients = GetMaxClients();
    1.97 +	new String:nameBuf[MAX_NAME_LENGTH];
    1.98 +	
    1.99 +	if (color == -1)
   1.100 +	{
   1.101 +		color = 0;
   1.102 +		len = 0;
   1.103 +	}
   1.104 +	
   1.105 +	for (new i = 1; i <= maxClients; i++)
   1.106 +	{
   1.107 +		if (!IsClientConnected(i) || IsFakeClient(i))
   1.108 +		{
   1.109 +			continue;
   1.110 +		}
   1.111 +		FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
   1.112 +		SendDialogToOne(i, color, "%s: %s", nameBuf, text[len]);
   1.113 +	}
   1.114  
   1.115  	LogAction(client, -1, "%L triggered sm_tsay (text %s)", client, text);
   1.116 -    
   1.117 -	return Plugin_Handled;    
   1.118 +	
   1.119 +	return Plugin_Handled;	
   1.120  }
   1.121  
   1.122  public Action:Command_SmChat(client, args)
   1.123 @@ -388,15 +405,44 @@
   1.124  	return -1;
   1.125  }
   1.126  
   1.127 -SendChatToAll(String:name[], String:message[])
   1.128 +SendChatToAll(client, String:message[])
   1.129  {
   1.130 -	if (g_DoColor)
   1.131 +	new maxClients;
   1.132 +	new String:nameBuf[MAX_NAME_LENGTH];
   1.133 +	
   1.134 +	maxClients = GetMaxClients();
   1.135 +	for (new i = 1; i <= maxClients; i++)
   1.136  	{
   1.137 -		PrintToChatAll("\x04(ALL) %s: \x01%s", name, message);
   1.138 +		if (!IsClientConnected(i) || IsFakeClient(i))
   1.139 +		{
   1.140 +			continue;
   1.141 +		}
   1.142 +		FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
   1.143 +		
   1.144 +		if (g_DoColor)
   1.145 +		{
   1.146 +			PrintToChat(i, "\x04(ALL) %s: \x01%s", nameBuf, message);
   1.147 +		}
   1.148 +		else
   1.149 +		{
   1.150 +			PrintToChat(i, "%s: %s", nameBuf, message);
   1.151 +		}
   1.152  	}
   1.153 -	else
   1.154 +}
   1.155 +
   1.156 +DisplayCenterTextToAll(client, String:message[])
   1.157 +{
   1.158 +	new String:nameBuf[MAX_NAME_LENGTH];
   1.159 +	new maxClients = GetMaxClients();
   1.160 +	
   1.161 +	for (new i = 1; i < maxClients; i++)
   1.162  	{
   1.163 -		PrintToChatAll("(ALL) %s: %s", name, message);
   1.164 +		if (!IsClientConnected(i) || IsFakeClient(i))
   1.165 +		{
   1.166 +			continue;
   1.167 +		}
   1.168 +		FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
   1.169 +		PrintCenterText(i, "%s: %s", nameBuf, message);
   1.170  	}
   1.171  }
   1.172  
   1.173 @@ -423,26 +469,19 @@
   1.174  	}
   1.175  }
   1.176  
   1.177 -SendDialogToAll(color = 0, String:text[], any:...)
   1.178 +SendDialogToOne(client, color, String:text[], any:...)
   1.179  {
   1.180  	new String:message[100];
   1.181 -	VFormat(message, sizeof(message), text, 3);	
   1.182 +	VFormat(message, sizeof(message), text, 4);	
   1.183  	
   1.184 -	new MaxClients = GetMaxClients();
   1.185 -	for(new i = 1; i < MaxClients; i++)
   1.186 -	{
   1.187 -		if(IsClientInGame(i))
   1.188 -		{
   1.189 -			new Handle:kv = CreateKeyValues("Stuff", "title", message);
   1.190 -			KvSetColor(kv, "color", g_Colors[color][0], g_Colors[color][1], g_Colors[color][2], 255);
   1.191 -			KvSetNum(kv, "level", 1);
   1.192 -			KvSetNum(kv, "time", 10);
   1.193 -			
   1.194 -			CreateDialog(i, kv, DialogType_Msg);
   1.195 -			
   1.196 -			CloseHandle(kv);
   1.197 -		}
   1.198 -	}	
   1.199 +	new Handle:kv = CreateKeyValues("Stuff", "title", message);
   1.200 +	KvSetColor(kv, "color", g_Colors[color][0], g_Colors[color][1], g_Colors[color][2], 255);
   1.201 +	KvSetNum(kv, "level", 1);
   1.202 +	KvSetNum(kv, "time", 10);
   1.203 +	
   1.204 +	CreateDialog(client, kv, DialogType_Msg);
   1.205 +	
   1.206 +	CloseHandle(kv);	
   1.207  }
   1.208  
   1.209  SendPanelToAll(String:name[], String:message[])