strfind
#1

What's up with this code ?

pawn Код:
if(strfind(text, "brb", true) == 1)
    {
    afk[playerid] = 1;
    SendClientMessage(playerid,0xCC0000AA,"You are now in BRB mode.");
    }
Basically, when a player says "brb" in his chat line, he should gp into brb mode. But here, it doesn't. Anyway to fix ?
Reply
#2

You should put == 0 instead of == 1. It's the same as strcmp.

Leopard
Reply
#3

0 -> True
1 -> False
right ? I left scripting for a long time.
Reply
#4

Bump.!
Reply
#5

Ye.... but instead doing == 0 do !strfind(asdlask)
Reply
#6

Rafay false is 0, true is anything which isn't false.

@all:

Read this.
Reply
#7

I solved the problem using strcmp. Thanks anyway.
Reply
#8

I know, you've solved your problem, but there is another way:

Instead of
pawn Код:
if(strfind(text, "brb", true) == 1)
    {
    afk[playerid] = 1;
    SendClientMessage(playerid,0xCC0000AA,"You are now in BRB mode.");
    }
You should do
pawn Код:
if(strfind(text, "brb", true) != -1)
    {
    afk[playerid] = 1;
    SendClientMessage(playerid,0xCC0000AA,"You are now in BRB mode.");
    }
strfind returns -1 when it doesn't find the substring. Otherwise, it returns position of the substring in a string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)