Now uses new FindTarget stock
authorMichael McKoy <ferret99gt@gmail.com>
Thu Jul 26 23:42:13 2007 +0000 (2007-07-26)
changeset 117835e342535d2b
parent 1177 90c066adfa6b
child 1179 de29782b9146
Now uses new FindTarget stock
plugins/basechat.sp
     1.1 --- a/plugins/basechat.sp	Thu Jul 26 23:31:58 2007 +0000
     1.2 +++ b/plugins/basechat.sp	Thu Jul 26 23:42:13 2007 +0000
     1.3 @@ -131,39 +131,29 @@
     1.4  	}	
     1.5  	else if (msgStart == 2 && (CheckAdminForChat(client) || GetConVarBool(g_Cvar_Psaymode))) // sm_psay alias
     1.6  	{
     1.7 -		decl String:target[64];
     1.8 +		decl String:arg[64];
     1.9  	
    1.10 -		new len = BreakString(message, target, sizeof(target));
    1.11 -		
    1.12 -		new clients[2];
    1.13 -		new numClients = SearchForClients(target, clients, 2);
    1.14 +		new len = BreakString(message, arg, sizeof(target));
    1.15 +		new target = FindTarget(client, arg, true, false);
    1.16  		
    1.17 -		if (numClients == 0)
    1.18 -		{
    1.19 -			PrintToChat(client, "[SM] %t", "No matching client");
    1.20 +		if (target == -1)
    1.21  			return Plugin_Handled;
    1.22 -		}
    1.23 -		else if (numClients > 1)
    1.24 -		{
    1.25 -			PrintToChat(client, "[SM] %t", "More than one client matches", target);
    1.26 -			return Plugin_Handled;
    1.27 -		}
    1.28  		
    1.29  		decl String:name2[64];
    1.30 -		GetClientName(clients[0], name2, sizeof(name2));
    1.31 +		GetClientName(target, name2, sizeof(name2));
    1.32  	
    1.33  		if (g_DoColor)
    1.34  		{
    1.35  			PrintToChat(client, "\x04(Private to %s) %s: \x01%s", name2, name, message[len]);
    1.36 -			PrintToChat(clients[0], "\x04(Private to %s) %s: \x01%s", name2, name, message[len]);
    1.37 +			PrintToChat(target, "\x04(Private to %s) %s: \x01%s", name2, name, message[len]);
    1.38  		}
    1.39  		else
    1.40  		{
    1.41  			PrintToChat(client, "(Private to %s) %s: %s", name2, name, message[len]);
    1.42 -			PrintToChat(clients[0], "(Private to %s) %s: %s", name2, name, message[len]);			
    1.43 +			PrintToChat(target, "(Private to %s) %s: %s", name2, name, message[len]);			
    1.44  		}
    1.45  
    1.46 -		LogMessage("%L triggered sm_psay to %L (text %s)", client, clients[0], message);		
    1.47 +		LogMessage("%L triggered sm_psay to %L (text %s)", client, target, message);		
    1.48  	}
    1.49  	else
    1.50  		return Plugin_Continue;
    1.51 @@ -287,7 +277,7 @@
    1.52  	new color = FindColor(colorStr);
    1.53  
    1.54  	if (color == -1)    
    1.55 -	    SendDialogToAll(_, "%s: %s", name, text);
    1.56 +		SendDialogToAll(_, "%s: %s", name, text);
    1.57  	else
    1.58  		SendDialogToAll(color, "%s: %s", name, text[len]);
    1.59  
    1.60 @@ -324,49 +314,33 @@
    1.61  		return Plugin_Handled;	
    1.62  	}	
    1.63  	
    1.64 -	decl String:text[192];
    1.65 +	decl String:text[192], String:arg[64], String:message[192];
    1.66  	GetCmdArgString(text, sizeof(text));
    1.67 -	
    1.68 -	decl String:target[64], String:message[192];
    1.69  
    1.70 -	new len = BreakString(text, target, sizeof(target));
    1.71 +	new len = BreakString(text, arg, sizeof(arg));
    1.72  	BreakString(text[len], message, sizeof(message));
    1.73  	
    1.74 -	new clients[2];
    1.75 -	new numClients = SearchForClients(target, clients, 2);
    1.76 -	
    1.77 -	if (numClients == 0)
    1.78 -	{
    1.79 -		ReplyToCommand(client, "[SM] %t", "No matching client");
    1.80 -		return Plugin_Handled;
    1.81 -	}
    1.82 -	else if (numClients > 1)
    1.83 -	{
    1.84 -		ReplyToCommand(client, "[SM] %t", "More than one client matches", target);
    1.85 -		return Plugin_Handled;
    1.86 -	}
    1.87 -	else if (!CanUserTarget(client, clients[0]))
    1.88 -	{
    1.89 -		ReplyToCommand(client, "[SM] %t", "Unable to target");
    1.90 -		return Plugin_Handled;
    1.91 -	}
    1.92 -	
    1.93 +	new target = FindTarget(client, arg, true, false);
    1.94 +		
    1.95 +	if (target == -1)
    1.96 +		return Plugin_Handled;	
    1.97 +		
    1.98  	decl String:name[64], String:name2[64];
    1.99  	GetClientName(client, name, sizeof(name));
   1.100 -	GetClientName(clients[0], name2, sizeof(name2));
   1.101 +	GetClientName(target, name2, sizeof(name2));
   1.102  
   1.103  	if (g_DoColor)
   1.104  	{
   1.105  		PrintToChat(client, "\x04(Private: %s) %s: \x01%s", name2, name, message);
   1.106 -		PrintToChat(clients[0], "\x04(Private: %s) %s: \x01%s", name2, name, message);
   1.107 +		PrintToChat(target, "\x04(Private: %s) %s: \x01%s", name2, name, message);
   1.108  	}
   1.109  	else
   1.110  	{
   1.111  		PrintToChat(client, "(Private: %s) %s: %s", name2, name, message);
   1.112 -		PrintToChat(clients[0], "(Private: %s) %s: %s", name2, name, message);		
   1.113 +		PrintToChat(target, "(Private: %s) %s: %s", name2, name, message);		
   1.114  	}
   1.115  
   1.116 -	LogMessage("%L triggered sm_psay to %L (text %s)", client, clients[0], message);
   1.117 +	LogMessage("%L triggered sm_psay to %L (text %s)", client, target, message);
   1.118  	
   1.119  	return Plugin_Handled;	
   1.120  }