AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Help with contain.. (https://forums.alliedmods.net/showthread.php?t=286823)

Adryyy 08-25-2016 16:18

[HELP] Help with contain..
 
What is != -1 after
Code:

containi(blabla1,"blabla2") != -1
Why is not just
Code:

containi(blabla1,"blabla2")

eyal282 08-25-2016 16:32

Re: [HELP] Help with contain..
 
From the string.inc const ( in amxmodx.inc )

/* Checks if source contains string. On success function
* returns position in source, on failure returns -1. */
native contain(const source[],const string[]);

Means that:

new A[10] = "BlahBlah"
new B[10] = "LAHLAH"

//contain(A, B) will return -1

// So if -1 != -1

if(contain(A, B)) != -1)
{
//Something will happen if A and B match.
}


Please correct me if I'm wrong ^_^

Adryyy 08-25-2016 16:42

Re: [HELP] Help with contain..
 
Thanks. If, i don't put != -1, what's happening? Will return with what i want?
Like:
if(contain(A, B))
{
//Something will happen if A and B match.
}

SpeeDeeR 08-25-2016 17:52

Re: [HELP] Help with contain..
 
Quote:

Originally Posted by Adryyy (Post 2448229)
Thanks. If, i don't put != -1, what's happening? Will return with what i want?
Like:
if(contain(A, B))
{
//Something will happen if A and B match.
}

No. if(contain(A, B)) means the answer is either positive or a negative number, i.e. != 0.
-1 means there is NO MATCH. Other than this (higher then -1) means it has a match.

Adryyy 08-25-2016 18:06

Re: [HELP] Help with contain..
 
Thanks.


All times are GMT -4. The time now is 03:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.