#1

So, I have big problem, I'm looking to fix this bug but I can't

I made reg/log system for scratch script with MySQL, and all variables saves when I disconnect, but when I turn off server and turn on, variables are there, but when I login again, all variables are setted on 0, expect Username and Password, on ALL ACCOUNTS if I login just from one. So please help me fast, I really don't know what to do, I'm fixing this problem about 10 days and i can't, so please! You are my last chance, so please
Reply
#2

Give us your OnGameModeInit and OnGamemodeExit..
Reply
#3

Код:
connectionHandle = mysql_connect("localhost", "root", "samp", "");
mysql_debug(1);
INI_ParseFile(SPATH, "LoadServerData", .bExtra = false);
I can't give you full code, because there are maps

and exit, but forget about Y_INI code, this is for server variables, I now speak about player.

Код:
public OnGameModeExit()
{
	mysql_close(0);

	new INI:File = INI_Open(SPATH);
	INI_SetTag(File, "info");
	INI_WriteInt(File, "Smecarska_marsuta_1", ServerInfo[sSM1]);
	INI_WriteInt(File, "Smecarska_marsuta_2", ServerInfo[sSM2]);
	INI_WriteInt(File, "Smecarska_marsuta_3", ServerInfo[sSM3]);
	INI_WriteInt(File, "Smecarska_marsuta_4", ServerInfo[sSM4]);
	INI_WriteInt(File, "Cijena_Gradske_Stanice", ServerInfo[sCijenaGradskeStanice]);
    INI_WriteInt(File, "Cijena_Prigradske_Stanice", ServerInfo[sCijenaPrigradskeStanice]);
	INI_WriteInt(File, "Gradska_Autobusna_ruta_1", ServerInfo[sGradskaARuta1]);
	INI_WriteInt(File, "Gradska_Autobusna_ruta_2", ServerInfo[sGradskaARuta2]);
	INI_WriteInt(File, "Prigradska_Autobusna_ruta", ServerInfo[sPrigradskaARuta]);
	INI_Close(File);
        return 1;
}
Reply
#4

1) Show what you use to define SPATH
2) Show where you LOAD the USER'S file. (INI_ParseFile)
3) Show your login?? (Not required, but is recommended if you want to fix.)
Reply
#5

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
1) Show what you use to define SPATH
2) Show where you LOAD the USER'S file. (INI_ParseFile)
3) Show your login?? (Not required, but is recommended if you want to fix.)
1) There's not problem with Y_INI, I use Y_INI for ServerData, for example: Statisticofplayers: 54 (to show me which is biggest score of us )
2) As I said for 1)
3)

OnPlayerConnect:
Код:
//Register/Login

mysql_format(connectionHandle, Query, "SELECT * FROM `users` WHERE `Ime i prezime` = '%e'", GetName(playerid));
mysql_function_query(connectionHandle, Query, false, "CheckPlayer", "d", playerid);
CheckPlayer function:
Код:
public CheckPlayer(playerid)
{
	mysql_store_result();
	if(mysql_num_rows() == 1)
	{
	 	SetPlayerCameraPos(playerid, 320.0, 50.0, 170.0);
        SetPlayerCameraLookAt(playerid, 324.34, 54.122, 173.35);
        new string[512];
		format(string, sizeof(string), "{FFFFFF}Dobrodosli nazad na {039EFF}Matrix Gaming Hard RolePlay\n{FFFFFF}____________________________________\nVase Ime: {039EFF}%s\n{FFFFFF}Status: {039EFF}Imate account\n{FFFFFF}Level: {039EFF}%i\n{FFFFFF}Matrix Novac: {039EFF}%i\n{FFFFFF}_______________________________\nMolimo da se ulogujete, da zapocnete igru", GetName(playerid), PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pMN]);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_BLUE"          Login || Matrix Gaming", string, "Login","Izlaz");
	}
	else
	{
		SetPlayerCameraPos(playerid, 320.0, 50.0, 170.0);
        SetPlayerCameraLookAt(playerid, 324.34, 54.122, 173.35);
        new string[512];
        format(string, sizeof(string), "{FFFFFF}Dobrodosli na {039EFF}Matrix Gaming Hard RolePlay\n{FFFFFF}____________________________________\nVase Ime: {039EFF}%s\n{FFFFFF}Status: {039EFF}Nemate account\n{FFFFFF}-Molimo da uneste u polje {039EFF}zeljeni password\n{FFFFFF}-Nakon toga, slijedi {039EFF}intro(tutorial)\n{FFFFFF}_______________________________\nMolimo da se registrujete, te zapocnete igru", GetName(playerid));
	 	ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_BLUE"      Registracija || Matrix Gaming", string, "Registracija", "");
	}
	mysql_free_result();
