MySQL Problems ...
#1

Hello,

I have a huge problem with my script.
Everything goes fine with the saving to database, loading and all other, BUT, there is a problem: on the server, id 1 and id 2 are connected to the server (this is an example). If id 1 quits, and someone else (or the same player) joins (it'll take id 1, ofc), the player with id 2 loses his stats (level, adminlevel, etc... they all get 0). This happens if any id with 1 lower connects, the next id loses his stats.
Why is that ?

This is a part of the script:

Код:
// mysql table = playerleveling
public LoadPlayerLeveling(playerid)
{
	new cereresql[80], row[512], pdata[9][32];
	format(cereresql, sizeof(cereresql), "SELECT * FROM playerleveling WHERE id=%d", PlayerInfo[playerid][pSQLID]);
	samp_mysql_query(cereresql);
	SQLLog(cereresql);
	samp_mysql_store_result();
	if (samp_mysql_num_rows() != 0)
	{
	    samp_mysql_fetch_row(row);
	    split(row, pdata, '|');
	    PlayerInfo[playerid][pLevel] = strvalEx(pdata[1]); //Level
	    PlayerInfo[playerid][pAdmin] = strvalEx(pdata[2]); ///AdminLevel
		PlayerInfo[playerid][pUpgrade] = strvalEx(pdata[3]); //UpgradePoints
		PlayerInfo[playerid][pConnectTime] = strvalEx(pdata[4]); //ConnectedTime
		PlayerInfo[playerid][pExp] = strvalEx(pdata[5]); //Respect
		PlayerInfo[playerid][pPayDay] = strvalEx(pdata[6]); //PayDay
		PlayerInfo[playerid][pPayDayHad] = strvalEx(pdata[7]); //PayDayHad
	    PlayerInfo[playerid][pPayCheck] = strvalEx(pdata[8]); //Paycheck
	}
	return 1;
}

public SavePlayerLeveling(playerid)
{
    new query[512],name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(query, sizeof(query), "UPDATE playerleveling SET PlayerLevel=%d, AdminLevel=%d, UpgradePoints=%d, ConnectedTime=%d, Respect=%d, PayDay=%d, PayDayHad=%d, Paycheck=%d WHERE id=%d",
	PlayerInfo[playerid][pLevel],//Level
	PlayerInfo[playerid][pAdmin], ///AdminLevel
	PlayerInfo[playerid][pUpgrade], //UpgradePoints
	PlayerInfo[playerid][pConnectTime], //ConnectedTime
	PlayerInfo[playerid][pExp], //Respect
	PlayerInfo[playerid][pPayDay], //PayDay
	PlayerInfo[playerid][pPayDayHad], //PayDayHad
    PlayerInfo[playerid][pPayCheck],//Paycheck
    PlayerInfo[playerid][pSQLID]);
    samp_mysql_query(query);
	SQLLog(query);
	printf("SavePlayerLeveling for %s", name);
	return 1;
}
Can someone help me, please ?
Reply
#2

Maybe you forgot to reset the variables when someone logs off or or?
Reply
#3

LoadPlayerLeveling(playerid)
SavePlayerLeveling(playerid)

load is in connect
save is in disconenct
??
Reply
#4

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
Maybe you forgot to reset the variables when someone logs off or or?
don't think so ...
Quote:
Originally Posted by gigi1223
Посмотреть сообщение
LoadPlayerLeveling(playerid)
SavePlayerLeveling(playerid)

load is in connect
save is in disconenct
??
yea, isn't it ?
Reply
#5

yea yea its correct but idk wht u get this strange thing
Reply
#6

other ideas ?
Reply
#7

Maybe the SQLID is the same as all players. I prefer to you to use user name instead id.
Reply
#8

I tried that too, same result ...
Reply
#9

and the SQL Log:

Код:
SELECT id FROM players WHERE LOWER(Name) = LOWER('Adi') LIMIT 1
SELECT reason FROM bans WHERE ip = '79.114.122.229'
SELECT * FROM bans WHERE player = 2
SELECT Locked FROM players WHERE id=2 LIMIT 1
SELECT COUNT(*) FROM players WHERE Name='Adi'
SELECT Password FROM players WHERE id = 2 LIMIT 1
SELECT * FROM players WHERE Name='Adi'
SELECT * FROM playerleveling WHERE Name='Adi'
SELECT * FROM playerprofile WHERE Name='Adi'
SELECT * FROM playerobjects WHERE Name='Adi'
SELECT * FROM playercriminalr WHERE Name='Adi'
SELECT * FROM playerskill WHERE Name='Adi'
SELECT * FROM playerkeyslyc WHERE Name='Adi'
SELECT * FROM playerignorel WHERE Name='Adi'
SELECT * FROM playerothers WHERE Name='Adi'
SELECT id FROM players WHERE LOWER(Name) = LOWER('Administrator') LIMIT 1
SELECT reason FROM bans WHERE ip = '79.114.124.20'
SELECT * FROM bans WHERE player = 1
SELECT Locked FROM players WHERE id=1 LIMIT 1
SELECT COUNT(*) FROM players WHERE Name='Administrator'
SELECT Password FROM players WHERE id = 1 LIMIT 1
SELECT * FROM players WHERE Name='Administrator'
SELECT * FROM playerleveling WHERE Name='Administrator'
SELECT * FROM playerprofile WHERE Name='Administrator'
SELECT * FROM playerobjects WHERE Name='Administrator'
SELECT * FROM playercriminalr WHERE Name='Administrator'
SELECT * FROM playerskill WHERE Name='Administrator'
SELECT * FROM playerkeyslyc WHERE Name='Administrator'
SELECT * FROM playerignorel WHERE Name='Administrator'
SELECT * FROM playerothers WHERE Name='Administrator'
UPDATE players SET `Sex`=1, `Age`=17, `Origin`=1, `Money`=900, `Bank`=1234, `Leader`=0, `Member`=0, `FMember`=255, `FRank`=0, `Rank`=0, `pSHealth`=0.000000, `pHealth`=100.000000, `Interior`=0, `Local`=255, `Team`=6, `Skin`=23, `ShopSkin`=3, `Char`=49, `Job`=0, `Locked`=0, `Tutorial`=1, `Registered`=1 WHERE Name='Adi'
UPDATE playerleveling SET PlayerLevel=10, AdminLevel=1337, UpgradePoints=0, ConnectedTime=0, Respect=0, PayDay=0, PayDayHad=2, Paycheck=2200 WHERE Name='Adi'
UPDATE playerprofile SET DateReg='10.5.2010', BornDay=24, BornMonth=12, Birthday=0, Question='Nobody', QuestionVar=1, WarnName1='Nobody', WarnName2='Nobody', WarnReason1='Empty', WarnReason2='Empty', WarnDate1='0.0.0', WarnDate2='0.0.0', Muted=0, MuteTime=0, Warnings=0, Married=0, Mto='' WHERE Name='Adi'
UPDATE playerobjects SET PhoneNr=5854, Phonebook=0, LottoNr=50, Fishes=51, BiggestFish=0, Materials=0, Drugs=0, Gun1=0, Gun2=0, Gun3=0, Gun4=0, Ammo1=0, Ammo2=0, Ammo3=0, Ammo4=0, Fuel=0, Walkie=0, HouseMaterials=0, HouseDrugs=0, Injections=0, ATF=0, Beer=0, Wine=0, Sprunk=0, Smoke=0, CardPassword=1234 WHERE Name='Adi'
UPDATE playercriminalr SET Crimes=0, Kills=0, Deaths=1, Arrested=0, WantedDeaths=0, HeadValue=0, Jailed=0, JailTime=0, ContractTime=0, Wins=0, Loses=0, JailCell=0, WantedLevel=1, WantedPoints=0 WHERE Name='Adi'
UPDATE playerskill SET DetSkill=0, SexSkill=0, LawSkill=0, MechSkill=0, JackSkill=0, CarSkill=0, NewsSkill=0, DrugsSkill=0, FishSkill=0, CarTime=0, AlcoholPerk=0, DrugPerk=0, MiserPerk=0, PainPerk=0, TraderPerk=0, FightStyle=0, FindTime=0, PistolSkill=0, SDPistolSkill=0, DeagleSkill=0, ShotgunSkill=0, MP5Skill=0, AK47Skill=0, M4Skill=0, SniperSkill=0 WHERE Name='Adi'
UPDATE playerkeyslyc SET House=255, Bizz=4, CarLic=1, FlyLic=1, BoatLic=1, FishLic=1, ShamalLic=1, Passport=1, GunLic=1, ForbbidenLic=0 WHERE Name='Adi'
UPDATE playerignorel SET Ignore1='Empty', Ignore2='Empty', Ignore3='Empty', Ignore4='Empty', Ignore5='Empty', Ignore6='Empty', Ignore7='Empty', Ignore8='Empty', Ignore9='Empty', Ignore10='Empty' WHERE Name='Adi'
UPDATE playerothers SET Mission=0, MSG='Empty', DriveRoom=0, LockBank=0, RoadBlock=0, CopSpawn=0, TaxiSpawn=0, MedicSpawn=0, SchoolSpawn=0, NewsSpawn=0, HouseSpawn=1, MolotovTime=0, MolotovCocktail=0, WhisperColor=21, Coordonator=0, VIP=1 WHERE Name='Adi'
SELECT id FROM players WHERE LOWER(Name) = LOWER('Adi') LIMIT 1
SELECT reason FROM bans WHERE ip = '79.114.122.229'
SELECT * FROM bans WHERE player = 2
SELECT Locked FROM players WHERE id=2 LIMIT 1
SELECT COUNT(*) FROM players WHERE Name='Adi'
SELECT Password FROM players WHERE id = 2 LIMIT 1
SELECT * FROM players WHERE Name='Adi'
SELECT * FROM playerleveling WHERE Name='Adi'
SELECT * FROM playerprofile WHERE Name='Adi'
SELECT * FROM playerobjects WHERE Name='Adi'
SELECT * FROM playercriminalr WHERE Name='Adi'
SELECT * FROM playerskill WHERE Name='Adi'
SELECT * FROM playerkeyslyc WHERE Name='Adi'
SELECT * FROM playerignorel WHERE Name='Adi'
SELECT * FROM playerothers WHERE Name='Adi'
UPDATE players SET `Sex`=0, `Age`=0, `Origin`=0, `Money`=1900, `Bank`=0, `Leader`=0, `Member`=0, `FMember`=0, `FRank`=0, `Rank`=0, `pSHealth`=0.000000, `pHealth`=100.000000, `Interior`=0, `Local`=255, `Team`=6, `Skin`=23, `ShopSkin`=3, `Char`=49, `Job`=0, `Locked`=0, `Tutorial`=1, `Registered`=0 WHERE Name='Administrator'
UPDATE playerleveling SET PlayerLevel=0, AdminLevel=0, UpgradePoints=0, ConnectedTime=0, Respect=0, PayDay=0, PayDayHad=2, Paycheck=2517 WHERE Name='Administrator'
UPDATE playerprofile SET DateReg='10.5.2010', BornDay=24, BornMonth=12, Birthday=0, Question='Nobody', QuestionVar=1, WarnName1='Nobody', WarnName2='Nobody', WarnReason1='Empty', WarnReason2='Empty', WarnDate1='0.0.0', WarnDate2='0.0.0', Muted=0, MuteTime=0, Warnings=0, Married=0, Mto='' WHERE Name='Administrator'
UPDATE playerobjects SET PhoneNr=5854, Phonebook=0, LottoNr=50, Fishes=52, BiggestFish=0, Materials=0, Drugs=0, Gun1=0, Gun2=0, Gun3=0, Gun4=0, Ammo1=0, Ammo2=0, Ammo3=0, Ammo4=0, Fuel=0, Walkie=0, HouseMaterials=0, HouseDrugs=0, Injections=0, ATF=0, Beer=0, Wine=0, Sprunk=0, Smoke=0, CardPassword=1234 WHERE Name='Administrator'
UPDATE playercriminalr SET Crimes=0, Kills=0, Deaths=0, Arrested=0, WantedDeaths=0, HeadValue=0, Jailed=0, JailTime=0, ContractTime=0, Wins=0, Loses=0, JailCell=0, WantedLevel=1, WantedPoints=0 WHERE Name='Administrator'
UPDATE playerskill SET DetSkill=0, SexSkill=0, LawSkill=0, MechSkill=0, JackSkill=0, CarSkill=0, NewsSkill=0, DrugsSkill=0, FishSkill=0, CarTime=0, AlcoholPerk=0, DrugPerk=0, MiserPerk=0, PainPerk=0, TraderPerk=0, FightStyle=0, FindTime=0, PistolSkill=0, SDPistolSkill=0, DeagleSkill=0, ShotgunSkill=0, MP5Skill=0, AK47Skill=0, M4Skill=0, SniperSkill=0 WHERE Name='Administrator'
UPDATE playerkeyslyc SET House=255, Bizz=4, CarLic=1, FlyLic=1, BoatLic=1, FishLic=1, ShamalLic=1, Passport=1, GunLic=1, ForbbidenLic=0 WHERE Name='Administrator'
UPDATE playerignorel SET Ignore1='Empty', Ignore2='Empty', Ignore3='Empty', Ignore4='Empty', Ignore5='Empty', Ignore6='Empty', Ignore7='Empty', Ignore8='Empty', Ignore9='Empty', Ignore10='Empty' WHERE Name='Administrator'
UPDATE playerothers SET Mission=0, MSG='Empty', DriveRoom=0, LockBank=0, RoadBlock=0, CopSpawn=0, TaxiSpawn=0, MedicSpawn=0, SchoolSpawn=0, NewsSpawn=0, HouseSpawn=1, MolotovTime=0, MolotovCocktail=0, WhisperColor=21, Coordonator=0, VIP=1 WHERE Name='Administrator'
Reply
#10

may it be a login problem ... ?

Код:
public OnPlayerLogin(playerid,password[])
{
	new tmp2[64],tmp[64];
    new string2[64];
	new playername[MAX_PLAYER_NAME];
	MySQLCheckConnection();
    GetPlayerName(playerid, playername, sizeof(playername));
    format(tmp, sizeof(tmp), "SELECT COUNT(*) FROM players WHERE Name='%s'", playername);
    SQLLog(tmp);
    samp_mysql_query(tmp);
	//if (DEBUG) SQLLog(tmp);
    samp_mysql_store_result();
    samp_mysql_fetch_row(tmp);
	new registered = strval(tmp);
	if (registered > 0)
 	{
	  	if (!strlen(password))
		{
		    ShowPlayerDialog(playerid,5,DIALOG_STYLE_INPUT,"Autentificare","Ati introdus o parola gresita !\nVa rugam sa introduceti parola corecta !\n\n\n\n\t\t\t\tLinkMania","Login","Iesire");
			SendClientMessage(playerid, 0xE24541FF, "SERVER: Ai introdus o parola gresita !");
	        gPlayerLogTries[playerid] += 1;
	        if(gPlayerLogTries[playerid] == 4)
			{
				new banip[16];
				GetPlayerIp(playerid, banip, sizeof(banip));
				new string[128];
				GetPlayerName(playerid, playername, sizeof(playername));
				format(string, sizeof(string), "Parola gresita de 4 ori : %s", playername);
				AddBan("LinkMania", 999999, banip, string,0);
			}
	        return 1;
		}
		new ipaddress[16];
		GetPlayerIp(playerid, ipaddress, sizeof(ipaddress));
		MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pKey]);
		if(strcmp(PlayerInfo[playerid][pKey],password,false) == 0) // aaa != AAA
		{
			LoadPlayerData(playerid);
			LoadPlayerLeveling(playerid);
			LoadPlayerProfile(playerid);
			LoadPlayerObjects(playerid);
			LoadPlayerCriminalR(playerid);
			LoadPlayerSkill(playerid);
			LoadPlayerKeysLyc(playerid);
			LoadPlayerIgnoreL(playerid);
			LoadPlayerOthers(playerid);
		}
		else
		{
		    ShowPlayerDialog(playerid,5,DIALOG_STYLE_INPUT,"Autentificare","Ati introdus o parola gresita !\nVa rugam sa introduceti parola corecta !\n\n\n\n\t\t\t\tLinkMania","Login","Iesire");
			SendClientMessage(playerid, 0xE24541FF, "SERVER: Ati introdus o parola gresita !");
	        gPlayerLogTries[playerid] += 1;
	        if(gPlayerLogTries[playerid] == 4)
			{
			    new banip[16];
				GetPlayerIp(playerid, banip, sizeof(banip));
				new string[128];
				GetPlayerName(playerid, playername, sizeof(playername));
				format(string, sizeof(string), "Parola gresita de 4 ori : %s", playername);
				AddBan("LinkMania", 999999, banip, string,0);
			}
	        return 1;
		}
		new string[256];
		ResetPlayerCash(playerid);
		ConsumingMoney[playerid] = true;
		GivePlayerCash(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][pInt] = 15;
			PlayerInfo[playerid][pLocal] = 255;
			PlayerInfo[playerid][pTeam] = 3;
			PlayerInfo[playerid][pSkin] = 183;
			new randphone = 1000 + random(8999);
			PlayerInfo[playerid][pPnumber] = randphone;
			PlayerInfo[playerid][pPhousekey] = 255;
			PlayerInfo[playerid][pPbiskey] = 255;
			PlayerInfo[playerid][pAccount] = 5000;
			PlayerInfo[playerid][pReg] = 1;
			ResetPlayerCash(playerid);
			GivePlayerCash(playerid,1000);
		}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)