save player money to txt on disconnect
#1

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 =/
Reply
#2

Why not use Dini?
Reply
#3

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 !
Reply
#4

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!
Reply
#5

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

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

Problem solved thread locked
Reply
#8

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

ps im not a beginner

me : Oct 2009

you : Mar 2010

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

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)