SA-MP Forums Archive
Script not calling loadaccount? - 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: Script not calling loadaccount? (/showthread.php?tid=561793)



Script not calling loadaccount? - supernerd2000 - 05.02.2015

Hey guys, basically for some reason my GM refuses to call my loadaccount function. I have double checked and it is saving properly. If you'll notice I made it so it prints to the console whenever it loads data, the user logs in, or the user disconnects. Everything is being shown on the console except for data loading. And again the save files look fine. It is just account loading.

Code:
pawn Код:
enum PlayerInfo
{
    Pass[129],
    Adminlevel,
    VIPlevel,
    Money,
    Scores,
    Kills,
    Deaths,
    Logged,
    Color,
    Skin,
    GodEnabled,
    CustomSlot0,
    CustomSlot1,
    CustomSlot2,
    CustomSlot3,
    CustomSlot4,
    CustomSlot5,
    CustomSlot6,
    CustomSlot7,
    CustomSlot8,
    CustomSlot9,
    CustomSlot10,
    CustomSlot11,
    CustomSlot0a,
    CustomSlot1a,
    CustomSlot2a,
    CustomSlot3a,
    CustomSlot4a,
    CustomSlot5a,
    CustomSlot6a,
    CustomSlot7a,
    CustomSlot8a,
    CustomSlot9a,
    CustomSlot10a,
    CustomSlot11a,
    isAFK,
    Muted,
    Float:POS_X,
    Float:POS_Y,
    Float:POS_Z
}
new pInfo[MAX_PLAYERS][PlayerInfo];

stock Path(playerid)
{
    new
        string[128],
        name[MAX_PLAYER_NAME]
    ;
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),UserPath,name);
    return string;
}

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(fexist(Path(playerid)))
    {
        INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
    }
    return 1;
}

    if(dialogid == dregister)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                return 1;
            }
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"AdminLevel",0);
            INI_WriteInt(file,"VIPLevel",0);
            INI_WriteInt(file,"Money",0);
            INI_WriteInt(file,"Scores",0);
            INI_WriteInt(file,"Kills",0);
            INI_WriteInt(file,"Deaths",0);
            INI_WriteInt(file,"Color",COLOR_WHITE);
            INI_WriteInt(file,"Skin",162);
            INI_WriteInt(file,"GodEnabled",0);
            INI_WriteInt(file,"isAFK",0);
            INI_WriteInt(file,"Muted",0);
            INI_WriteInt(file,"GodEnabled",0);
            INI_WriteInt(file,"isAFK",0);
            INI_WriteInt(file,"Muted",0);
            INI_WriteInt(file,"CustomSlot0",0);
            INI_WriteInt(file,"CustomSlot0a",0);
            INI_WriteInt(file,"CustomSlot1",0);
            INI_WriteInt(file,"CustomSlot1a",0);
            INI_WriteInt(file,"CustomSlot2",0);
            INI_WriteInt(file,"CustomSlot2a",0);
            INI_WriteInt(file,"CustomSlot3",0);
            INI_WriteInt(file,"CustomSlot3a",0);
            INI_WriteInt(file,"CustomSlot4",0);
            INI_WriteInt(file,"CustomSlot4a",0);
            INI_WriteInt(file,"CustomSlot5",0);
            INI_WriteInt(file,"CustomSlot5a",0);
            INI_WriteInt(file,"CustomSlot6",0);
            INI_WriteInt(file,"CustomSlot6a",0);
            INI_WriteInt(file,"CustomSlot7",0);
            INI_WriteInt(file,"CustomSlot7a",0);
            INI_WriteInt(file,"CustomSlot8",0);
            INI_WriteInt(file,"CustomSlot8a",0);
            INI_WriteInt(file,"CustomSlot9",0);
            INI_WriteInt(file,"CustomSlot9a",0);
            INI_WriteInt(file,"CustomSlot10",0);
            INI_WriteInt(file,"CustomSlot10a",0);
            INI_WriteInt(file,"CustomSlot11",0);
            INI_WriteInt(file,"CustomSlot11a",0);
            INI_WriteFloat(file,"POS_X",2506.0935);
            INI_WriteFloat(file,"POS_Y",-1672.0536);
            INI_WriteFloat(file,"POS_Z",13.3714);
            INI_Close(file);
            return 1;
        }
    }
    if(dialogid == dlogin)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass, pInfo[playerid][Pass], false))
            {
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                pInfo[playerid][Logged] = 1;
                GivePlayerMoney(playerid, pInfo[playerid][Money]);
                SetPlayerPos(playerid, pInfo[playerid][POS_X], pInfo[playerid][POS_Y], pInfo[playerid][POS_Z]);
                SetPlayerSkin(playerid, pInfo[playerid][Skin]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot0], pInfo[playerid][CustomSlot0a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot1], pInfo[playerid][CustomSlot1a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot2], pInfo[playerid][CustomSlot2a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot3], pInfo[playerid][CustomSlot3a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot4], pInfo[playerid][CustomSlot4a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot5], pInfo[playerid][CustomSlot5a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot6], pInfo[playerid][CustomSlot6a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot7], pInfo[playerid][CustomSlot7a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot8], pInfo[playerid][CustomSlot8a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot9], pInfo[playerid][CustomSlot9a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot10], pInfo[playerid][CustomSlot10a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot11], pInfo[playerid][CustomSlot11a]);
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
                print("User logged in.");
            }
            else
            {
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
            }
            return 1;
        }
    }
    return 1;
}

forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password",pInfo[playerid][Pass],129);
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
    INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);
    INI_Int("Money",pInfo[playerid][Money]);
    INI_Int("Scores",pInfo[playerid][Scores]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("Color",pInfo[playerid][Color]);
    INI_Int("Skin",pInfo[playerid][Skin]);
    INI_Int("GodEnabled",pInfo[playerid][GodEnabled]);
    INI_Int("CustomSlot0",pInfo[playerid][CustomSlot0]);
    INI_Int("CustomSlot1",pInfo[playerid][CustomSlot1]);
    INI_Int("CustomSlot2",pInfo[playerid][CustomSlot2]);
    INI_Int("CustomSlot3",pInfo[playerid][CustomSlot3]);
    INI_Int("CustomSlot4",pInfo[playerid][CustomSlot4]);
    INI_Int("CustomSlot5",pInfo[playerid][CustomSlot5]);
    INI_Int("CustomSlot6",pInfo[playerid][CustomSlot6]);
    INI_Int("CustomSlot7",pInfo[playerid][CustomSlot7]);
    INI_Int("CustomSlot8",pInfo[playerid][CustomSlot8]);
    INI_Int("CustomSlot9",pInfo[playerid][CustomSlot9]);
    INI_Int("CustomSlot10",pInfo[playerid][CustomSlot10]);
    INI_Int("CustomSlot11",pInfo[playerid][CustomSlot11]);
    INI_Int("CustomSlot0a",pInfo[playerid][CustomSlot0a]);
    INI_Int("CustomSlot1a",pInfo[playerid][CustomSlot1a]);
    INI_Int("CustomSlot2a",pInfo[playerid][CustomSlot2a]);
    INI_Int("CustomSlot3a",pInfo[playerid][CustomSlot3a]);
    INI_Int("CustomSlot4a",pInfo[playerid][CustomSlot4a]);
    INI_Int("CustomSlot5a",pInfo[playerid][CustomSlot5a]);
    INI_Int("CustomSlot6a",pInfo[playerid][CustomSlot6a]);
    INI_Int("CustomSlot7a",pInfo[playerid][CustomSlot7a]);
    INI_Int("CustomSlot8a",pInfo[playerid][CustomSlot8a]);
    INI_Int("CustomSlot9a",pInfo[playerid][CustomSlot9a]);
    INI_Int("CustomSlot10a",pInfo[playerid][CustomSlot10a]);
    INI_Int("CustomSlot11a",pInfo[playerid][CustomSlot11a]);
    INI_Int("isAFK",pInfo[playerid][isAFK]);
    INI_Int("Muted",pInfo[playerid][Muted]);
    INI_Float("POS_X",pInfo[playerid][POS_X]);
    INI_Float("POS_Y",pInfo[playerid][POS_Y]);
    INI_Float("POS_Z",pInfo[playerid][POS_Z]);
    print("Account Data Loaded.");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    pInfo[playerid][Logged] = 0;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    pInfo[playerid][POS_X] = Float:x;
    pInfo[playerid][POS_Y] = Float:y;
    pInfo[playerid][POS_Z] = Float:z;
    new INI:file = INI_Open(Path(playerid));
    INI_SetTag(file,"User");
    INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
    INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
    INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
    INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
    INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
    INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
    INI_WriteInt(file,"Logged",pInfo[playerid][Logged]);
    INI_WriteInt(file,"Color",pInfo[playerid][Color]);
    INI_WriteInt(file,"Skin",pInfo[playerid][Skin]);
    INI_WriteInt(file,"CustomSlot0",pInfo[playerid][CustomSlot0]);
    INI_WriteInt(file,"CustomSlot0a",pInfo[playerid][CustomSlot0a]);
    INI_WriteInt(file,"CustomSlot1",pInfo[playerid][CustomSlot1]);
    INI_WriteInt(file,"CustomSlot1a",pInfo[playerid][CustomSlot1a]);
    INI_WriteInt(file,"CustomSlot2",pInfo[playerid][CustomSlot2]);
    INI_WriteInt(file,"CustomSlot2a",pInfo[playerid][CustomSlot2a]);
    INI_WriteInt(file,"CustomSlot3",pInfo[playerid][CustomSlot3]);
    INI_WriteInt(file,"CustomSlot3a",pInfo[playerid][CustomSlot3a]);
    INI_WriteInt(file,"CustomSlot4",pInfo[playerid][CustomSlot4]);
    INI_WriteInt(file,"CustomSlot4a",pInfo[playerid][CustomSlot4a]);
    INI_WriteInt(file,"CustomSlot5",pInfo[playerid][CustomSlot5]);
    INI_WriteInt(file,"CustomSlot5a",pInfo[playerid][CustomSlot5a]);
    INI_WriteInt(file,"CustomSlot6",pInfo[playerid][CustomSlot6]);
    INI_WriteInt(file,"CustomSlot6a",pInfo[playerid][CustomSlot6a]);
    INI_WriteInt(file,"CustomSlot7",pInfo[playerid][CustomSlot7]);
    INI_WriteInt(file,"CustomSlot7a",pInfo[playerid][CustomSlot7a]);
    INI_WriteInt(file,"CustomSlot8",pInfo[playerid][CustomSlot8]);
    INI_WriteInt(file,"CustomSlot8a",pInfo[playerid][CustomSlot8a]);
    INI_WriteInt(file,"CustomSlot9",pInfo[playerid][CustomSlot9]);
    INI_WriteInt(file,"CustomSlot9a",pInfo[playerid][CustomSlot9a]);
    INI_WriteInt(file,"CustomSlot10",pInfo[playerid][CustomSlot10]);
    INI_WriteInt(file,"CustomSlot10a",pInfo[playerid][CustomSlot10a]);
    INI_WriteInt(file,"CustomSlot11",pInfo[playerid][CustomSlot11]);
    INI_WriteInt(file,"CustomSlot11a",pInfo[playerid][CustomSlot11a]);
    INI_WriteFloat(file,"POS_X",pInfo[playerid][Float:POS_X]);
    INI_WriteFloat(file,"POS_Y",pInfo[playerid][Float:POS_Y]);
    INI_WriteFloat(file,"POS_Z",pInfo[playerid][Float:POS_Z]);
    print("Account Data Saved. User disconnected.");
    INI_Close(file);
    return 1;
}
Thanks in advance for any help I receive.


