SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/04/2014, 08:54 PM   #1
crouch010
Huge Clucker
 
Join Date: Aug 2010
Location: Bucharest
Posts: 224
Reputation: 0
Default mysql crash

hy everyone, i have transfered 70% from my "accounts" part of gamemode to MYSQL ( i mean just 70% of account stuff not houses or cars etc. rest of 30% its the saving part remaining to do)
The problem is with the callback (OnPlayerLogin) , in the database i`m showing correct with password and other stuff, but in server when i try to log with my password it crashes the sampserver.exe ....i dont know why.

HTML Code:
PUBLIC: OnPlayerLogin(playerid, password[])
{
	MySQLCheckConnection();
	new playersip[24], result[128], string2[256], tmp2[256], Query[128];
	new playername2[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername2, sizeof(playername2));
	GetPlayerIp(playerid, playersip, sizeof(playersip));
	format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `pUsername` = '%s' AND `pKey` = '%s'", playername2, password);
	mysql_query(Query);
	mysql_store_result();
	if(IsPlayerConnectedEx(playerid))
	{
		if(mysql_num_rows() != 0)
		{
			if(mysql_retrieve_row ())
			{
				mysql_fetch_field_row(result, "pKey"); format(PlayerInfo[playerid][pKey], sizeof(result), result);
				mysql_fetch_field_row(result, "pLevel"); PlayerInfo[playerid][pLevel] = strval(result);
		    	mysql_fetch_field_row(result, "pAdmin"); PlayerInfo[playerid][pAdmin] = strval(result);
		    	mysql_fetch_field_row(result, "pHelper"); PlayerInfo[playerid][pHelper] = strval(result);
		    	mysql_fetch_field_row(result, "pEmail"); format(PlayerInfo[playerid][pEmail], sizeof(result), result);
		    	mysql_fetch_field_row(result, "pTitle"); format(PlayerInfo[playerid][pTitle], sizeof(result), result);
		    	mysql_fetch_field_row(result, "pLastLogin"); format(PlayerInfo[playerid][pLastLogin], sizeof(result), result);
		    	mysql_fetch_field_row(result, "pCoin"); PlayerInfo[playerid][pCoin] = strval(result);
		    	mysql_fetch_field_row(result, "gPupgrade"); PlayerInfo[playerid][gPupgrade] = strval(result);
		    	mysql_fetch_field_row(result, "pConnectTime"); PlayerInfo[playerid][pConnectTime] = strval(result);
		    	mysql_fetch_field_row(result, "pDonateRank"); PlayerInfo[playerid][pDonateRank] = strval(result);
		    	mysql_fetch_field_row(result, "pReg"); PlayerInfo[playerid][pReg] = strval(result);
		    	mysql_fetch_field_row(result, "pSex"); PlayerInfo[playerid][pSex] = strval(result);
		    	mysql_fetch_field_row(result, "pAge"); PlayerInfo[playerid][pAge] = strval(result);
		    	mysql_fetch_field_row(result, "pOrigin"); PlayerInfo[playerid][pOrigin] = strval(result);
		    	mysql_fetch_field_row(result, "pMuted"); PlayerInfo[playerid][pMuted] = strval(result);
		    	mysql_fetch_field_row(result, "pMuteTime"); PlayerInfo[playerid][pMuteTime] = strval(result);
		    	mysql_fetch_field_row(result, "pExp"); PlayerInfo[playerid][pExp] = strval(result);
		    	mysql_fetch_field_row(result, "pCash"); PlayerInfo[playerid][pCash] = strval(result);
		    	mysql_fetch_field_row(result, "pAccount"); PlayerInfo[playerid][pAccount] = strval(result);
		    	mysql_fetch_field_row(result, "pCrimes"); PlayerInfo[playerid][pCrimes] = strval(result);
                mysql_fetch_field_row(result, "pKills"); PlayerInfo[playerid][pKills] = strval(result);
                mysql_fetch_field_row(result, "pDeaths"); PlayerInfo[playerid][pDeaths] = strval(result);
                mysql_fetch_field_row(result, "pArrested"); PlayerInfo[playerid][pArrested] = strval(result);
                mysql_fetch_field_row(result, "pWantedDeaths"); PlayerInfo[playerid][pWantedDeaths] = strval(result);
                mysql_fetch_field_row(result, "pPhoneBook"); PlayerInfo[playerid][pPhoneBook] = strval(result);
                mysql_fetch_field_row(result, "pLottoNr"); PlayerInfo[playerid][pLottoNr] = strval(result);
                mysql_fetch_field_row(result, "pFishes"); PlayerInfo[playerid][pFishes] = strval(result);
                mysql_fetch_field_row(result, "pBiggestFish"); PlayerInfo[playerid][pBiggestFish] = strval(result);
                mysql_fetch_field_row(result, "pJob"); PlayerInfo[playerid][pJob] = strval(result);
                mysql_fetch_field_row(result, "pPayCheck"); PlayerInfo[playerid][pPayCheck] = strval(result);
                mysql_fetch_field_row(result, "pHeadValue"); PlayerInfo[playerid][pHeadValue] = strval(result);
                mysql_fetch_field_row(result, "pJailed"); PlayerInfo[playerid][pJailed] = strval(result);
                mysql_fetch_field_row(result, "pJailTime"); PlayerInfo[playerid][pJailTime] = strval(result);
                mysql_fetch_field_row(result, "pMats"); PlayerInfo[playerid][pMats] = strval(result);
                mysql_fetch_field_row(result, "pDrugs"); PlayerInfo[playerid][pDrugs] = strval(result);
                mysql_fetch_field_row(result, "pWeed"); PlayerInfo[playerid][pWeed] = strval(result);
                mysql_fetch_field_row(result, "pLeader"); PlayerInfo[playerid][pLeader] = strval(result);
                mysql_fetch_field_row(result, "pMember"); PlayerInfo[playerid][pMember] = strval(result);
                mysql_fetch_field_row(result, "pRank"); PlayerInfo[playerid][pRank] = strval(result);
                mysql_fetch_field_row(result, "pPos_x"); PlayerInfo[playerid][pPos_x] = floatstr(result);
                mysql_fetch_field_row(result, "pPos_y"); PlayerInfo[playerid][pPos_y] = floatstr(result);
                mysql_fetch_field_row(result, "pPos_z"); PlayerInfo[playerid][pPos_z] = floatstr(result);
                mysql_fetch_field_row(result, "pChar"); PlayerInfo[playerid][pChar] = strval(result);
                mysql_fetch_field_row(result, "pContractTime"); PlayerInfo[playerid][pContractTime] = strval(result);
                mysql_fetch_field_row(result, "pSHealth"); PlayerInfo[playerid][pSHealth] = floatstr(result);
                mysql_fetch_field_row(result, "pHealth"); PlayerInfo[playerid][pHealth] = floatstr(result);
                mysql_fetch_field_row(result, "pRob"); PlayerInfo[playerid][pRob] = strval(result);
                mysql_fetch_field_row(result, "pInt"); PlayerInfo[playerid][pInt] = strval(result);
                mysql_fetch_field_row(result, "pLocal"); PlayerInfo[playerid][pLocal] = strval(result);
                mysql_fetch_field_row(result, "pTeam"); PlayerInfo[playerid][pTeam] = strval(result);
                mysql_fetch_field_row(result, "pModel"); PlayerInfo[playerid][pModel] = strval(result);
                mysql_fetch_field_row(result, "pPnumber"); PlayerInfo[playerid][pPnumber] = strval(result);
                mysql_fetch_field_row(result, "pPhousekey"); PlayerInfo[playerid][pPhousekey] = strval(result);
                mysql_fetch_field_row(result, "pPbiskey"); PlayerInfo[playerid][pPbiskey] = strval(result);
                mysql_fetch_field_row(result, "pCarLic"); PlayerInfo[playerid][pCarLic] = strval(result);
                mysql_fetch_field_row(result, "pFlyLic"); PlayerInfo[playerid][pFlyLic] = strval(result);
                mysql_fetch_field_row(result, "pBoatLic"); PlayerInfo[playerid][pBoatLic] = strval(result);
                mysql_fetch_field_row(result, "pFishLic"); PlayerInfo[playerid][pFishLic] = strval(result);
                mysql_fetch_field_row(result, "pGunLic"); PlayerInfo[playerid][pGunLic] = strval(result);
                mysql_fetch_field_row(result, "pArma"); PlayerInfo[playerid][pArma] = strval(result);
                mysql_fetch_field_row(result, "pDGun1"); PlayerInfo[playerid][pDGun1] = strval(result);
                mysql_fetch_field_row(result, "pDGun2"); PlayerInfo[playerid][pDGun2] = strval(result);
                mysql_fetch_field_row(result, "pDGun3"); PlayerInfo[playerid][pDGun3] = strval(result);
                mysql_fetch_field_row(result, "pDGun4"); PlayerInfo[playerid][pDGun4] = strval(result);
                mysql_fetch_field_row(result, "pDGun5"); PlayerInfo[playerid][pDGun5] = strval(result);
                mysql_fetch_field_row(result, "pGun1"); PlayerInfo[playerid][pGun1] = strval(result);
                mysql_fetch_field_row(result, "pGun2"); PlayerInfo[playerid][pGun2] = strval(result);
                mysql_fetch_field_row(result, "pGun3"); PlayerInfo[playerid][pGun3] = strval(result);
                mysql_fetch_field_row(result, "pGun4"); PlayerInfo[playerid][pGun4] = strval(result);
                mysql_fetch_field_row(result, "pAmmo1"); PlayerInfo[playerid][pAmmo1] = strval(result);
                mysql_fetch_field_row(result, "pAmmo2"); PlayerInfo[playerid][pAmmo2] = strval(result);
                mysql_fetch_field_row(result, "pAmmo3"); PlayerInfo[playerid][pAmmo3] = strval(result);
                mysql_fetch_field_row(result, "pAmmo4"); PlayerInfo[playerid][pAmmo4] = strval(result);
                mysql_fetch_field_row(result, "pPcarkey"); PlayerInfo[playerid][pPcarkey] = strval(result);
                mysql_fetch_field_row(result, "pPcarkey2"); PlayerInfo[playerid][pPcarkey2] = strval(result);
                mysql_fetch_field_row(result, "pPcarkey3"); PlayerInfo[playerid][pPcarkey3] = strval(result);
                mysql_fetch_field_row(result, "pTut"); PlayerInfo[playerid][pTut] = strval(result);
                mysql_fetch_field_row(result, "pWarns"); PlayerInfo[playerid][pWarns] = strval(result);
                mysql_fetch_field_row(result, "pFWarns"); PlayerInfo[playerid][pFWarns] = strval(result);
                mysql_fetch_field_row(result, "pLWarns"); PlayerInfo[playerid][pLWarns] = strval(result);
                mysql_fetch_field_row(result, "pWipe"); PlayerInfo[playerid][pWipe] = strval(result);
                mysql_fetch_field_row(result, "pAdjustable"); PlayerInfo[playerid][pAdjustable] = strval(result);
			}
		}
		else
		{
			new string[256], regstring[512];
			format(regstring, sizeof(regstring), "{BECBFC}Password doesn't match your name!  \n{BECBFC}Please reenter your password below to login to your account.",PlayerName(playerid));
			ShowPlayerDialog(playerid, 12347, DIALOG_STYLE_PASSWORD, "Account Login", regstring, "Login", "Quit");
	        mysql_free_result();
	        gPlayerLogTries[playerid] += 1;
	        format(string, sizeof(string), "{FF0000}ATENTIE: {FFFF00}Daca gresesti parola de 4 ori consecutiv primesti ban.Ai gresit de %d/{FF0000}4 {FFFF00}ori.", gPlayerLogTries[playerid]);
			SendClientMessage(playerid, COLOR_WHITE, string);
	        if(gPlayerLogTries[playerid] == 4) { Fuck(playerid, -1, "4 Log Tries"); } return 1;
		}
		mysql_store_result();
		TextDrawHideForPlayer(playerid, Bar1);
		TextDrawHideForPlayer(playerid, Bar2);
		PlayerInfo[playerid][pAdjustable] = 0;
		ResetPlayerMoney(playerid);
		ConsumingMoney[playerid] = 1;
		GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
		CurrentMoney[playerid] = PlayerInfo[playerid][pCash];
		if(PlayerInfo[playerid][pReg] == 0)
		{
			PlayerInfo[playerid][pLevel] = 1;
			PlayerInfo[playerid][pSHealth] = 0.0;
			PlayerInfo[playerid][pHealth] = 100.0;
			PlayerInfo[playerid][pPos_x] = 2246.6;
			PlayerInfo[playerid][pPos_y] = -1161.9;
			PlayerInfo[playerid][pPos_z] = 1029.7;
			PlayerInfo[playerid][pInt] = 0;
			PlayerInfo[playerid][pLocal] = 255;
			PlayerInfo[playerid][pTeam] = 3;
			PlayerInfo[playerid][pModel] = 7;
			new randph = randomEx(1000, 8999);
			PlayerInfo[playerid][pPnumber] = randph;
			PlayerInfo[playerid][pPhousekey] = 255;
			PlayerInfo[playerid][pPbiskey] = 255;
			PlayerInfo[playerid][pAccount] = 150000;
			PlayerInfo[playerid][pReg] = 1;
		}
		if(PlayerInfo[playerid][pLevel] < 1)
		{
			if(IsFucked(PlayerName(playerid))) { Fuck(playerid, -1, "Level"); }
			else { Fuck(playerid, -1, "Website Ban"); } return 1;
		}
		if(PlayerInfo[playerid][pLevel] == -999)
		{
			Fuck(playerid, -1, "Level -999");
			UpdatePlayer(playerid);
		}
 	    if (PlayerInfo[playerid][pLevel] >= 1)
		{
		    new plevel = PlayerInfo[playerid][pLevel];
		    new year, month, day , hour, minute, second;
		    GetPlayerIp(playerid, playersip, sizeof(playersip));
			getdate(year, month, day);
			gettime(hour, minute, second);
			format(string2, sizeof(string2), "%s s-a conectat pe server, level:%d IP: (%s).", PlayerName(playerid), plevel, playersip);
			SendAdminMessage(COLOR_YELLOW2, string2);
		 	SendHelperMessage(COLOR_YELLOW2, string2);
		 	format(string2, sizeof(string2), "[%s IP: %s] - LoginDate=%d/%d/%d at %d:%d:%d", PlayerName(playerid), playersip, day, month, year, hour, minute, second);
		 	LoginLog(string2);
		}
		ClearChatbox(playerid, 15);
		format(string2, sizeof(string2), "* Bun venit %s.",PlayerName(playerid));
		SendClientMessage(playerid, COLOR_WHITE, string2);
		printf("%s has logged in.",PlayerName(playerid));
		if (PlayerInfo[playerid][pDonateRank] == 1) { SendClientMessage(playerid, COLOR_WHITE,"* You are a {FF0000}Power User account."); }
		if (PlayerInfo[playerid][pDonateRank] == 2) { SendClientMessage(playerid, COLOR_WHITE,"* You are a {FF0000}V.I.P User account."); }
		if (PlayerInfo[playerid][pDonateRank] == 3) { SendClientMessage(playerid, COLOR_WHITE,"* You are a {FF0000}eXtra V.I.P User account."); }
		if (PlayerInfo[playerid][pAdmin] > 0)
		{
			format(string2, sizeof(string2), "* You are logged in as a {FF0000}Level %d Admin.",PlayerInfo[playerid][pAdmin]);
			SendClientMessage(playerid, COLOR_WHITE,string2);
		}
		if (PlayerInfo[playerid][pHelper] > 0)
		{
			format(string2, sizeof(string2), "* You are logged in as a {FF0000}Level %d Helper.",PlayerInfo[playerid][pHelper]);
			SendClientMessage(playerid, COLOR_WHITE,string2);
		}
		if(PlayerInfo[playerid][pWipe] == 1)
		{
		    gTeam[playerid] = 3;
            PlayerInfo[playerid][pTeam] = 3;
            PlayerInfo[playerid][pMember] = 0;
            PlayerInfo[playerid][pLeader] = 0;
            PlayerInfo[playerid][pRank] = 0;
			PlayerInfo[playerid][pChar] = 0;
			PlayerInfo[playerid][pFWarns] = 0;
			PlayerInfo[playerid][pLWarns] = 0;
		    PlayerInfo[playerid][pWipe] = 0;
		    new rand = random(sizeof(CIV));
			SetSpawnInfo(playerid, gTeam[playerid], CIV[rand], 0.0,0.0,0.0,0,0,0,0,0,0,0);
			PlayerInfo[playerid][pModel] = CIV[rand];
			MedicBill[playerid] = 0;
			SpawnPlayer(playerid);
			//UpdatePlayer(playerid);
		    SendClientMessage(playerid, -1, "{2DC7E8}[INFO] {C0C0C0}A fost wipe factions, ai primit FPK! (/fpkall)");
		}
		SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
		if(gTeam[playerid] == 0)
		{
			gTeam[playerid] = 3;
		}
		else
		{
			gTeam[playerid] = PlayerInfo[playerid][pTeam];
		}
		gPlayerLogged[playerid] = 1;
        new laststring[512], abcd[128]; new dd, mm, yy; new ore, mn, sec;
		getdate(yy, mm, dd); gettime(ore, mn, sec);
		format(laststring, sizeof(laststring), "%d.%d.%d %d:%d", dd, mm, yy, ore, mn);
		strmid(PlayerInfo[playerid][pLastLogin], laststring, 0, strlen(laststring), 255);
		format(abcd, sizeof(abcd), "UPDATE `users` SET `pLastLogin` = '%s' WHERE `pUsername` = '%s' LIMIT 1", PlayerInfo[playerid][pLastLogin], PlayerName(playerid));
		mysql_query(abcd);
		mysql_store_result();
		format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~r~~h~ %s", PlayerName(playerid));
		GameTextForPlayer(playerid, tmp2, 300, 1);
		DateProp(playerid);
		SendClientMessage(playerid, COLOR_YELLOW, motd);
		SpawnPlayer(playerid);
		new titletext[64];
		format(titletext, sizeof(titletext), "< %s >", PlayerInfo[playerid][pTitle]);
		if(strlen(PlayerInfo[playerid][pTitle]))
		{
			Update3DTextLabelText(PlayerTitleID[playerid], GetPlayerTeamColor(playerid), titletext);
		}
	}
	return 1;
}
crouch010 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Crash ahmedkoki Scripting Help 6 22/02/2014 08:11 PM
MySql Crash Shirley Scripting Help 2 08/09/2013 07:01 AM
MySQL R7 Crash Sp3cter Scripting Help 0 21/07/2013 12:57 PM
[HELP] MYSQL CRASH :( wups Help Archive 1 05/06/2010 07:27 AM
MySQL crash help Ironboy500 Help Archive 9 31/03/2010 01:01 PM


All times are GMT. The time now is 12:08 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.