Public feed #377187

Something

public cpp v1 · immutable
Raw Edit
·published 2007-03-01 15:28 UTC
rendered paste body
public idmatch(playerid,string[]){    new id=-1;	if(strlen(string)==0)	{	    SendClientMessage(playerid,servermsg,"Input an ID/name!");	    return -1;	}	else	{		new matches=0;		if(isnum(string)==1)		{			new nid=strval(string);			if(IsPlayerConnected(nid))			{				return nid;			}		}		for(new n=0;n<GetMaxPlayers();n++)		{			if(IsPlayerConnected(n))			{				new name[256];				GetPlayerName(n,name,sizeof(name));				if(strcmp(string,name,true)==0)				{					return n;				}				else if(strfind(name,string,true)!=-1)				{				    id=n;					matches++;				}			}		}		if(matches>1)		{		    new output[256];		    format(output,sizeof(output),"There were %d matches found for \"%s\" - aborting.",matches,string);		    SendClientMessage(playerid,servermsg,output);		    return -1;		}		else if(matches==0)		{			new output[256];			format(output,sizeof(output),"There were no matches found for \"%s\" - aborting.",string);			SendClientMessage(playerid,servermsg,output);			return -1;		}	}	return id;}