return 1;
}
OnDialogeResponse for login:
Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
					mysql_format(connectionHandle, Query, "SECELT * FROM `users` WHERE `Ime i prezime` = '%e' AND `Password` = md5('%e')", GetName(playerid), inputtext);
					mysql_function_query(connectionHandle, Query, false, "LoginPlayer", "ds", playerid, inputtext);
                    TextDrawHideForPlayer(playerid, Textdraw0);
                	TextDrawHideForPlayer(playerid, Textdraw1);
                	TextDrawHideForPlayer(playerid, Textdraw2);
                	TextDrawHideForPlayer(playerid, Textdraw3);
                	TextDrawHideForPlayer(playerid, Textdraw4);
                    PlayerInfo[playerid][pKosenje] = 0;
                    PlayerInfo[playerid][pSmecar] = 0;
					if(PlayerInfo[playerid][pSpawn] == 1)
					{
     				SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkinO], 1264.4155,-1744.0496,356.0060, 180.0, 0, 0, 0,0,0,0);
					SpawnPlayer(playerid);
						new string2[128];
					format(string2, sizeof(string2), "{039EFF}MG:RP || {FFFFFF}%s {039EFF}dobrodosli na Matrix Gaming Hard RP!", GetName(playerid));
                    SendClientMessage(playerid, -1, string2);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					SetPlayerVirtualWorld(playerid, 1);
                	PlayerInfo[playerid][pVW] = 1;
					return 1;
					}
					if(PlayerInfo[playerid][pSpawn] == 2)
					{
     				SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkinO], 1264.4155,-1744.0496,356.0060, 180.0, 0, 0, 0,0,0,0);
					SpawnPlayer(playerid);
						new string2[128];
					format(string2, sizeof(string2), "{039EFF}MG:RP || {FFFFFF}%s {039EFF}dobrodosli na Matrix Gaming Hard RP!", GetName(playerid));
                    SendClientMessage(playerid, -1, string2);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerVirtualWorld(playerid, 2);
                	PlayerInfo[playerid][pVW] = 2;
					return 1;
					}
					if(PlayerInfo[playerid][pSpawn] == 3)
					{
					SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkinO], 1685.8240, -2242.3794, 13.5469, 180.0, 0, 0, 0,0,0,0);
					SpawnPlayer(playerid);
						new string2[128];
					format(string2, sizeof(string2), "{039EFF}MG:RP || {FFFFFF}%s {039EFF}dobrodosli na Matrix Gaming Hard RP!", GetName(playerid));
                    SendClientMessage(playerid, -1, string2);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					return 1;
					}
					if(PlayerInfo[playerid][pSpawn] == 4)
					{
					SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkinO], 867.5604,-2691.9775,13.1547,98.9048, 0, 0, 0, 0, 0, 0);
					SpawnPlayer(playerid);
						new string2[128];
					format(string2, sizeof(string2), "{039EFF}MG:RP || {FFFFFF}%s {039EFF}dobrodosli na Matrix Gaming Hard RP!", GetName(playerid));
                    SendClientMessage(playerid, -1, string2);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					return 1;
					}
				
				}
			 	}
