Raised This Month: $ Target: $400
 0% 

[HELP] Help with contain..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Adryyy
Member
Join Date: Oct 2011
Old 08-25-2016 , 16:18   [HELP] Help with contain..
Reply With Quote #1

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

Last edited by Adryyy; 08-25-2016 at 16:18.
Adryyy is offline
Send a message via Yahoo to Adryyy Send a message via Skype™ to Adryyy
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-25-2016 , 16:32   Re: [HELP] Help with contain..
Reply With Quote #2

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 ^_^

Last edited by eyal282; 08-25-2016 at 16:40.
eyal282 is offline
Adryyy
Member
Join Date: Oct 2011
Old 08-25-2016 , 16:42   Re: [HELP] Help with contain..
Reply With Quote #3

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.
}

Last edited by Adryyy; 08-25-2016 at 16:44.
Adryyy is offline
Send a message via Yahoo to Adryyy Send a message via Skype™ to Adryyy
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-25-2016 , 17:52   Re: [HELP] Help with contain..
Reply With Quote #4

Quote:
Originally Posted by Adryyy View Post
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.

Last edited by SpeeDeeR; 08-25-2016 at 17:54.
SpeeDeeR is offline
Adryyy
Member
Join Date: Oct 2011
Old 08-25-2016 , 18:06   Re: [HELP] Help with contain..
Reply With Quote #5

Thanks.

Last edited by Adryyy; 08-26-2016 at 15:49.
Adryyy is offline
Send a message via Yahoo to Adryyy Send a message via Skype™ to Adryyy
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:43.


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