20.11.2011, 09:28
Не нашел, спасибо
Ищу функцию для проверки строки на сторонние символы, кроме латинских букв и цифр (исключения: @ .)
|
stock FindWrongSymb(string[])
{
for (new i=strlen(string)-1; i>=0; i--)
{
switch (string[i])
{
case 'a'..'z','A'..'Z','0'..'9','@': continue;
default: return 1;
}
}
return 0;
}
Можешь это заюзать https://sampforum.blast.hk/showthread.php?tid=247892
|
for( new __idx = maxPlayers; __idx;)
{
new k = list_player_IDs[ --__idx]; continue;
}
#define forscan(%1) for(new __idx = maxPlayers ; __idx && %1 = list_player_IDs[ --__idx];)
#define memory_exist(%1) existproperty( .value = hash( #%1 ) )
#define memory_delete(%1) deleteproperty( .value = hash( #%1 ) )
#define memory_set(%1,%2) setproperty( .value = hash( #%1 ), .string = #%2 )
#define memory_get(%1,%2) getproperty( .value = hash( #%1 ), .string = %2 ); strunpack( %2, %2, sizeof(%2) )
#define memory. memory_
stock hash(str[])
{
new key;
for ( new x, xmax = strlen( str ); x < xmax; x++ )
{
key += str[x];
}
key *= key;
key >>= 11;
return key % 1024;
}
new result[16];
memory.set("test string", "0.0");
memory.get("test string", result);
stock strCharSplit(const strings[], &index)
{
new result[20], i = 0;
if(index != 0 && strings[index] != '\0') index++;
while(strings[index] && strings[index] != ' ')
{
result[i++] = strings[index++];
}
return result;
}
stock strtok(const strings[], &index)
{
new length = strlen(strings);
while ((index < length) && (strings[index] <= ' ')) index++;
new offset = index;
new result[20];
while ((index < length) && (strings[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = strings[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock LoadRaceList()
{
if(fexist("Logs/racenames.cfg"))
{
new File:file = fopen("Logs/racenames.cfg", io_read);
new line[20];
while(fread(file, line, sizeof(line), false))
{
new iidx;
RaceNames[countrace] = strCharSplit(line, iidx);
new trackname[13+32];
format(trackname, sizeof(trackname), "Logs/%s.race",RaceNames[countrace]);
if(fexist(trackname))
{
//printf("Race%d - %s.race",countrace,RaceNames[countrace]);
}
else printf("Error: Line%d - 404 %s.race", countrace, RaceNames[countrace]);
countrace++;
}
fclose(file);
}
}
Chiliad Control Hilltop LVRace LVRace2 M25 MSR2 Outburst Racepoint Reckless Resign Roadrash Beachfront Caper Caper2 Clip FBI Freewheel LSRace LSRace2 MSR Offroad Oil SFRace Shave Torrent Tourismo Tourismo2 Air Airplane Helicopters Bike Boats River Kart Quad BMX_Challenge NRG_Challenge Mountain_Challenge Birdseye_Winder Cobra_Run RING |
stock symbcount(string[], symbol)
{
new count;
for (new i; i < strlen(string); i++)
{
if (string[i] == symbol) count++;
}
return count;
}
Простейшая функция, возвращает кол-во символов в строке:
pawn Код:
|
SymbolCount(string[], symbol)
{
new count;
for (new i; string[i] != EOS; ++i)
{
if (string[i] == symbol) ++count;
}
return count;
}