Command will always show number 1 when it has to raise
#1

So I had problem with creating file but I figured it out (Thanks to Jakku). Well, now the problem is on the counting. I want it to count up, but for some reasons it will always count to 1.

This is the code I got.

pawn Код:
COMMAND:createconvoy(playerid, params[])
{
    new string[64], text[128], number[25];
    new File:convoys = fopen("ConvoyIDs.txt", io_read);
    if(convoys)
    {
        fread(convoys, string);
        format(number, sizeof(number), "%d", fread(convoys, string)+1);
        fwrite(convoys, number);
       
        PlayerInfo[playerid][pConvoy] = fread(convoys, string)+1;
       
        fclose(convoys);
       
        format(text, sizeof(text), "Convoy with ID %d has been created", fread(convoys, string)+1);
       
        print(text);
       

    }
    return 1;
}
Thanks in advance.
Reply
#2

Try something like this:

Not Tested.
pawn Код:
//somewhere at top of script
new Convoy = 0;

//Your command
COMMAND:createconvoy(playerid, params[])
{
    new string[64], text[128], number[25];
    new File:convoys = fopen("ConvoyIDs.txt", io_read);
    if(convoys)
    {
        Convoy++; //adds 1 each time
        fread(convoys, string);
        format(number, sizeof(number), "%d", Convoy);
        fwrite(convoys, number);
       
        PlayerInfo[playerid][pConvoy] = Convoy;
       
        fclose(convoys);
       
        format(text, sizeof(text), "Convoy with ID %d has been created", Convoy);
       
        print(text);
       

    }
    return 1;
}
Reply
#3

Yup, it works in-game but it shows 0 in the ConvoyIDs text.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)