Using strfind wrong?
#1

I don't know why but it also allows other players to use the clan chat here is example how i use strfind

pawn Код:
if(strfind(GetpName(playerid), "[iP]", true))
but still other players (even without [iP] tag) can use the clan chat.

Note: this was proof 100% when i use another user name like 'Rock' etc...

so tell me guys i'm using strfind wrong?
Reply
#2

I am not sure (I also don't know strfind very well). If you change 'true' to 'false', will it be fixed (because a long time ago I used 'false', not 'true')?
Reply
#3

nope it didn't work
Reply
#4

I found it in my script, try this one:

Код:
if(strfind(GetpName(playerid),"[iP]", true) != -1)
Reply
#5

Guys, first use the wiki than pawn-lang.pdf (or the impl guide if needed) than the search function and AT LAST post a topic...

Quote:
Returns
The number of characters before the sub string (the sub string's start position) or -1 if it's not found.
After knowing that, Libra_PL version is correct
Reply
#6

Quote:
Originally Posted by Wiki
Returns The number of characters before the sub string (the sub string's start position) or -1 if it's not found.
Use this:
pawn Код:
if(strfind(GetpName(playerid), "[iP]", false) != -1)
Basically what made it not work is it returned 0 as there are no characters before the [iP] when you made it check a name.
It should be set to false so it someone has the tag [ip] or [Ip] he won't be able to talk on the clan chat neither.

To even make this more accurate use the following:
pawn Код:
if(!strfind(GetpName(playerid), "[iP]", false))
This will make it ONLY work if the player has [iP] before his name, example: "[iP]iRage".
It won't work if a player has [iP] anywhere else in his name, example: "iRa[iP]ge" or "iRage[iP]".
Reply
#7

Quote:
Originally Posted by iRage
Посмотреть сообщение
Use this:
pawn Код:
if(strfind(GetpName(playerid), "[iP]", false) != -1)
Basically what made it not work is it returned 0 as there are no characters before the [iP] when you made it check a name.
It should be set to false so it someone has the tag [ip] or [Ip] he won't be able to talk on the clan chat neither.

To even make this more accurate use the following:
pawn Код:
if(!strfind(GetpName(playerid), "[iP]", false))
This will make it ONLY work if the player has [iP] before his name, example: "[iP]iRage".
It won't work if a player has [iP] anywhere else in his name, example: "iRa[iP]ge" or "iRage[iP]".
In this case use strcmp because its faster

pawn Код:
if(!strcmp(GetpName(playerid), "[iP]", false, 4)) {}
Reply
#8

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
In this case use strcmp because its faster

pawn Код:
if(!strcmp(GetpName(playerid), "[iP]", false, 4)) {}
That would work too.
Anyways have you tested both and came up with your speed results or...?
Reply
#9

Thanks everyone it is working now thx to you iRage rep+ for you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)