SA-MP Forums Archive
save player money to txt on disconnect - 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: save player money to txt on disconnect (/showthread.php?tid=254358)



[Solved]save player money to txt on disconnect - jamesbond007 - 10.05.2011

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(PlayerInfo[playerid][Registered] == 1 && PlayerInfo[playerid][LoggedIn] == 1)
    {
        new pname[MAX_PLAYER_NAME], str[128];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(str, sizeof(str),"users/%s.txt",pname);
        //new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        if(fexist(str))
        {
            //SendClientMessageToAll(0xCCFF00,"exists");
            new string[128], string2[128], string3[128], MyVal[256], File:ftw = fopen(str,io_read);
            while(fread(ftw, string))
            {
                //SendClientMessageToAll(0xCCFF00,"reading file...");
                if(strcmp(string, "money: ", false, strlen("money: ")) == 0)
                {
                    MyVal[playerid]=GetVal(3, string);
                    format(string2,sizeof(string2),"%d",MyVal); // 0
                    format(string3,sizeof(string3),"%d",money); // 100
                    new string4[128];
                    strdel(string2, 0, strlen(string2));
                    SendClientMessageToAll(0xCCFF00,string5);
                    new func = strins(string2,string3,0);
                    format(string4,sizeof(string4),"string4: %d",func);
                    SendClientMessageToAll(0xCCFF00,string4);
                }
            }
        }
    }
return 1;
}
this returns 1 when it suppose to return 100?

im trying to replace the old string with the new string to save it in a text file someone pls help i cant figure this out ! its freakin annoying =/


Re: save player money to txt on disconnect - sim_sima - 10.05.2011

Why not use Dini?


Re: save player money to txt on disconnect - Zh3r0 - 10.05.2011

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
Why not use Dini?
You guys should stop guiding beginners to use the slowest writing/reading system!


Use Y_INI or DOF2 !


Re: save player money to txt on disconnect - Seven_of_Nine - 10.05.2011

Agreed, +1 for dini. Download it here.
If you've downloaded and put in the pawno / includes folder:
pawn Код:
#include <dini>
Then you can use
pawn Код:
dini_Create(file name); // to create files
dini_IntSet(file, name of Int, int) // to set integers in your file
dini_Set(file, name of string, string) // to set strings in your file
dini will return a great .ini file for you!


Re: save player money to txt on disconnect - jamesbond007 - 10.05.2011

is there anyway to use dini without a pawno server folder? if not then stop posting useless and help me out using only file functions .. dam im so tired of this shit even tho i made a nice register and login this way


Re: save player money to txt on disconnect - Zh3r0 - 10.05.2011

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
is there anyway to use dini without a pawno server folder? if not then stop posting useless and help me out using only file functions .. dam im so tired of this shit even tho i made a nice register and login this way
MySQL or SQLite. SA-MP has SQLite integrated, MySQL is a plugin!


Re: save player money to txt on disconnect - jamesbond007 - 10.05.2011

Problem solved thread locked


Re: save player money to txt on disconnect - sim_sima - 10.05.2011

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
MySQL or SQLite. SA-MP has SQLite integrated, MySQL is a plugin!
Yea, but MySQL is way too advanced for beginners, and it requires a MySQL server.


Re: save player money to txt on disconnect - jamesbond007 - 10.05.2011

ps im not a beginner

me : Oct 2009

you : Mar 2010

and also stop replying on threads that have already been solved -.-


Re: save player money to txt on disconnect - Zh3r0 - 10.05.2011

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
Yea, but MySQL is way too advanced for beginners, and it requires a MySQL server.
I was just giving an example, It's totally up to him if he wants to study the MySQL or not!


@james, Join date doesn't matter! It's all about how much you learned PAWN for the last years!