{ffffff}Ez egy fehér hex kódos szöveg.
Ez egy fehér hex kódos szöveg.
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
stock RemoveHexColorFromString(string[],startpos = 0)
{
new
pos[2];
pos[0] = strfind(string,\"{\",true,startpos);
pos[1] = strfind(string,\"}\",true,startpos);
while(pos[0]+7 == pos[1])
{
strdel(string, pos[0], pos[1]+1);
pos[0] = strfind(string,\"{\",true,startpos);
pos[1] = strfind(string,\"}\",true,startpos);
}
return 1;
}
main() {}
public OnGameModeInit()
{
new str[] = \"Ez a fehér hex: {ffffff}\";
print(str);
RemoveHexColorFromString(str);
print(str);
new str2[] = \"{ffffff}Ez a fehér hex: {ffffff}-< Meg ez is.{fffffff}\";
print(str2);
RemoveHexColorFromString(str2);
print(str2);
new str3[] = \"{ffffff}Ez a startpos teszt: {ffffff}-< Meg ez is.{fffffff}\";
print(str3);
RemoveHexColorFromString(str3,8);
print(str3);
return 1;
}
stock RemoveHexColorFromString(string[],startpos = 0)
{
new
pos[2];
pos[0] = strfind(string,\"{\",true,startpos);
pos[1] = strfind(string,\"}\",true,startpos);
while(pos[0]+7 == pos[1])
{
strdel(string, pos[0], pos[1]+1);
pos[0] = strfind(string,\"{\",true,startpos);
pos[1] = strfind(string,\"}\",true,startpos);
}
return 1;
}
Nem rossz, bár szerintem \"do while\" ciklussal egyszerûbben meglehet írni.Ha sokan panaszkodnak rá, átírom, mondjuk szerintem olyan nagy szintû eltérés nincs :)
stock RemoveHexColorFromString(string[], startpos = 0)
{
new pos[2];
while(((pos[0] = strfind(string, \"{\", .pos = startpos)) + 7) == (pos[1] = strfind(string, \"}\", .pos = startpos)))
strdel(string, pos[0], pos[1]+1);
return 1;
}
Kész. Remélem így gondoltad :DNem.
(Ennél azért nehezebb kell, hogy sok idõt töltsek vele el :D)
Ha nem gond, leegyszerûsítettem:
stock RemoveHexColorFromString(string[], startpos = 0)
{
new pos[2];
while(((pos[0] = strfind(string, \"{\", .pos = startpos)) + 7) == (pos[1] = strfind(string, \"}\", .pos = startpos)))
strdel(string, pos[0], pos[1]+1);
return 1;
}
[/quote]
Nem.
Kész. Remélem így gondoltad :D
(Ennél azért nehezebb kell, hogy sok idõt töltsek vele el :D)
Hanem valami ilyesmire gondoltam: :D
Ha nem gond, leegyszerûsítettem:
stock RemoveHexColorFromString(string[], startpos = 0)
{
new pos[2];
while(((pos[0] = strfind(string, \"{\", .pos = startpos)) + 7) == (pos[1] = strfind(string, \"}\", .pos = startpos)))
strdel(string, pos[0], pos[1]+1);
return 1;
}
[/quote]
[/quote]
A lényege ugyan az, csak egy sorba be lett sûrítve :D
Ha nem gond, leegyszerûsítettem:
stock RemoveHexColorFromString(string[], startpos = 0)
{
new pos[2];
while(((pos[0] = strfind(string, \"{\", .pos = startpos)) + 7) == (pos[1] = strfind(string, \"}\", .pos = startpos)))
strdel(string, pos[0], pos[1]+1);
return 1;
}
[/quote]
Köszi, kinek mi átláthatóbb :)
\"{ffffff}Ez a fehér hex: {ffffff}-< Meg ez is.{fffffff}\";[/quote]
Az utolsó {ffffff}-t nem törli.
@DrAkE
Persze mûködõ képes változatra gondoltam. :angel:
Edit:
Ennél:
\"{ffffff}Ez a fehér hex: {ffffff}-< Meg ez is.{fffffff}\";Az utolsó {ffffff}-t nem törli.
[/quote]
Direkt, ugyanis az nem mûködõképes Hex kód. (7 betû van 6 helyet)
stock
RemoveHexColorFromString(str[], start = 0)
{
new
i = start;
while(str)
{
if(str == \'{\' && str[i + 7] == \'}\')
{
strdel(str, i, i + 8);
}
i++;
}
return 1;
}
stock
RemoveHexColorFromString(str[], i = 0)
{
while(str) if(str[i++] == \'{\' && str[i + 6] == \'}\') strdel(str, i - 1, i + 7);
}
stock
RemoveHexColorFromString(str[], i = 0)
{
new
pos,
lenght = strlen(str);
while(i + pos < lenght)
{
if(str[i + pos] == \'{\' && str[i + pos + 7] == \'}\') pos += 8;
str = str[i + pos];
i++;
}
str = EOS;
}