LoginPlayer function:

Код:
public LoginPlayer(playerid, password[])
{
	
	mysql_store_result();
	if(mysql_num_rows() == 1)
	{
	    if(mysql_retrieve_row() == 1)
	    {
	    	new string[128];
	        mysql_fetch_field_row(string, "Level", connectionHandle); PlayerInfo[playerid][pLevel] = strval(string);
	        mysql_fetch_field_row(string, "Respekti", connectionHandle); PlayerInfo[playerid][pExp] = strval(string);
	        mysql_fetch_field_row(string, "Novac", connectionHandle); PlayerInfo[playerid][pCash] = strval(string);
	        mysql_fetch_field_row(string, "Posao", connectionHandle); PlayerInfo[playerid][pJob] = strval(string);
	        mysql_fetch_field_row(string, "Rank - posao", connectionHandle); PlayerInfo[playerid][pRankP] = strval(string);
	        mysql_fetch_field_row(string, "Organizacija", connectionHandle); PlayerInfo[playerid][pOrg] = strval(string);
	        mysql_fetch_field_row(string, "Rank - organizacija", connectionHandle); PlayerInfo[playerid][pRankO] = strval(string);
	        mysql_fetch_field_row(string, "Wanted level", connectionHandle); PlayerInfo[playerid][pWanted] = strval(string);
	        mysql_fetch_field_row(string, "Lider", connectionHandle); PlayerInfo[playerid][pLeader] = strval(string);
	        mysql_fetch_field_row(string, "Admin", connectionHandle); PlayerInfo[playerid][pAdmin] = strval(string);
	        mysql_fetch_field_row(string, "MS", connectionHandle); PlayerInfo[playerid][pMS] = strval(string);
	        mysql_fetch_field_row(string, "Skin - osnovni", connectionHandle); PlayerInfo[playerid][pSkinO] = strval(string);
	        mysql_fetch_field_row(string, "Skin - posao", connectionHandle); PlayerInfo[playerid][pSkinP] = strval(string);
	        mysql_fetch_field_row(string, "Spawn", connectionHandle); PlayerInfo[playerid][pSpawn] = strval(string);
	        mysql_fetch_field_row(string, "Plata", connectionHandle); PlayerInfo[playerid][pPlata] = strval(string);
	        mysql_fetch_field_row(string, "Matrix novac", connectionHandle); PlayerInfo[playerid][pMN] = strval(string);
	        mysql_fetch_field_row(string, "Banka", connectionHandle); PlayerInfo[playerid][pBanka] = strval(string);
	        mysql_fetch_field_row(string, "Broj telefona", connectionHandle); PlayerInfo[playerid][pPhNumber] = strval(string);
	        mysql_fetch_field_row(string, "Pin-kod kartice", connectionHandle); PlayerInfo[playerid][pPKKartica] = strval(string);
	        mysql_fetch_field_row(string, "Pin-kod telefona", connectionHandle); PlayerInfo[playerid][pPKTelefon] = strval(string);
	        mysql_fetch_field_row(string, "Virtual World", connectionHandle); PlayerInfo[playerid][pVW] = strval(string);
	    }
	}
	mysql_free_result();
	return 1;
}
That's for mySQL, I don't need anything for Y_INI, jsut MYSQL, Y_INI work perfectly
Reply
#6

Help please!!!!

BUMP!
Reply
#7

One question when you exit before you stop the server did everything its save like have to be ?
Reply
#8

Yes, all reset after I login in after server restart(turn off/turn on)
Reply
#9

BUMP!!!
Reply
#10

I searched and I found problem, but I don't know how to fix, problem is here :

mysql_format(connectionHandle, Query, "SECELT * FROM `users` WHERE `Ime i prezime` = '%e' AND `Password` = '%e'", GetName(playerid), inputtext);
mysql_function_query(connectionHandle, Query, false, "LoginPlayer", "ds", playerid, inputtext);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)