Weird bug on login
#1

Hello there!

I have been trying to script a roleplay script from scratch, but I have a very weird bug at the moment.

I can register fine, however when I log in, I get bugged.

It was working for a while, and I have been scripting the whole day without taking backups so I have no idea when or how it happened.

Normal Registering:
[ame]http://www.youtube.com/watch?v=zeKaYfi_iuI[/ame]



Bugged Login:
[ame]http://www.youtube.com/watch?v=CPwT06vZc8I[/ame]

My login and registering code:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == dregister) //If dialog id is a register dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            if(!strlen(inputtext)) //If they didn't enter any password
            {// then we will tell to them to enter the password to register
                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;
            }
            //If they have entered a correct password for his/her account...
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"Player's Data");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"Admin",0);
            INI_WriteInt(file,"Donator",0);
            INI_WriteInt(file,"Money",1000);
            INI_WriteInt(file,"Level",1);
            INI_WriteInt(file,"Kills",0);
            INI_WriteInt(file,"Deaths",0);
            INI_WriteInt(file,"Skin",299);
            INI_WriteFloat(file,"Health",100);
            INI_WriteFloat(file,"Armor",0);
            INI_WriteFloat(file,"PosX",1779.69);
            INI_WriteFloat(file,"PosY",-1937.75);
            INI_WriteFloat(file,"PosZ",13.55);
            INI_WriteInt(file,"Faction",pInfo[playerid][pFaction]);//As explained above
            INI_WriteInt(file,"Job",pInfo[playerid][pJob]);//As explained above
            INI_WriteInt(file,"Banned",pInfo[playerid][pBanned]);//As explained above
            new plrIP[16];
            GetPlayerIp(playerid, plrIP, sizeof(plrIP));
            INI_WriteString(file,"IP",plrIP);//As explained above
            INI_Close(file);
            SetSpawnInfo(playerid, 0, 299, 1779.69, -1937.75, 13.55, 30, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
            SetPlayerPos(playerid, 1779.69, -1937.75, 13.55);
            pInfo[playerid][pMoney] = 1000;
            GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
            pInfo[playerid][pLevel] = 1;
            SetPlayerScore(playerid, pInfo[playerid][pLevel]);
            pInfo[playerid][pSkin] = 299;
            SetPlayerSkin(playerid, 299);
            SendClientMessage(playerid,-1,"You have been successfully registered.");
            return 1;
        }
    }
    if(dialogid == dlogin) //If dialog id is a login dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            new hashpass[129]; //Will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass,pInfo[playerid][pPass])) //If they have insert their correct password
            {//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                SetPlayerScore(playerid,pInfo[playerid][pLevel]);//We will get their score inside of his user's account and we will set it here
                GivePlayerMoney(playerid, pInfo[playerid][pMoney]);//As explained above
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
                SetSpawnInfo(playerid, 0, pInfo[playerid][pSkin], pInfo[playerid][pPosX], pInfo[playerid][pPosY], pInfo[playerid][pPosZ], 30, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                SetPlayerScore(playerid, pInfo[playerid][pLevel]);
                SetPlayerHealth(playerid, pInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, pInfo[playerid][pArmor]);
            }
            else //If they've entered an incorrect password
            {//then
                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");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    //Same as OnDialogResponse, we will save their stats inside of their user's account
    if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
    {
        new Float:PosX, Float:PosY, Float:PosZ;
        GetPlayerPos(playerid, PosX, PosY, PosZ);
        new Float:health;
        GetPlayerHealth(playerid,health);
        new INI:file = INI_Open(Path(playerid)); //will open their file
        INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
        INI_WriteInt(file,"Admin",pInfo[playerid][pAdmin]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
        INI_WriteInt(file,"Donator",pInfo[playerid][pDonator]);//As explained above
        INI_WriteInt(file,"Money",pInfo[playerid][pMoney]);//We will save his money inside of his account
        INI_WriteInt(file,"Level",pInfo[playerid][pLevel]);//We will save his score inside of his account
        INI_WriteInt(file,"Kills",pInfo[playerid][pKills]);//As explained above
        INI_WriteInt(file,"Deaths",pInfo[playerid][pDeaths]);//As explained above
        INI_WriteInt(file,"Skin",pInfo[playerid][pSkin]);//As explained above
        INI_WriteFloat(file,"Health",health);//As explained above
        INI_WriteFloat(file,"Armor",pInfo[playerid][pArmor]);//As explained above
        INI_WriteFloat(file,"PosX",PosX);
        INI_WriteFloat(file,"PosY",PosY);
        INI_WriteFloat(file,"PosZ",PosZ);
        INI_WriteInt(file,"Faction",pInfo[playerid][pFaction]);//As explained above
        INI_WriteInt(file,"Job",pInfo[playerid][pJob]);//As explained above
        INI_WriteInt(file,"Banned",pInfo[playerid][pBanned]);//As explained above
        new plrIP[16];
        GetPlayerIp(playerid, plrIP, sizeof(plrIP));
        INI_WriteString(file,"IP",plrIP);//As explained above
        INI_Close(file);//Now after we've done saving their data, we now need to close the file
        return 1;
    }
    return 1;
}
pawn Код:
forward loadaccount_user(playerid, name[], value[]); //forwarding a new function to load user's data
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][pPass],129); /*we will use INI_String to load user's password.
    ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/

    INI_Int("Admin",pInfo[playerid][pAdmin]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
    INI_Int("Donator",pInfo[playerid][pDonator]);//As explained above
    INI_Int("Money",pInfo[playerid][pMoney]); //As explained above
    INI_Int("Level",pInfo[playerid][pLevel]);//As explained above
    INI_Int("Kills",pInfo[playerid][pKills]);//As explained above
    INI_Int("Deaths",pInfo[playerid][pDeaths]);//As explained above
    INI_Int("Skin",pInfo[playerid][pSkin]);//As explained above
    INI_Int("Health",pInfo[playerid][pHealth]);//As explained above
    INI_Int("PosX",pInfo[playerid][pPosX]);//As explained above
    INI_Int("PosY",pInfo[playerid][pPosY]);//As explained above
    INI_Int("PosZ",pInfo[playerid][pPosZ]);//As explained above
    INI_Int("Faction",pInfo[playerid][pFaction]);//As explained above
    INI_Int("Job",pInfo[playerid][pJob]);//As explained above
    INI_Int("Banned",pInfo[playerid][pBanned]);//As explained above
    INI_Int("Ban Reason",pInfo[playerid][pBanReason]);//As explained above
    return 1;
}
Reply
#2

pawn Код:
INI_Int("Health",pInfo[playerid][pHealth]);//As explained above
INI_Int("PosX",pInfo[playerid][pPosX]);//As explained above
INI_Int("PosY",pInfo[playerid][pPosY]);//As explained above
INI_Int("PosZ",pInfo[playerid][pPosZ]);//As explained above
Should be:

pawn Код:
INI_Float("Health",pInfo[playerid][pHealth]);//As explained above
INI_Float("PosX",pInfo[playerid][pPosX]);//As explained above
INI_Float("PosY",pInfo[playerid][pPosY]);//As explained above
INI_Float("PosZ",pInfo[playerid][pPosZ]);//As explained above
PS: You forgot the armour in the loading data.
pawn Код:
INI_Float("Armor",pInfo[playerid][pArmor]);

EDIT:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    //Same as OnDialogResponse, we will save their stats inside of their user's account
    if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
    {
        new Float:PosX, Float:PosY, Float:PosZ;
        GetPlayerPos(playerid, PosX, PosY, PosZ);
        new Float:health, Float:armour;
        GetPlayerHealth(playerid,health);
        GetPlayerArmour(playerid, armour);
        new INI:file = INI_Open(Path(playerid)); //will open their file
        INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
        INI_WriteInt(file,"Admin",pInfo[playerid][pAdmin]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
        INI_WriteInt(file,"Donator",pInfo[playerid][pDonator]);//As explained above
        INI_WriteInt(file,"Money",pInfo[playerid][pMoney]);//We will save his money inside of his account
        INI_WriteInt(file,"Level",pInfo[playerid][pLevel]);//We will save his score inside of his account
        INI_WriteInt(file,"Kills",pInfo[playerid][pKills]);//As explained above
        INI_WriteInt(file,"Deaths",pInfo[playerid][pDeaths]);//As explained above
        INI_WriteInt(file,"Skin",pInfo[playerid][pSkin]);//As explained above
        INI_WriteFloat(file,"Health",health);//As explained above
        INI_WriteFloat(file,"Armor",armour);//As explained above
        INI_WriteFloat(file,"PosX",PosX);
        INI_WriteFloat(file,"PosY",PosY);
        INI_WriteFloat(file,"PosZ",PosZ);
        INI_WriteInt(file,"Faction",pInfo[playerid][pFaction]);//As explained above
        INI_WriteInt(file,"Job",pInfo[playerid][pJob]);//As explained above
        INI_WriteInt(file,"Banned",pInfo[playerid][pBanned]);//As explained above
        new plrIP[16];
        GetPlayerIp(playerid, plrIP, sizeof(plrIP));
        INI_WriteString(file,"IP",plrIP);//As explained above
        INI_Close(file);//Now after we've done saving their data, we now need to close the file
        return 1;
    }
    return 1;
}
Reply
#3

Код:
H:\gamemodes\RP.pwn(177) : warning 213: tag mismatch
H:\gamemodes\RP.pwn(178) : warning 213: tag mismatch
H:\gamemodes\RP.pwn(179) : warning 213: tag mismatch
H:\gamemodes\RP.pwn(180) : warning 213: tag mismatch
H:\gamemodes\RP.pwn(181) : warning 213: tag mismatch
pawn Код:
INI_Float("Armor",pInfo[playerid][pArmor]);//177
    INI_Float("Health",pInfo[playerid][pHealth]);//178
    INI_Float("PosX",pInfo[playerid][pPosX]);//179
    INI_Float("PosY",pInfo[playerid][pPosY]);//180
    INI_Float("PosZ",pInfo[playerid][pPosZ]);//190
Reply
#4

Did you declare Float:pPosX, etc in your enum?
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Did you declare FloatPosX, etc in your enum?
Ah, that's right. I forgot that. Thanks & Repped both of you.
Reply
#6

That didn't seem to resolve the problem, however that fixed a few other bugs.

However, I found out that the reason it was like that was because I was testing a ban system, and when I logged in and it said: You are banned from this sever, please post an appeal, it saved my pos and health before I had spawned.

Please close this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)