Raised This Month: $32 Target: $400
 8% 

ArrayFindString Issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConorCC
Member
Join Date: Feb 2014
Old 12-13-2021 , 17:26   ArrayFindString Issue
Reply With Quote #1

Hey There!

I just realized ArrayFindString will returns the index of the first occurence of the specified string. As it says in the documentation.

If you have an array like:
- de_dust2_long
- de_nuke

And you are looking for a string like:
- de_dust2

The function will returns 0 instead of -1. I know de_dust2 is part of de_dust2_long, but wouldn't be nice a 3rd param of the original function to search exact string or substing?

PHP Code:
ArrayFindStringEx(&Array: WhichszItem[], bExact 1) {

    if ( !
bExact )
        return 
ArrayFindString(WhichszItem);

    new 
szTmpItem[32], iArraySize ArraySize(Which);

    for ( new 
iiArraySize++ ) {

        
ArrayGetString(WhichiszTmpItemcharsmax(szTmpItem));

        if ( 
equal(szItemszTmpItem) )
            return 
i;
    }

    return -
1;

ConorCC is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-13-2021 , 22:05   Re: ArrayFindString Issue
Reply With Quote #2

This has been reported here but in the context of this being a bug of the original function. I personally agree with this being a bug for this function as opposed to a feature request to be added.
__________________
fysiks is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 12-14-2021 , 08:29   Re: ArrayFindString Issue
Reply With Quote #3

Check this out, it does the same thing but it compares every item from array.
https://forums.alliedmods.net/showth...=329651&page=2
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 12-14-2021 at 08:29.
Shadows Adi is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-14-2021 , 10:12   Re: ArrayFindString Issue
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
This has been reported here but in the context of this being a bug of the original function. I personally agree with this being a bug for this function as opposed to a feature request to be added.
I don't know if I would call it a bug, but it certainly is not intuitive. In the example provided by op, I would expect to get -1, not 0.
At this point, the functionality can not be changed(to keep backwards compatibility), but a new argument shoule be added to control how the string is matched.
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-14-2021 , 20:27   Re: ArrayFindString Issue
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
At this point, the functionality can not be changed(to keep backwards compatibility)
I certainly understand the argument but you could also argue that 1.9.0 has never actually been "released" and therefore people cant necessarily expect things not to change .
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-18-2021 , 08:19   Re: ArrayFindString Issue
Reply With Quote #6

And should include another argument for case sensitiveness. In its current state, there is no real use, you'd better just write a stock for searching strings.
__________________








CrazY. is offline
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 20:41.


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