SA-MP Forums Archive
Quick help, looping through saved names - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Quick help, looping through saved names (/showthread.php?tid=187016)



Quick help, looping through saved names(files) [NOT SOLVED PLEASE HELP] - 0ne - 31.10.2010

Alright, i need help, can't figure out a way to loop through the names and check a variable in it, i save the names like this:

pawn Код:
format(gangfile, 128, "Gangs/%s.ini", format(gangNames[gangnum], MAX_GANG_NAME, "%s", params));
Dunno if its right, correct me if im wrong.

trying toread like this

pawn Код:
if(dini_Int("Gangs/%s.ini","Members") < MAX_GANG_MEMBERS)
but thats definately wrong, please some help..

EDIT: "i" is defined like this:

for(new i = 1; i < MAX_GANGS; i++)
{


Re: Quick help, looping through saved names - Jefff - 31.10.2010

1
pawn Код:
format(gangNames[gangnum], MAX_GANG_NAME, "%s", params);
format(gangfile, 128, "Gangs/%s.ini",gangNames[gangnum]);



Re: Quick help, looping through saved names - 0ne - 31.10.2010

Thank you, anyone knows solution to the 2nd problem?


Re: Quick help, looping through saved names - 0ne - 01.11.2010

Bump, please help i so want to learn this!


Re: Quick help, looping through saved names - 0ne - 02.11.2010

Bump, anyone?..


Re: Quick help, looping through saved names - 0ne - 03.11.2010

Help please!

P.S doesn't let me save his name like this:

pawn Код:
for(new ig = 6; ig > 6; ig--)
            {
                format(string, 24, "Member%d", ig);
                dini_IntSet(gangfile, string, pName(playerid));
            }
Argument type mismatch?
And how could i delete his name from file ?


Re: Quick help, looping through saved names - LarzI - 03.11.2010

Use dini_Set, not dini_IntSet


Re: Quick help, looping through saved names - 0ne - 03.11.2010

That worked, but it doesn't write his name to the file


Re: Quick help, looping through saved names - Miguel - 03.11.2010

pawn Код:
for(new ig = 0; ig < 6; ig +)
{
    format(string, 24, "Member%d", ig);
    dini_IntSet(gangfile, string, pName(playerid));
}



Re: Quick help, looping through saved names - 0ne - 03.11.2010

Why change -- to ++? i mean there are max 6members, and after 1joins it does -- for 5numbers only to be available ex: member5,4,3,2,1


Re: Quick help, looping through saved names - Miguel - 03.11.2010

Let's see what you did:
pawn Код:
for(new ig = 6; ig > 6; ig--)
{
    format(string, 24, "Member%d", ig);
    dini_IntSet(gangfile, string, pName(playerid));
}
You created a variable and you set it to 6; then if the variable was greater than 6 (that has no sense); subtract 1 to the variable. What was the problem then? The problem was that the variable was never going to be greater than six, because it would start at 6 and then 5, 4, 3, 2, 1, 0, -1, -2, etc.

Maybe:
pawn Код:
for(new ig = 6; ig > 0; ig--) // It will go from 6 to 0.
{
    format(string, 24, "Member%d", ig);
    dini_IntSet(gangfile, string, pName(playerid));
}



Re: Quick help, looping through saved names - 0ne - 03.11.2010

Alright now it's good but 1problem that it writes member1,2,3,4,5,6 and all goes by my name :S


Re: Quick help, looping through saved names - Miguel - 03.11.2010

Because you're using "playerid" and not a variable storing that gang's member ID. You will have to find out which ID is x member.

pawn Код:
dini_IntSet(gangfile, string, pName(playerid)); // playerid there is wrong...



Re: Quick help, looping through saved names - 0ne - 04.11.2010

and how to do that?