[help] strfind + sscanf.
#10

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by ¤Adas¤
Errors? Then your compiler is dumb.
No, you're not giving him the functions needed for this.
Oh, I am so sorry! I hope, here are all functions already.

pawn Код:
stock GetCharsCount(const string[], ...)
{
new Count, num = numargs();
for(new n = 1; n<num; n++) for(new i; i<strlen(string); i++) if(getarg(n, 0) && string[i] == getarg(n, 0)) Count++;
return Count;
}

stock GetNumericCharsCount(const string[]) return GetCharsCount(string, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57);

stock bool:IsNumericChar(character) return character > 46 && character < 58;

stock bool:IsNumeric(const string[]) return GetNumericCharsCount(string) == strlen(string);

stock bool:GetNumericPartOfString(const string[], output[], &index)
{
new lenght = strlen(string);
if(!lenght || !GetNumericCharsCount(string)) return false;
while(index < lenght && !IsNumericChar(string[index])) index++;
new offset = index;
while(index < lenght && IsNumericChar(string[index])) output[index - offset] = string[index], index++;
return true;
}

stock GetPlayerID(const name[], bool:ignorecase = false)
{
new output[5], index;
for(new i; i<GetMaxPlayers(); i++) if(IsPlayerConnected(i)) if(strfind(Name(i), name, ignorecase) != -1) return i;
if(IsNumeric(name) && IsPlayerConnected(strval(name))) return strval(name);
if(GetNumericPartOfString(name, output, index) && IsPlayerConnected(strval(output))) return strval(output);
return INVALID_PLAYER_ID;
}
Reply


Messages In This Thread
[help] strfind + sscanf. - by Martin_M - 06.03.2010, 16:29
Re: [help] strfind + sscanf. - by ¤Adas¤ - 06.03.2010, 16:36
Re: [help] strfind + sscanf. - by Martin_M - 06.03.2010, 16:41
Re: [help] strfind + sscanf. - by ¤Adas¤ - 06.03.2010, 16:47
Re: [help] strfind + sscanf. - by Martin_M - 06.03.2010, 17:02
Re: [help] strfind + sscanf. - by Martin_M - 06.03.2010, 17:47
Re: [help] strfind + sscanf. - by ¤Adas¤ - 06.03.2010, 17:49
Re: [help] strfind + sscanf. - by Martin_M - 06.03.2010, 18:47
Re: [help] strfind + sscanf. - by ¤Adas¤ - 06.03.2010, 18:49
Re: [help] strfind + sscanf. - by ¤Adas¤ - 06.03.2010, 19:31

Forum Jump:


Users browsing this thread: 5 Guest(s)