Pawno multidimensional array search - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pawno multidimensional array search (
/showthread.php?tid=615739)
Pawno multidimensional array search -
godless_phoenix - 26.08.2016
Код:
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.
Re: Pawno multidimensional array search -
DarkSkull - 26.08.2016
Umm.. Are you calling this function some where?
This will only work for arrays that have id in it.
Re: Pawno multidimensional array search -
arakuta - 26.08.2016
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(i = 0; i < sizeof(multi); ++i)
{
multi[i][id] = random(5);
multi[i][level] = random(5);
}
new x = random(20);
new y = 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 i; i < x; ++i)
{
for(new j; j < y; ++j)
{
if(arr[i][j] == 5)
{
printf("5 is in [%d][%d]",i,j);
return;
}
}
}
}
Re: Pawno multidimensional array search -
godless_phoenix - 27.08.2016
@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.