Respuesta: Script not calling loadaccount? - !R1Ch@rD! - 05.02.2015

you either have this function because I see you have it in OnPlayerConnect and goes OnDialogResponse

pawn Код:
if(dialogid == dregister)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                return 1;
            }
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"AdminLevel",0);
            INI_WriteInt(file,"VIPLevel",0);
            INI_WriteInt(file,"Money",0);
            INI_WriteInt(file,"Scores",0);
            INI_WriteInt(file,"Kills",0);
            INI_WriteInt(file,"Deaths",0);
            INI_WriteInt(file,"Color",COLOR_WHITE);
            INI_WriteInt(file,"Skin",162);
            INI_WriteInt(file,"GodEnabled",0);
            INI_WriteInt(file,"isAFK",0);
            INI_WriteInt(file,"Muted",0);
            INI_WriteInt(file,"GodEnabled",0);
            INI_WriteInt(file,"isAFK",0);
            INI_WriteInt(file,"Muted",0);
            INI_WriteInt(file,"CustomSlot0",0);
            INI_WriteInt(file,"CustomSlot0a",0);
            INI_WriteInt(file,"CustomSlot1",0);
            INI_WriteInt(file,"CustomSlot1a",0);
            INI_WriteInt(file,"CustomSlot2",0);
            INI_WriteInt(file,"CustomSlot2a",0);
            INI_WriteInt(file,"CustomSlot3",0);
            INI_WriteInt(file,"CustomSlot3a",0);
            INI_WriteInt(file,"CustomSlot4",0);
            INI_WriteInt(file,"CustomSlot4a",0);
            INI_WriteInt(file,"CustomSlot5",0);
            INI_WriteInt(file,"CustomSlot5a",0);
            INI_WriteInt(file,"CustomSlot6",0);
            INI_WriteInt(file,"CustomSlot6a",0);
            INI_WriteInt(file,"CustomSlot7",0);
            INI_WriteInt(file,"CustomSlot7a",0);
            INI_WriteInt(file,"CustomSlot8",0);
            INI_WriteInt(file,"CustomSlot8a",0);
            INI_WriteInt(file,"CustomSlot9",0);
            INI_WriteInt(file,"CustomSlot9a",0);
            INI_WriteInt(file,"CustomSlot10",0);
            INI_WriteInt(file,"CustomSlot10a",0);
            INI_WriteInt(file,"CustomSlot11",0);
            INI_WriteInt(file,"CustomSlot11a",0);
            INI_WriteFloat(file,"POS_X",2506.0935);
            INI_WriteFloat(file,"POS_Y",-1672.0536);
            INI_WriteFloat(file,"POS_Z",13.3714);
            INI_Close(file);
            return 1;
        }
    }
    if(dialogid == dlogin)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass, pInfo[playerid][Pass], false))
            {
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                pInfo[playerid][Logged] = 1;
                GivePlayerMoney(playerid, pInfo[playerid][Money]);
                SetPlayerPos(playerid, pInfo[playerid][POS_X], pInfo[playerid][POS_Y], pInfo[playerid][POS_Z]);
                SetPlayerSkin(playerid, pInfo[playerid][Skin]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot0], pInfo[playerid][CustomSlot0a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot1], pInfo[playerid][CustomSlot1a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot2], pInfo[playerid][CustomSlot2a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot3], pInfo[playerid][CustomSlot3a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot4], pInfo[playerid][CustomSlot4a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot5], pInfo[playerid][CustomSlot5a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot6], pInfo[playerid][CustomSlot6a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot7], pInfo[playerid][CustomSlot7a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot8], pInfo[playerid][CustomSlot8a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot9], pInfo[playerid][CustomSlot9a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot10], pInfo[playerid][CustomSlot10a]);
                GivePlayerWeapon(playerid, pInfo[playerid][CustomSlot11], pInfo[playerid][CustomSlot11a]);
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
                print("User logged in.");
            }
            else
            {
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
            }
            return 1;
        }
    }
    return 1;
}



