Pawno multidimensional array search
#1

Код:
enum anarraydata {id, something, somethingdifferent, and it goes...}; //look the id at beginning.
new anarray[200000][anarraydata];

stock multisearchbyid(myarr[][], findval, myarrsize = sizeof(myarr), isfound=0){ 
	for(new i=0; i<myarrsize; i++) {
		if(myarr[i][id] == findval) {  //there is a problem in here. id probably making an issue.
			isfound= i;
			break; 
		}
	}
	return isfound;
}
I wrote something like that but its not working. i really confused.
Reply
#2

Umm.. Are you calling this function some where?
This will only work for arrays that have id in it.
Reply
#3

Weird behavior. I don't know if this is a bug or something, but use the raw number instead.

PHP код:
new multi[20][abcd];

main() 
{
    
    new 
i;
    
    for(
0sizeof(multi); ++i)
    {
        
multi[i][id] = random(5);
        
multi[i][level] = random(5);
    }
    
    new 
random(20);
    new 
random(20);
    
    
multi[x][id] = 0;
    
multi[y][level] = 5;
    
    
MultiArray(multi,sizeof(multi),sizeof(multi[]));
    
    
multi[x][id] = 5;
    
multi[y][level] = 0;
    
    
MultiArray(multi,sizeof(multi),sizeof(multi[]));
    

PHP код:
stock MultiArray(arr[][],x,y)
{
    for(new 
ix; ++i)
    {
        for(new 
jy; ++j)
        {
            if(
arr[i][j] == 5)
            {
                
printf("5 is in [%d][%d]",i,j);
                return;
            }
        }
    }

Reply
#4

@arakuta you are the best. i wasnt know that i can call multi[qwerty] as multi[2] if qwerty is at 2th place in initialization. Thank you so much.

@DarkSkull I cant even compiling the code. But if you have a time you can try to run it. I believe its related pawno lang or my pawno studio.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)