SA-MP Forums Archive
Hel with adding to variable and saving it - 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: Hel with adding to variable and saving it (/showthread.php?tid=452039)



Hel with adding to variable and saving it - Zigonja - 19.07.2013

I want to do that each time player writes /payborder 500 adds to the file, but what happens is it allways stays 500 even if I do it multiple times.

Thanks in advance

pawn Код:
if(!strcmp(cmd, "/payborder"))
    {
        if(canopen == 1)
        {
            new File:ftw=fopen("armymoneycollect.txt", io_write);
            new empety;
            new string[256];
            if(IsPlayerInRangeOfPoint(playerid, 8, 631.2999900,-1193.0000000,19.3000000))
            {
                MoveDynamicObject(tunnel, 631.2999900,-1193.0000000, 14.89999961853, 5);
                SendClientMessage(playerid, COLOR_BLUE,"* Border Sucessfully opened, closing in 5 seconds!");
                SetTimer("tunnelc", 5000, false);
                GivePlayerMoney(playerid, -500);
                empety += 500;
                format(string,sizeof(string),"%d", empety);
                SendClientMessage(playerid, -1, string);
                if(ftw)
                {
                    fread(ftw, string);
                    format(string,sizeof(string),"%d", empety);
                    fwrite(ftw, string);
                    fclose(ftw);
                }
            }



Re: Hel with adding to variable and saving it - arakuta - 20.07.2013

You are just setting 500.

You should read, get, then add 500 to the obtained value, then save.


Re: Hel with adding to variable and saving it - Zigonja - 20.07.2013

thanks to both but the thing is that the server im scriptong for isn't using y_ini.
So how can read the fule and then add to it? pr is there a way to stock y_ini?


Re: Hel with adding to variable and saving it - Zigonja - 20.07.2013

I know about including it, but they don't have it, im not scripting for myself