AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved searching string inside another string (https://forums.alliedmods.net/showthread.php?t=319689)

riste.kgb 11-15-2019 05:47

searching string inside another string
 
Code:

if(strfind(data[Something], string) !== -1) {
return true;
} else {
return false;
}

It doesn't work.

Also contain, containi is not working properly. What's the point to exists these functions when they returns -1, and zero (which in if, while statements are false)

I want to search string inside another string, it can be 1 single char from that string or all strings.

equal and or equali will not work in my situation.

Code:

if(!(strfind(data[Something],string))
Will not work,because always returns 1 even if no string match
Tested it with !! too.

AMXXi is 1.8.2

edon1337 11-15-2019 05:50

Re: searching string inside another string
 
Quote:

Originally Posted by riste.kgb (Post 2673005)
Also contain, containi is not working properly. What's the point to exists these functions when they returns -1, and zero (which in if, while statements are false)

Check doc before posting.
Quote:

Return
-1 on failure (no match found). Any other value
You have to check != -1 to make sure that string1 is contained somewhere inside string2.

riste.kgb 11-15-2019 05:55

Re: searching string inside another string
 
Quote:

Originally Posted by edon1337 (Post 2673006)
Check doc before posting.


You have to check != -1 to make sure that string1 is contained somewhere inside the string2.

I know, i did that again but there is bug and it is not even checking.


Again not works i even did multiple checks
Code:

if(strfind(data[something],string) != -1) || !strfind(data[something,string) || strfind(data[something],string) > 0 ) {
return true
} else {
return false
}

Second checking if the result is 0 => which is false always

Natsheh 11-15-2019 05:55

Re: searching string inside another string
 
What ??? At least use the last amxx stable version which is 182 contain/i should return -1 on failure and greater than -1 on success

riste.kgb 11-15-2019 05:58

Re: searching string inside another string
 
Quote:

Originally Posted by Natsheh (Post 2673008)
What ??? At least use the last amxx stable version which is 182 contain/i should return -1 on failure and greater than -1 on success

I forgot it is 1.8.2 amxx version, and this is bugged.

functions:

strfind()
contain()
containi()

Natsheh 11-15-2019 06:05

Re: searching string inside another string
 
If it is bugged it would be already fixed on v182 I had never experienced any problem using them..

riste.kgb 11-15-2019 06:07

Re: searching string inside another string
 
Quote:

Originally Posted by Natsheh (Post 2673011)
If it is bugged it would be already fixed on v182 I had never experienced any problem using them..

I experienced it right now.

OciXCrom 11-15-2019 07:24

Re: searching string inside another string
 
Please show the full code. You're obviously doing something wrong.

PHP Code:

if(strfind(wherewhat) != -1

PHP Code:

if(contain(wherewhat) != -1

PHP Code:

if(containi(wherewhat) != -1


riste.kgb 11-15-2019 08:19

Re: searching string inside another string
 
Quote:

Originally Posted by OciXCrom (Post 2673017)
Please show the full code. You're obviously doing something wrong.

PHP Code:

if(strfind(wherewhat) != -1

PHP Code:

if(contain(wherewhat) != -1

PHP Code:

if(containi(wherewhat) != -1



I've checked first how i put in array the flags then i see that it was wrong in native, i forgot to add
param_convert(5), and there it happens that bug. So now it's fixed.

It appears that is not a bug with function strfind.

I fixed this problem. Thank you guys for assisting in the thread.


All times are GMT -4. The time now is 02:44.

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