AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   n00b question : SearchForClients Alternatives (https://forums.alliedmods.net/showthread.php?t=66043)

MoggieX 01-22-2008 05:39

n00b question : SearchForClients Alternatives
 
Morning,

Brace ya self, another n00b question coming :-P

Currently I'm using the sm cash plugin by ferret as a base for another plugin however its using SearchForClients() function to locate the target, when compiling, it gives a warnign that its depreciated.

However when I try the alternatives [FindTarget() or ProcessTargetString()] I receive back:

'argument type mismatch (argument 1)'

This is what I have written, can some point me in the right direction to using one of the alternatives? Where 'name' is the target

PHP Code:

// find a target
    
new iClients[3];
    new 
iNumClients FindTarget(nameiClients3);
    
    if (
iNumClients == 0)
    {
        
PrintToChatAll("\x04[SM Colour]\x01 No matching client");
        
//ReplyToCommand(client, "[SM Colour] %t", "No matching client");
        
return Plugin_Handled;
    }
    else if (
iNumClients 1)
    {
        
PrintToChatAll("\x04[SM Colour]\x01 More than one client matches");
        
//ReplyToCommand(client, "[SM Colour] %t", "More than one client matches", name);
        
return Plugin_Handled;
    }
    else if (!
CanUserTarget(clientiClients[0]))
    {
        
PrintToChatAll("\x04[SM Colour]\x01 Unable to target");
        
//ReplyToCommand(client, "[SM Colour] %t", "Unable to target");
        
return Plugin_Handled;
    }
other code here.... 

BTW once this is done, I'll be ready to release it!

Matt

MoggieX 01-22-2008 08:47

Re: n00b question : SearchForClients Alternatives
 
hmmm.... ignore the above the base commands appear to be what I was looking for as it looks like the extra coding added to check the clinets has now been added to ProcessTargetString() and will do the vast majority of the checking!

Matt

ferret 01-28-2008 10:21

Re: n00b question : SearchForClients Alternatives
 
FindTarget is a very simple stock meant to hide and wrap up the ProcessTargetString and error message handling. It's only really meant for commands that will only target a single player. If you need stuff like @all/@team, don't use it.

Sounds like you got where you need to go though.

MoggieX 01-29-2008 07:27

Re: n00b question : SearchForClients Alternatives
 
Quote:

Originally Posted by ferret (Post 579237)
FindTarget is a very simple stock meant to hide and wrap up the ProcessTargetString and error message handling. It's only really meant for commands that will only target a single player. If you need stuff like @all/@team, don't use it.

Sounds like you got where you need to go though.

Hi Ferret,

Yes I did after trawling through the base plugins :)

BTW The reason for the post as I was using your cash plugin as a base which uses that function and wanted an alternative so that the plugin I was writting it would be approved (not using a depreciated function)

Matt

ferret 01-29-2008 13:53

Re: n00b question : SearchForClients Alternatives
 
Yeah cash is very old. It was written before ProcessTargetString was added (Many many months bebfore). In fact, it was written before FindTarget was made a base stock.


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

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