#1

#include <YSI\y_ini>

Thats what i use to save my stats and when i register an account it does save but some reason when you try to login it it says incorrect password any advice?
Reply
#2

We can't help you without a code,
Show us your Login and Register code
Reply
#3

Код:
public OnPlayerConnect(playerid)
{
 	new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

	InterpolateCameraPos(playerid, 380.2796, -340.6636, 49.3404, -162.2861, 157.5699, 53.6954, 150000);
	InterpolateCameraLookAt(playerid, 381.0202, -341.3334, 49.4304, -162.9535, 158.3127, 53.8754, 100000);
	
    SetPlayerMapIcon(playerid, 1, 373.4215, -275.4926, 1.0578, 9, 0, MAPICON_LOCAL);
	SetTimer("LevelTimer", 1800000, true);

    TogglePlayerSpectating(playerid, 1); // remove "Spawn" button
    SetPlayerPos(playerid, -162.9535, 158.3127, 53.8754);

    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Type your password below to login.", "Login", "Quit");
    }

    else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register a new account.", "Register", "Quit");

 	PreloadAnimLib(playerid, "KNIFE");
	PreloadAnimLib(playerid, "MEDIC");

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	if(Logged[playerid] == true)
	{
		new year, month, day, hour, minute, second, Float: X, Float: Y, Float: Z, Float: hp, Float: armor;
		GetPlayerArmour(playerid, armor), GetPlayerHealth(playerid, hp);
	    getdate(year, month, day), gettime(hour, minute, second), GetPlayerPos(playerid, X, Y, Z);

		GetPlayerWeaponData(playerid, 2, pInfo[playerid][Weapon1], pInfo[playerid][Wep1Ammo]);
		GetPlayerWeaponData(playerid, 3, pInfo[playerid][Weapon2], pInfo[playerid][Wep2Ammo]);
		GetPlayerWeaponData(playerid, 4, pInfo[playerid][Weapon3], pInfo[playerid][Wep3Ammo]);
		GetPlayerWeaponData(playerid, 5, pInfo[playerid][Weapon4], pInfo[playerid][Wep4Ammo]);
		GetPlayerWeaponData(playerid, 6, pInfo[playerid][Weapon5], pInfo[playerid][Wep5Ammo]);

	    new INI:File = INI_Open(UserPath(playerid));

	    INI_SetTag(File, "Player Data");

		// account related
	    INI_WriteInt(File, "Admin", pInfo[playerid][Admin]);
	    INI_WriteInt(File, "Level", pInfo[playerid][Level]);
	    INI_WriteInt(File, "Skin", GetPlayerSkin(playerid));
	    INI_WriteInt(File, "Exp", pInfo[playerid][Exp]);
	    INI_WriteInt(File, "CurExp", pInfo[playerid][CurExp]);
	    INI_WriteInt(File, "Gender", pInfo[playerid][Gender]);
		INI_WriteInt(File, "Registered", pInfo[playerid][Registered]);
		INI_WriteInt(File, "HandMoney", GetPlayerMoney(playerid));
		INI_WriteInt(File, "BankMoney", pInfo[playerid][BankMoney]);

		INI_WriteFloat(File, "Armour", armor);
		INI_WriteFloat(File, "Health", hp);

		// faction
	    INI_WriteInt(File, "Faction", pInfo[playerid][Faction]);
		INI_WriteInt(File, "FactionTier", pInfo[playerid][FactionTier]);
	    INI_WriteString(File, "FactionRank", pInfo[playerid][FactionRank]);

		INI_WriteInt(File, "Weapon1", pInfo[playerid][Weapon1]);
		INI_WriteInt(File, "Wep1Ammo", pInfo[playerid][Wep1Ammo]);
		INI_WriteInt(File, "Weapon2", pInfo[playerid][Weapon2]);
		INI_WriteInt(File, "Wep2Ammo", pInfo[playerid][Wep2Ammo]);
		INI_WriteInt(File, "Weapon3", pInfo[playerid][Weapon3]);
		INI_WriteInt(File, "Wep3Ammo", pInfo[playerid][Wep3Ammo]);
		INI_WriteInt(File, "Weapon4", pInfo[playerid][Weapon4]);
		INI_WriteInt(File, "Wep4Ammo", pInfo[playerid][Wep4Ammo]);
		INI_WriteInt(File, "Weapon5", pInfo[playerid][Weapon5]);
		INI_WriteInt(File, "Wep5Ammo", pInfo[playerid][Wep5Ammo]);

		// server-side
		INI_WriteInt(File, "LastPos", 1);
		INI_WriteInt(File, "LastInt", GetPlayerInterior(playerid));
	 	INI_WriteInt(File, "LastVW", GetPlayerVirtualWorld(playerid));
	    INI_WriteFloat(File, "LastX", X);
	    INI_WriteFloat(File, "LastY", Y);
	    INI_WriteFloat(File, "LastZ", Z);

		INI_WriteInt(File, "Mask", pInfo[playerid][Mask]);
	    INI_WriteInt(File, "MaskID", pInfo[playerid][MaskID]);
	    INI_WriteInt(File, "PhoneNumber", pInfo[playerid][PhoneNumber]);
	    INI_WriteInt(File, "HouseOwner", pInfo[playerid][HouseOwner]);
  	    INI_WriteInt(File, "BizOwner", pInfo[playerid][BizOwner]);
	    INI_WriteInt(File, "VehicleOwner", pInfo[playerid][VehicleOwner]);

		// informational
	    INI_WriteInt(File, "lvDay", day);
	    INI_WriteInt(File, "lvMonth", month);
	    INI_WriteInt(File, "lvYear", year);
	    INI_WriteInt(File, "lvHour", hour);
	    INI_WriteInt(File, "lvMinute", minute);
	    INI_WriteInt(File, "lvSecond", second);

	    INI_Close(File);
	}

    return 1;
}
Код:
{
    new string[128], pname[MAX_PLAYER_NAME+1];
	GetPlayerName(playerid, pname, sizeof(pname));

    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);

            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register a new account.", "Register", "Quit");

                new INI:File = INI_Open(UserPath(playerid));

				new rand1 = random(99999), rand2 = random(99999);

                INI_SetTag(File, "Player Data");
                
                INI_WriteInt(File, "Password", udb_hash(inputtext));
			    INI_WriteInt(File, "Admin", 0);
			    INI_WriteInt(File, "Level", 1);
			    INI_WriteInt(File, "Skin", 0);
			    INI_WriteInt(File, "Exp", 0);
			    INI_WriteInt(File, "Gender", 0);
			    INI_WriteInt(File, "Registered", 0);

				INI_WriteFloat(File, "Armour", 0);
				INI_WriteFloat(File, "Health", 100);
				
			    INI_WriteInt(File, "Faction", 0);
			    INI_WriteInt(File, "FactionTier", 0);
			 	INI_WriteString(File, "FactionRank", "None");

				INI_WriteInt(File, "HandMoney", 0);
				INI_WriteInt(File, "BankMoney", 0);
				
				INI_WriteInt(File, "Mask", 0);
			    INI_WriteInt(File, "MaskID", rand1);
			    INI_WriteInt(File, "PhoneNumber", rand2);
			    INI_WriteInt(File, "HouseOwner", 9999);
			    INI_WriteInt(File, "VehicleOwner", 9999);
			    INI_WriteInt(File, "BizOwner", 9999);

			    INI_WriteInt(File, "Weapon1", 0);
			    INI_WriteInt(File, "Wep1Ammo", 0);
			    INI_WriteInt(File, "Weapon2", 0);
			    INI_WriteInt(File, "Wep2Ammo", 0);
			    INI_WriteInt(File, "Weapon3", 0);
			    INI_WriteInt(File, "Wep3Ammo", 0);
			    INI_WriteInt(File, "Weapon4", 0);
			    INI_WriteInt(File, "Wep4Ammo", 0);
			    INI_WriteInt(File, "Weapon5", 0);
			    INI_WriteInt(File, "Wep5Ammo", 0);

			    INI_WriteInt(File, "lvDay", 0);
			    INI_WriteInt(File, "lvMonth", 0);
			    INI_WriteInt(File, "lvYear", 0);
			    INI_WriteInt(File, "lvHour", 0);
			    INI_WriteInt(File, "lvMinute", 0);
			    INI_WriteInt(File, "lvSecond", 0);

				INI_WriteInt(File, "LastPos", 0);
				INI_WriteInt(File, "LastVW", 0);
				INI_WriteInt(File, "LastInt", 0);
			    INI_WriteFloat(File, "LastX", 0);
			    INI_WriteFloat(File, "LastY", 0);
			    INI_WriteFloat(File, "LastZ", 0);

                INI_Close(File);

				format(string, sizeof(string), "SERVER:{FFFFFF} Welcome to the server, %s!", pname);
				SendClientMessage(playerid, 0x46E850FF, string);

				SetSpawnInfo(playerid, 0, 0, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
			}
        }

        case DIALOG_LOGIN:
        {
            if (!response) return Kick(playerid);

            if(response)
            {
                if(udb_hash(inputtext) == pInfo[playerid][Pass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

					format(string, sizeof(string), "SERVER:{FFFFFF} Welcome back, %s! You last logged in at %d/%d/%d %d:%d:%d.", pname, pInfo[playerid][lvDay], pInfo[playerid][lvMonth], pInfo[playerid][lvYear], pInfo[playerid][lvHour], pInfo[playerid][lvMinute], pInfo[playerid][lvSecond]);
					SendClientMessage(playerid, 0x46E850FF, string);

					Logged[playerid] = true;

					SetSpawnInfo(playerid, 0, 0, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0);
                	SpawnPlayer(playerid);
                }

                else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FFFFFF}You have entered an {C44B4B}incorrect{FFFFFF} password.\nType your password below to login.", "Login", "Quit");

                return 1;
            }
        }
