strfind -
Scenario - 18.01.2012
I want to use strfind in order to determine if a string has HEX color codes in it- that way I don't log the HEX codes. I know strfind returns the position of what I searched for (in this case, it would be an opening bracket ( { )). What if there are multiple values of the string I searched for (i.e. the opening bracket). Will it also return the position of those too?
If you have a better way to do this, please let me know.
Re: strfind -
[ABK]Antonio - 18.01.2012
hmm...this might not work...
pawn Код:
if(!sscanf(params, "h", something)) return SendClientMessage(playerid, -1, "You can't use hex!");
else if(sscanf(params, "somethinelse", something)) //im not sure if this would even work tbh...it probably wouldn't...
Re: strfind -
Scenario - 18.01.2012
That isn't really what I'm looking to do, sorry. However, is "h" a valid sscanf specifier?
EDIT: Oh nice, I never knew "h" was a valid sscanf specifier. Even though you didn't directly help me, it's good enough. Thanks!
Re: strfind -
[ABK]Antonio - 18.01.2012
Quote:
Originally Posted by RealCop228
That isn't really what I'm looking to do, sorry. However, is "h" a valid sscanf specifier?
|
It might be deprecated now..I got it from the wiki lol, says
h Hex number Colour
x Hex number Colour
Re: strfind -
Scenario - 18.01.2012
Quote:
Originally Posted by [ABK]Antonio
It might be deprecated now..I got it from the wiki lol, says
h Hex number Colour
x Hex number Colour
|
I checked the sscanf thread, it doesn't appear to be deprecated so I think I'm (we're?) in luck!
Thanks!
Re: strfind -
Scenario - 18.01.2012
Okay, so this is my command:
pawn Код:
stock sendAdminMessage(color, const string[])
{
foreach(new i : Player)
if(GetPVarInt(i, "ADMINLEVEL") > 0) SendClientMessage(i, color, string);
new szTmpString[9];
do
{
if(strfind(string, "{", true) != -1)
{
new iStartPosition = strfind(string, "{", true);
new iEndPosition = iStartPosition+8;
strdel(string, iStartPosition, iEndPosition); // line 1046
}
}
while(!sscanf(string, "h", szTmpString));
}
This is the error I'm getting:
Код:
(1046) : error 035: argument type mismatch (argument 1)
Re: strfind -
[ABK]Antonio - 18.01.2012
Which line is 1046
Re: strfind -
Scenario - 18.01.2012
Quote:
Originally Posted by [ABK]Antonio
Which line is 1046
|
pawn Код:
strdel(string, iStartPosition, iEndPosition); // line 1046
It's in the code above...
Re: strfind -
Jefff - 18.01.2012
remove 'const'
Re: strfind -
Scenario - 18.01.2012
Quote:
Originally Posted by Jefff
remove 'const'
|
Oh wow, easy enough. Why didn't it like the "const"?