/blindfold
#21

pawn Код:
stock isNumeric(const string[])
{
  new length=strlen(string);
  if (length==0) return false;
  for (new i = 0; i < length; i++)
  {
    if (
      (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
      || (string[i]=='-' && i!=0)                       // A '-' but not at first.
      || (string[i]=='+' && i!=0)                       // A '+' but not at first.
    ) return false;
  }
  if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  return true;
}

stock GetPlayerId(string[])
{ // By Alex (touched up by DracoBlue & Cueball)
  if(isNumeric(string))
  {
    new player = strval(string);
    if(IsPlayerConnected(player)) return player;
  }
  else
  {
    new playername[MAX_PLAYER_NAME];
    for(new i=0; i<=MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        GetPlayerName(i, playername, MAX_PLAYER_NAME);
        if(strfind(playername, string, true) != -1) return i;
      }
    }
  }
  return INVALID_PLAYER_ID;
}
Copy these into your script (outside of any callbacks/functions, place it at the bottom).

Taken from dutils.inc by DracoBlue But it seems that I made a mistake, the function name is 'GetPlayerId(string[])' (note the Id, as opposed to ID).

Replace this line (in both commands):
pawn Код:
new id = strval(tmp);
with this:
pawn Код:
new id = GetPlayerId(tmp);
Thanks for the feedback on my descriptions.

~Cueball~
Reply


Messages In This Thread
/blindfold - by Pujan2008 - 03.04.2008, 07:21
Re: /blindfold - by MidoBan - 03.04.2008, 07:37
Re: /blindfold - by yom - 03.04.2008, 07:38
Re: /blindfold - by MidoBan - 03.04.2008, 07:42
Re: /blindfold - by swayam - 03.04.2008, 08:23
Re: /blindfold - by MidoBan - 03.04.2008, 08:29
Re: /blindfold - by swayam - 03.04.2008, 09:36
Re: /blindfold - by MidoBan - 03.04.2008, 09:48
Re: /blindfold - by cmg4life - 03.04.2008, 11:16
Re: /blindfold - by Exuro - 03.04.2008, 13:57
Re: /blindfold - by Sandra18[NL] - 03.04.2008, 14:08
Re: /blindfold - by Exuro - 03.04.2008, 14:28
Re: /blindfold - by Tr1viUm - 03.04.2008, 14:34
Re: /blindfold - by Carlos_Leone - 03.04.2008, 14:44
Re: /blindfold - by Saorp - 07.04.2008, 04:43
Re: /blindfold - by Joe Staff - 07.04.2008, 05:17
Re: /blindfold - by Cueball - 07.04.2008, 05:22
Re: /blindfold - by Joe Staff - 07.04.2008, 05:27
Re: /blindfold - by Giacomand - 07.04.2008, 06:20
Re: /blindfold - by Saorp - 08.04.2008, 04:54
Re: /blindfold - by Cueball - 08.04.2008, 05:42
Re: /blindfold - by Saorp - 08.04.2008, 19:15
Re: /blindfold - by kavkazian - 09.04.2008, 20:07
Re: /blindfold - by Pujan2008 - 09.04.2008, 21:08
Re: /blindfold - by Pghpunkid - 10.04.2008, 00:28
Re: /blindfold - by kavkazian - 10.04.2008, 09:19
Re: /blindfold - by yom - 10.04.2008, 09:22
Re: /blindfold - by kavkazian - 10.04.2008, 10:11
Re: /blindfold - by Cactus - 10.04.2008, 10:34
Re: /blindfold - by yom - 10.04.2008, 11:18
Re: /blindfold - by Joe Staff - 10.04.2008, 12:12
Re: /blindfold - by yom - 10.04.2008, 12:16
Re: /blindfold - by Joe Staff - 10.04.2008, 12:21
Re: /blindfold - by kavkazian - 10.04.2008, 15:28
Re: /blindfold - by Qeux - 11.04.2009, 16:01
Re: /blindfold - by MenaceX^ - 11.04.2009, 16:28

Forum Jump:


Users browsing this thread: 1 Guest(s)