Command will always show number 1 when it has to raise - 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: Command will always show number 1 when it has to raise (
/showthread.php?tid=502051)
Command will always show number 1 when it has to raise -
Private200 - 22.03.2014
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.
Re: Command will always show number 1 when it has to raise -
Aerotactics - 22.03.2014
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;
}
Re: Command will always show number 1 when it has to raise -
Private200 - 22.03.2014
Yup, it works in-game but it shows 0 in the ConvoyIDs text.