SA-MP Forums Archive
Looping and returning multiple values with 1 function - 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: Looping and returning multiple values with 1 function (/showthread.php?tid=334902)



Looping and returning multiple values with 1 function - DBan - 16.04.2012

How can I loop files and return each identical value (in 1 string) with 1 function?

Here is my code:
pawn Код:
for(new i; i < MAX_FILES; i++)//Loop my files
{
    if(strcmp(FileInfo[i][Owner], GetName(playerid), true))//if the playerid's name is the files "Owner"
    {
        new biz[50];
        format(biz, sizeof(biz), "%s" FileInfo[i][Name]);
        //Store biz and continue loop to get the rest of the files Names? :S
    }
}



Re: Looping and returning multiple values with 1 function - [HiC]TheKiller - 16.04.2012

You would need all the file names of the files in a separate file because you cannot find all the file names in a directory using PAWN. The alternative is to create a plugin that does this for you.


Re: Looping and returning multiple values with 1 function - DBan - 16.04.2012

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
You would need all the file names of the files in a separate file because you cannot find all the file names in a directory using PAWN. The alternative is to create a plugin that does this for you.
Can you please show me an example with the plugin?

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
You would need all the file names of the files in a separate file
Then what if there is multiple names? How can I read them all (in one go) from the new file?


Re: Looping and returning multiple values with 1 function - DaRkM - 16.04.2012

As Killer knows I'm new to sscanf, but would it be possible to store all names in biz and then use sscanf to get the right name or something?
pawn Код:
new biz[500];
        format(biz, sizeof(biz), "%s %s", biz, FileInfo[i][Name]);
Just an idea.


Re: Looping and returning multiple values with 1 function - DBan - 16.04.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
If I understand you correctly, you want to store the owner in a file and then find all files owned by a person?
The owner(name) is stored in the file with the name(2nd value) is stored in that file, I want to get all the name/s(2nd values) from the files the owner(name) owns. :/