Reply
#4

Код:
public OnPlayerConnect(playerid)
{
 	new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

	InterpolateCameraPos(playerid, 380.2796, -340.6636, 49.3404, -162.2861, 157.5699, 53.6954, 150000);
	InterpolateCameraLookAt(playerid, 381.0202, -341.3334, 49.4304, -162.9535, 158.3127, 53.8754, 100000);
	
    SetPlayerMapIcon(playerid, 1, 373.4215, -275.4926, 1.0578, 9, 0, MAPICON_LOCAL);
	SetTimer("LevelTimer", 1800000, true);

    TogglePlayerSpectating(playerid, 1); // remove "Spawn" button
    SetPlayerPos(playerid, -162.9535, 158.3127, 53.8754);

    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Type your password below to login.", "Login", "Quit");
    }

    else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register a new account.", "Register", "Quit");

 	PreloadAnimLib(playerid, "KNIFE");
	PreloadAnimLib(playerid, "MEDIC");

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	if(Logged[playerid] == true)
	{
		new year, month, day, hour, minute, second, Float: X, Float: Y, Float: Z, Float: hp, Float: armor;
		GetPlayerArmour(playerid, armor), GetPlayerHealth(playerid, hp);
	    getdate(year, month, day), gettime(hour, minute, second), GetPlayerPos(playerid, X, Y, Z);

		GetPlayerWeaponData(playerid, 2, pInfo[playerid][Weapon1], pInfo[playerid][Wep1Ammo]);
		GetPlayerWeaponData(playerid, 3, pInfo[playerid][Weapon2], pInfo[playerid][Wep2Ammo]);
		GetPlayerWeaponData(playerid, 4, pInfo[playerid][Weapon3], pInfo[playerid][Wep3Ammo]);
		GetPlayerWeaponData(playerid, 5, pInfo[playerid][Weapon4], pInfo[playerid][Wep4Ammo]);
		GetPlayerWeaponData(playerid, 6, pInfo[playerid][Weapon5], pInfo[playerid][Wep5Ammo]);

	    new INI:File = INI_Open(UserPath(playerid));

	    INI_SetTag(File, "Player Data");

		// account related
	    INI_WriteInt(File, "Admin", pInfo[playerid][Admin]);
	    INI_WriteInt(File, "Level", pInfo[playerid][Level]);
	    INI_WriteInt(File, "Skin", GetPlayerSkin(playerid));
	    INI_WriteInt(File, "Exp", pInfo[playerid][Exp]);
	    INI_WriteInt(File, "CurExp", pInfo[playerid][CurExp]);
	    INI_WriteInt(File, "Gender", pInfo[playerid][Gender]);
		INI_WriteInt(File, "Registered", pInfo[playerid][Registered]);
		INI_WriteInt(File, "HandMoney", GetPlayerMoney(playerid));
		INI_WriteInt(File, "BankMoney", pInfo[playerid][BankMoney]);

		INI_WriteFloat(File, "Armour", armor);
		INI_WriteFloat(File, "Health", hp);

		// faction
	    INI_WriteInt(File, "Faction", pInfo[playerid][Faction]);
		INI_WriteInt(File, "FactionTier", pInfo[playerid][FactionTier]);
	    INI_WriteString(File, "FactionRank", pInfo[playerid][FactionRank]);

		INI_WriteInt(File, "Weapon1", pInfo[playerid][Weapon1]);
		INI_WriteInt(File, "Wep1Ammo", pInfo[playerid][Wep1Ammo]);
		INI_WriteInt(File, "Weapon2", pInfo[playerid][Weapon2]);
		INI_WriteInt(File, "Wep2Ammo", pInfo[playerid][Wep2Ammo]);
		INI_WriteInt(File, "Weapon3", pInfo[playerid][Weapon3]);
		INI_WriteInt(File, "Wep3Ammo", pInfo[playerid][Wep3Ammo]);
		INI_WriteInt(File, "Weapon4", pInfo[playerid][Weapon4]);
		INI_WriteInt(File, "Wep4Ammo", pInfo[playerid][Wep4Ammo]);
		INI_WriteInt(File, "Weapon5", pInfo[playerid][Weapon5]);
		INI_WriteInt(File, "Wep5Ammo", pInfo[playerid][Wep5Ammo]);

		// server-side
		INI_WriteInt(File, "LastPos", 1);
		INI_WriteInt(File, "LastInt", GetPlayerInterior(playerid));
	 	INI_WriteInt(File, "LastVW", GetPlayerVirtualWorld(playerid));
	    INI_WriteFloat(File, "LastX", X);
	    INI_WriteFloat(File, "LastY", Y);
	    INI_WriteFloat(File, "LastZ", Z);

		INI_WriteInt(File, "Mask", pInfo[playerid][Mask]);
	    INI_WriteInt(File, "MaskID", pInfo[playerid][MaskID]);
	    INI_WriteInt(File, "PhoneNumber", pInfo[playerid][PhoneNumber]);
	    INI_WriteInt(File, "HouseOwner", pInfo[playerid][HouseOwner]);
  	    INI_WriteInt(File, "BizOwner", pInfo[playerid][BizOwner]);
	    INI_WriteInt(File, "VehicleOwner", pInfo[playerid][VehicleOwner]);

		// informational
	    INI_WriteInt(File, "lvDay", day);
	    INI_WriteInt(File, "lvMonth", month);
	    INI_WriteInt(File, "lvYear", year);
	    INI_WriteInt(File, "lvHour", hour);
	    INI_WriteInt(File, "lvMinute", minute);
	    INI_WriteInt(File, "lvSecond", second);

	    INI_Close(File);
	}

    return 1;
}
Код:
{
    new string[128], pname[MAX_PLAYER_NAME+1];
	GetPlayerName(playerid, pname, sizeof(pname));

    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);

            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register a new account.", "Register", "Quit");

                new INI:File = INI_Open(UserPath(playerid));

				new rand1 = random(99999), rand2 = random(99999);

                INI_SetTag(File, "Player Data");
                
                INI_WriteInt(File, "Password", udb_hash(inputtext));
			    INI_WriteInt(File, "Admin", 0);
			    INI_WriteInt(File, "Level", 1);
			    INI_WriteInt(File, "Skin", 0);
			    INI_WriteInt(File, "Exp", 0);
			    INI_WriteInt(File, "Gender", 0);
			    INI_WriteInt(File, "Registered", 0);

				INI_WriteFloat(File, "Armour", 0);
				INI_WriteFloat(File, "Health", 100);
				
			    INI_WriteInt(File, "Faction", 0);
			    INI_WriteInt(File, "FactionTier", 0);
			 	INI_WriteString(File, "FactionRank", "None");

				INI_WriteInt(File, "HandMoney", 0);
				INI_WriteInt(File, "BankMoney", 0);
				
				INI_WriteInt(File, "Mask", 0);
			    INI_WriteInt(File, "MaskID", rand1);
			    INI_WriteInt(File, "PhoneNumber", rand2);
			    INI_WriteInt(File, "HouseOwner", 9999);
			    INI_WriteInt(File, "VehicleOwner", 9999);
			    INI_WriteInt(File, "BizOwner", 9999);

			    INI_WriteInt(File, "Weapon1", 0);
			    INI_WriteInt(File, "Wep1Ammo", 0);
			    INI_WriteInt(File, "Weapon2", 0);
			    INI_WriteInt(File, "Wep2Ammo", 0);
			    INI_WriteInt(File, "Weapon3", 0);
			    INI_WriteInt(File, "Wep3Ammo", 0);
			    INI_WriteInt(File, "Weapon4", 0);
			    INI_WriteInt(File, "Wep4Ammo", 0);
			    INI_WriteInt(File, "Weapon5", 0);
			    INI_WriteInt(File, "Wep5Ammo", 0);

			    INI_WriteInt(File, "lvDay", 0);
			    INI_WriteInt(File, "lvMonth", 0);
			    INI_WriteInt(File, "lvYear", 0);
			    INI_WriteInt(File, "lvHour", 0);
			    INI_WriteInt(File, "lvMinute", 0);
			    INI_WriteInt(File, "lvSecond", 0);

				INI_WriteInt(File, "LastPos", 0);
				INI_WriteInt(File, "LastVW", 0);
				INI_WriteInt(File, "LastInt", 0);
			    INI_WriteFloat(File, "LastX", 0);
			    INI_WriteFloat(File, "LastY", 0);
			    INI_WriteFloat(File, "LastZ", 0);

                INI_Close(File);

				format(string, sizeof(string), "SERVER:{FFFFFF} Welcome to the server, %s!", pname);
				SendClientMessage(playerid, 0x46E850FF, string);

				SetSpawnInfo(playerid, 0, 0, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
			}
        }

        case DIALOG_LOGIN:
        {
            if (!response) return Kick(playerid);

            if(response)
            {
                if(udb_hash(inputtext) == pInfo[playerid][Pass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

					format(string, sizeof(string), "SERVER:{FFFFFF} Welcome back, %s! You last logged in at %d/%d/%d %d:%d:%d.", pname, pInfo[playerid][lvDay], pInfo[playerid][lvMonth], pInfo[playerid][lvYear], pInfo[playerid][lvHour], pInfo[playerid][lvMinute], pInfo[playerid][lvSecond]);
					SendClientMessage(playerid, 0x46E850FF, string);

					Logged[playerid] = true;

					SetSpawnInfo(playerid, 0, 0, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0);
                	SpawnPlayer(playerid);
                }

                else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FFFFFF}You have entered an {C44B4B}incorrect{FFFFFF} password.\nType your password below to login.", "Login", "Quit");

                return 1;
            }
        }
Reply
#5

Is that a gamemode which you made it or you found it somewhere?
Reply
#6

i got it off the internet as i am trying to learn scripting so i thought it would be easier to start with a script instead of from scratch
Reply
#7

I'd say re-write the code, use WP_hash and help with ******.
Reply
#8

Yea i doubt that will happen as i am learning how to script so i dont know how to re-write all that code any other suggestions?
Reply
#9

Start with an easy script
Reply
#10

Swap
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
with
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_user", .bExtra = true, .extra = playerid);
It's a common problem that happens with Y_INI, just make sure it matches the name of your function as you didnt post it in the code above.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)