Quick help, looping through saved names
#1

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++)
{
Reply
#2

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

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

Bump, please help i so want to learn this!
Reply
#5

Bump, anyone?..
Reply
#6

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 ?
Reply
#7

Use dini_Set, not dini_IntSet
Reply
#8

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

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

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
Reply
#11

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));
}
Reply
#12

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

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...
Reply
#14

and how to do that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)