SA-MP Forums Archive
Dimi Isnt Saving File! - 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: Dimi Isnt Saving File! (/showthread.php?tid=267085)



Dimi Isnt Saving File! - HayZatic - 07.07.2011

Okay So Heres My Script.

Код:
public OnPlayerConnect(playerid)
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
    }
	return 1;
}
forward SaveAccounts(playerid); // Example Forward

public OnPlayerDisconnect(playerid, reason)
{

    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}
It Dosnt Save The File Why?


Re: Dimi Isnt Saving File! - Wesley221 - 07.07.2011

Did you create the file, did you create the folder in your scriptfolder?


Re: Dimi Isnt Saving File! - HayZatic - 07.07.2011

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
Did you create the file, did you create the folder in your scriptfolder?
Of Course i did


Re: Dimi Isnt Saving File! - Wesley221 - 07.07.2011

pawn Код:
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
Try this


Re: Dimi Isnt Saving File! - Shadoww5 - 07.07.2011

Show us this define: SERVER_USER_FILE.


Re: Dimi Isnt Saving File! - Gazmull - 07.07.2011

Did you put a Dini function for loading the file?


Re: Dimi Isnt Saving File! - HayZatic - 07.07.2011

Код:
#define SERVER_USER_FILE "HZadmin/Registration/%s.ini"



Re: Dimi Isnt Saving File! - HayZatic - 07.07.2011

Please Help!


Re: Dimi Isnt Saving File! - Steven82 - 07.07.2011

Create a custom function like this.

pawn Код:
forward SaveAccount(playerid);
public SaveAccount(playerid)
{
    new user[32];
    format(user, sizeof(user), "Users/%s.ini", GetPlayerNameEx(playerid));
    if(LoggedIn[playerid] == 1)
    {
        dini_IntSet(user, "AdminLevel", PlayerInfo[playerid][pAdminLevel]);
    }
    return 1;
}
Change that to your needs, but under OnPlayerDisconnect put this function "SaveAccount(playerid);" and it will work. I already posted a solution for people having trouble with this in Lorenc_'s topic but everyone just ignored me.

EDIT: Here is the GetPlayerNameEx stock. This thing works wonders.
pawn Код:
stock GetPlayerNameEx(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, pname, sizeof(pname));
    }
    else
        pname = "Unknow";
    return pname;
}



Re: Dimi Isnt Saving File! - Hipflop - 07.07.2011

This can be solved. I put my login script later on this topic. Now im gonna take a shower