strfind
#1

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.
Reply
#2

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...
Reply
#3

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!
Reply
#4

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
Reply
#5

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!
Reply
#6

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)
Reply
#7

Which line is 1046
Reply
#8

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
Which line is 1046
pawn Код:
strdel(string, iStartPosition, iEndPosition); // line 1046
It's in the code above...
Reply
#9

remove 'const'
Reply
#10

Quote:
Originally Posted by Jefff
Посмотреть сообщение
remove 'const'
Oh wow, easy enough. Why didn't it like the "const"?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)