Re: Script not calling loadaccount? - supernerd2000 - 05.02.2015

So I should move it from OnPlayerConnect to OnDialogResponse is what you're saying?

Edit: Didn't work, but I see what you mean by I had it in both. I removed it from OnPlayerConnect and left it in OnDialogResponse but had no luck.


Respuesta: Re: Script not calling loadaccount? - !R1Ch@rD! - 05.02.2015

Quote:
Originally Posted by supernerd2000
Посмотреть сообщение
So I should move it from OnPlayerConnect to OnDialogResponse is what you're saying?
if because that function is not going OnPlayerConnect it goes OnDialogResponse which I put there


Re: Script not calling loadaccount? - supernerd2000 - 05.02.2015

Alright, I fixed it like you said, and it didn't work.


Respuesta: Re: Script not calling loadaccount? - !R1Ch@rD! - 05.02.2015

Quote:
Originally Posted by supernerd2000
Посмотреть сообщение
Alright, I fixed it like you said, and it didn't work.
you still have the same problem? but since it will not keep accounts?


Re: Script not calling loadaccount? - supernerd2000 - 05.02.2015

Yeah, I still have this issue. See, it seems to be SAVING data just fine. However LOADING data seems to be where my issue lies.


Respuesta: Re: Script not calling loadaccount? - !R1Ch@rD! - 05.02.2015

Quote:
Originally Posted by supernerd2000
Посмотреть сообщение
Yeah, I still have this issue. See, it seems to be SAVING data just fine. However LOADING data seems to be where my issue lies.
Funny, I see good or serious For many codes as I do not see ta bn bn xD But O.o


Re: Script not calling loadaccount? - supernerd2000 - 05.02.2015

I don't understand what you mean?


Re: Script not calling loadaccount? - supernerd2000 - 06.02.2015

Does anyone have an answer? I have yet to fix this issue.