Jump to content
  • 0

Ajutor MySQL Save player


AsSsASIN

Question

Recommended Posts

pai daca se deconecteaza inseamna ca e ceva in neregula , adica nu e ca semnalul la telefon ba ai semnal ba nu ai semnal , nu are cum sa se conecteze si pe urma sa se deconecteze , conectare in sensul de , s-a conectat cu succes la baza de date (datele sunt corecte si baza de date este functionala) sau nu s-a conectat (datele sunt gresite sau baza de date nu este functionala)

Link to comment
Share on other sites

public SavePlayerData(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid])
		{
            printf("MySQL: Ping: %i",mysql_ping());
			new string[MAX_STRING];
			format(string, MAX_STRING, "UPDATE players SET ");
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE players SET password=%d, Level=%d, AdminLevel=%d, DonateRank=%s WHERE id=%d", PlayerInfo[playerid][pKey], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
			PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
		    format(string, MAX_STRING, "UPDATE players SET PointsUpgrade=%d, ConnectedTime=%d, Reg=%d, Sex=%d, Age=%d, Origin=%d', CK=%d WHERE id=%d", PlayerInfo[playerid][gPupgrade], PlayerInfo[playerid][pConnectTime], PlayerInfo[playerid][pReg], PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pOrigin], PlayerInfo[playerid][pCK], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
		    format(string, MAX_STRING, "UPDATE `players` SET `Muted` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Exp` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pExp], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Cash` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `AccountBank` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAccount], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CrimesComited` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCrimes], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Kills` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Deaths` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Arrested` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pArrested], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `WantedDeaths` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWantedDeaths], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Phonebook` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhoneBook], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `LottoNr` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLottoNr], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Fishes` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishes], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `BiggestFish` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBiggestFish], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Job` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJob], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `PayCheck` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayCheck], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `HeadValue` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pHeadValue], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Jailed` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `JailTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJailTime], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Mats` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMats], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Drugs` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugs], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Leader` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLeader], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Member` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMember], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `FMember` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFMember], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Rank` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pRank], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Char` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pChar], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `ContractTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pContractTime], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `DetSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDetSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `SexSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pSexSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `BoxSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBoxSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `LawSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhoneBook], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `MechSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMechSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `JackSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJackSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CarSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `NewsSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pNewsSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `DrugsSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugsSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CookSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCookSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `FishSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishSkill], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `pHealth` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `pSHealth` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pSHealth], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Int` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pInt], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Local` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLocal], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Team` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Model` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pModel], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Pnumber` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPnumber], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Phousekey` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhousekey], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Pbiskey` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPbiskey], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
			if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0)) {
				PlayerInfo[playerid][pPos_x] = 1684.9;
				PlayerInfo[playerid][pPos_y] = -2244.5;
				PlayerInfo[playerid][pPos_z] = 13.5;
			}
            format(string, MAX_STRING, "UPDATE `players` SET `Pos_x` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Pos_y` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Pos_z` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CarLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarLic], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `FlyLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFlyLic], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `BoatLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBoatLic], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `FishLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishLic], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `GunLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGunLic], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Gun1` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Gun2` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Gun3` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Gun4` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Ammo1` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo1], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Ammo2` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo2], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Ammo3` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo3], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Ammo4` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo4], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CarTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarTime], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `PayDay` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayDay], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `PayDayHad` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayDayHad], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `CDPlayer` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCDPlayer], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Wins` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWins], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Loses` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLoses], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `AlcoholPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAlcoholPerk], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `DrugPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugPerk], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `MiserPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMiserPerk], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `PainPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPainPerk], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `TraderPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTraderPerk], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Tut` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTut], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `MissionNr` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMissionNr], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Warns` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Adjustable` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAdjustable], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Fuel` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFuel], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `Married` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMarried], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
            format(string, MAX_STRING, "UPDATE `players` SET `MarriedTo` = '%s' WHERE `id` = '%d'", PlayerInfo[playerid][pMarriedTo], PlayerInfo[playerid][pSQLID]);
            mysql_query(string);
		}
	}
	return 1;
}

la database nu am default un cifru.

farse e nesimtit, credeam ca o sa ma ajute el :))

Link to comment
Share on other sites

Adauga mysql_debug( 1 ); la OnGameModeInit.

La inceput ai mysql_query( "UPDATE players` SET " ); nu-i completa sintaxa.

Si ca sa salvezi cateva randuri, poti face si asa:

UPDATE `players` SET `coloana` = 1, `coloana2` = 2, coloana3` = 3, `coloanan` = 4 WHERE `rand` = 'nume';"

%d se foloseste pentru numere intregi, iar pentru numere reale se foloseste %f.

Link to comment
Share on other sites

De exemplu, asta este bun?

UPDATE `players` SET `Level`, `AdminLevel`, Sex`, `Age` WHERE `id` = '%s' 

1. Diferenta intre %d si %f ?

2. Trebuie toate intr-o syntaxa, sau 5.6 in una?

Daca daca folosesti %d pentru numere reale atunci va imprima alte valori decat cele dorite de tine.

In legatura cu sintaxa, am uitat sa atribui unei coloane valorile, mi-am modificat mesajul initial.

La cate ai, nu cred ca poti sa le pui pe toate intr-un singur query, pentru ca format are o limita.

Link to comment
Share on other sites

Noua Syntaxa este buna ?

format(query, MAX_STRING, "UPDATE `players` SET `Level` = %d, `AdminLevel` = %d, `DonateRank` = %d, `PointsUpgrade` = %d WHERE `username` = %d", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][gPupgrade], PlayerInfo[playerid][pSQLID]);

Link to comment
Share on other sites

username este string,deci este %s.

format(query, MAX_STRING, "UPDATE `players` SET `Level` = %d, `AdminLevel` = %d, `DonateRank` = %d, `PointsUpgrade` = %d WHERE `username` = %s", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][gPupgrade],pName(playerid));

Dar,deschide phpmyadmin ,mergi la db,dai edit pe una dintre inregistrari(daca nu ai ,dai la insert si pune si tu niste date la intamplare) si pune la fiecare %d sau %s(%s unde ai varchar) si o sa iti genereze el codul bun:)

Uite cum am eu facut(la un gm mai vechi...)

	format(str,600,"UPDATE `users` SET `IP` = '%s',\
	`Email` = '%s',\
	`RegisterDate` = '%s',\
	`LastOn` = '%s',\
	`Language` = '%d',\
	`ALevel` = '%d',\
	`FavColor` = '%d',\
	`Round_Win` = '%d',\
	`VIP` = '%d',",IPp[playerid],Pi[a_Email],Pi[RegisterDate],Pi[LastOn],Pi[Language],Pi[Level],Pi[FavColor],Pi[RoundWin],Pi[VIP]);
	format(str,600,"%s\
	`UPLOADER` = '%d',\
	`RANK` = '%d',\
	`NoJoin` = '%d',\
	`DAYS` = '%d',\
	`HOURS` = '%d',\
	`MINUTES` = '%d',\
	`SECONDS` = '%d',\
	 WHERE `name` ='%s'",str,Pi[UPLOADER],Pi[Rank],Pi[NoJoin],Pi[Days],Pi[Hours],Pi[MINUTES],Pi[SECONDS],ReturnName(playerid));
	mysql_query(str);

Si merge :D

Link to comment
Share on other sites

public SavePlayerData(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid])
		{
			new query[MAX_STRING];
			format(query, MAX_STRING, "UPDATE players SET ");
            mysql_query(query);
			PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
			if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0)) {
				PlayerInfo[playerid][pPos_x] = 1684.9;
				PlayerInfo[playerid][pPos_y] = -2244.5;
				PlayerInfo[playerid][pPos_z] = 13.5;
			}
            format(query, MAX_STRING, "UPDATE `players` SET `Level` = `%d`,\
		    `AdminLevel` = `%d`,\
		    `DonateRank` = `%d`,\
			`PointsUpgrade` = `%d`,\
			`ConnectTime` = `%d`,\
			`Reg` = `%d`,\
			`Sex` = `%d`\
			WHERE `username` = `%s`", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][gPupgrade], ReturnName(playerid));
            mysql_query(query);
		}
	}
	return 1;
}

ce tot are, ce am gresit iara :|?

Link to comment
Share on other sites

public SavePlayerData(playerid)
{
	if(gPlayerLogged[playerid])
	{
		new query[MAX_STRING];
		PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
		if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0))
		{
			PlayerInfo[playerid][pPos_x] = 1684.9;
			PlayerInfo[playerid][pPos_y] = -2244.5;
			PlayerInfo[playerid][pPos_z] = 13.5;
		}
  		format(query, MAX_STRING, "UPDATE `players` SET `Level` = '%d', `AdminLevel` = '%d', `DonateRank` = '%d', `PointsUpgrade` = '%d', `ConnectTime` = '%d', `Reg` = '%d', `Sex` = '%d' WHERE `username` = '%s';", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][gPupgrade], ReturnName(playerid));
    	        mysql_query(query);
	}
	return 1;
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Similar Content

    • By D3m0n1K
      Buna Seara, descriere problema : cand ajung la dmv si scriu exam, nu imi afiseaza astea, daca doriti pot adauga liniile care este nevoie.
       
       
    • By AndreiiGL
      Salut, am o problema la comanda /work daca ma poate ajuta cineva, sunt incepator.
      https://pastebin.com/RJp8stDV
       
      Erorile:
      C:\Users\Andrei\Downloads\filehost_BLACKWEED (2)\BLACKWEED\gamemodes\1t4p.pwn(31022) : error 014: invalid statement; not in switch
      C:\Users\Andrei\Downloads\filehost_BLACKWEED (2)\BLACKWEED\gamemodes\1t4p.pwn(31022) : warning 215: expression has no effect
      C:\Users\Andrei\Downloads\filehost_BLACKWEED (2)\BLACKWEED\gamemodes\1t4p.pwn(31022) : error 001: expected token: ";", but found ":"
      C:\Users\Andrei\Downloads\filehost_BLACKWEED (2)\BLACKWEED\gamemodes\1t4p.pwn(31022) : error 029: invalid expression, assumed zero
      C:\Users\Andrei\Downloads\filehost_BLACKWEED (2)\BLACKWEED\gamemodes\1t4p.pwn(31022) : fatal error 107: too many error messages on one line
    • By Arabu
      Halloween systems - with MySQL R39 
      Autor : Edison
        [INFORMATIONS]:
      Every 10 minutes will be an event where you need to look for a pumpkin.
      You can earn a random amount of money and halloween points.
      With halloween points you can buy items from /shop.
      There's also a minigame (Players vs. Zombie) - (/startevent 2). The winning team earns random money and Halloween points.
       
       
      [COMMANDS]:
      /pumpkin - view event informations.
      /shop - shop with items (buy with halloween points)
      /togitems - enable/disable items
      /gotopumpkin (for RCON Admin) - to go to the pumpkin.
      /givepoints (for RCON Admin) - to set halloween points.
      /startevent (for RCON Admin) - to start an event/minigame.
       
      Download Link: http://bit.ly/halloweenfs
      Photos:
          
          
    • By AndreiSAMP2
      :\Users\Karol\Desktop\devised\gamemodes\devised.pwn(12) : fatal error 100: cannot read from file: "AutoAFK"
    • By WiDuAlK
      Salutare, azi am sa va prezint cum sa faceti un tutorial register/login mysql R39.
      Mai intai o sa va trebuiasca pluginul si includeul mysql care ip puteti gasi AICI!
      Mai intai o sa punem la inceputul GM-ului include-ul mysql.
       
      #include <a_mysql>  
      Acum o sa definim datele de conectare
      #define mysql_host "localhost" // aici punem ip hostului. Daca folosim in PC GM lasam localhost #define mysql_db "bazadate"// aici punem numele bazei de date. #define mysql_user "root"// aici punem numele userului de la host. Daca folositi PC lasati root. #define mysql_pass ""//Aici puneti parola de la host(de la phpmyadmin al hostului). In caz de folositi PC lasati asa.  
      Vom crea 2 Enum-uri. Unul cu dialogurile de register/login si altul cu datele pe care le va avea playerul
      enum {     DIALOG_LOGIN, // dialogul de login     DIALOG_REGISTER// dialogul de register }; enum pInfo //numele enumului este pInfo. in el vom pune datele playerului gen Admin/Level/ Money/Experianta si altele. {     pParola,//cu pParola vom lua parola din baza de date a playerului     pID// cu pID vom lua ID-ul din baza de date a playerului }; new P_Data[MAX_PLAYERS][pInfo];// Aceasta variabila este array. cu ea vom verifica 2 lucruri. id playerului si datele lui gen P_Data[playerid][pID] == 1;  
      Vom crea acum un new care ne va ajuta sa conectam datele de conectarea cu baza de date
      new handle; // handle(mâner) este cea de care ne vom folosi sa facem lagatura intre baza de date si server Acum vom crea legatura intre baza de date si server.
       
      forward MySQLConnect();// se creaza un nou callback cu forward public MySQLConnect()// se face callback-ul {     handle = mysql_connect(mysql_host, mysql_user, mysql_db, mysql_pass);// definim handle(manerul) ca fiind conectarea mysql la host, baza de date, parola si user-ul     if(mysql_errno() != 0)// in caz ca aceasta va fi diferita de 0(0 inseamna ca e conectat, 1 inseamna ca nu e conectat , fiind un vector)     {         printf("Conexiunea la baza de date %s a esuat ---> Server Inchis ~~~", mysql_db);// va trimite un mesaj in consola         SendRconCommand("exit");// se inchide serverul     }     else// altfel daca este 0(daca se face legatura)     {         printf("Conexiunea la baza de date '%s' cu user-ul '%s' a reusit!!!", mysql_db, mysql_user);// ne va da acest mesaj in consola     }     return 1; }  
      Callback-ul MySQLConnect se va pune la OnGameModeInit pentru a fi finalizata conectarea la baza de date.
      public OnGameModeInit() {     MySQLConnect();     return 1; } Se va crea un stock simplu cu care vom selecta numele playerului
       
      stock GetName(playerid) { new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name)); return Name; }  
      Acum vom se va crea un nou callback , la care vom apela cand playerul se conecteaza. El va arata daca are cont sau nu.
       
      forward OnPlayerLogin(playerid);// se creaza callbac-ul public OnPlayerLogin(playerid)//Se creaza publicul {     new rows, fields;// definim rows(randurile)si fields(domeniile)     cache_get_data(rows, fields);//cache_get_data interogheaza date din baza de date. acele date sunt rows si fields     if(rows)// atunci cand playerul se inregistreaza i se va crea niste randuri. Daca i se gasesc atunci cand se va conecta ii va da:     {         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Logheaza-te!", "Te rog sa-ti introduci parola contuului mai jos!", "Logare", "Exit");// dialogul register     }     else// daca nu i se gasesc randuri, adica daca contul nu exista, atunci i se va da urmatorul dialog     {         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Inregistrare", "Trebuie sa iti creezi un cont ca sa joci pe server. nTasteaza mai jos o parola, pentru a te inregistra!", "Inregistreaza", "Exit");// dialogul register     }     return 1; }  
      Acum ca am creat dialogul care ne ajuta sa verificam daca playerul are cont sau nu , mergem la OnPlayerConnect si punem urmatoarele:
       
      public OnPlayerConnect(playerid) {     new query[100];// definim query(interogare)     mysql_format(handle, query, sizeof(query), "SELECT * FROM conturi WHERE Nume = '%s'", GetName(playerid));// mysql format face interogarile/setarile/obtiunile/updateurile la baza de date     //handle reprezinta conectarea la mysql, query si sizeof(queri) reprezinta interogarea     //"SELECT * FROM conturi WHERE Nume = '%s'"- Selecteaza de la tabelul cu conturi, unde numele este %s(de exemplu eu am numele Widualk pe sa-mp. Mi se va extrage numele si     mysql_tquery(handle, query, "OnPlayerLogin", "i", playerid);// se va interoga OnPlayerLogin. Adica mai pe scurt , cand se conecteaza se va verifica daca are cont sau nu acel player.     return 1; }  
      Acum ca am terminat cu callback-urile de la conectare, vom crea dialogurile.
       
      public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {     new query[128], ip[25];// se creaza interogarea si ip.     switch(dialogid)// se va folosi switch pentru a selecta dialogul     {         case DIALOG_REGISTER:// daca se va selecta dialogul register         {             if(!response)                     return Kick(playerid);// daca se va apasa pe butonul Exit ii va da kick             if(response)// daca se apasa pe Butonul inregistrare se vor face urmatoarele verificari             {                 if(!strlen(inputtext))// daca nu e scris nimic la parola                         return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Introdu-ti o parola pentru a te inregistra pe server! n", "Inregistreaza", "Exit");// ii va da din nou dialogul register cu mesajul specific                 GetPlayerIp(playerid, ip, sizeof(ip));// definim ip-ul de mai sus                 mysql_format(handle, query, sizeof(query), "INSERT INTO conturi (Nume, Parola, IP) VALUES ('%s', '%e', '%s')", GetName(playerid), inputtext, ip);// se insereaza in tabelul cu conturi numele playerului, parola pe care a scris-o si ip pe care il are                 mysql_query(handle, query);// se va trimite setarile si se va interoga callback-ul OnRegistration                 SpawnPlayer(playerid); // ii da spawn             }             return 1;         }         case DIALOG_LOGIN:// daca se va selecta dialogul de login         {             if(!response) return Kick(playerid);// si se va apasa pe butonul exit ii va da kick             if(response)//daca se apasa pe butonul LOGARE se va face urmatoarele verificari             {                 if(!strlen(inputtext))// daca nu a scris nimic la parola                         return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");// ii va da dialogul cu login cu mesajul specific                 // daca se va trece peste aceasta verificare se vor face urmatoarele:                 mysql_format(handle, query, sizeof(query), "SELECT * FROM `conturi` WHERE `Nume`='%e' AND `Parola` = '%e'", GetName(playerid),inputtext);// va fi selectata parola de la tabelul cu conturi mysql_tquery(handle, query, "OnLogin", "i", playerid);// se va face apel la baza si se va interoga CallBackUl OnLogin (Tquery = take query sau ia interogare in romana)             }             return 1;         }     }     return 1; }  
      Acum , ca am facut dialogurile , vom crea calback-urile care se interogheaza la dialogurile de mai sus.
      Vom crea callback-ul pentrul dialogul de register.
       
      Acum , vom crea callback-ul la care apeleaza dialogul de login
       
      forward OnLogin(playerid);// definim callback ul public OnLogin(playerid)// facem publicul {     new rows, fields,temporar[200];// definim randurile si domeniile, iar temporar se va folosi la extragerea stringurilor     cache_get_data(rows, fields);// facem interogarea lor     if(rows)// daca playerul are randuri(adica daca are cont creat, odata cu contul se creeaza randurile)     {         //deci daca are randuri         cache_get_field_content(0, "Parola",temporar), format(P_Data[playerid][pParola], 25, temporar);// i se vaextrage parola si i se verifica daca coincide cu numele. Se foloseste new-ul temporar pentru extragerea parolei, ea retinandu-se temporar(pana cand se deconecteaza jucatorul)         P_Data[playerid][pID] = cache_get_field_content_int(0, "ID");// i se vaextrage ip-ul         //un exemplu ar fi , daca are Admin , va fi ceva de genu P_Data[playerid][pAdmin] = cache_get_field_content_int(0,"Admin)"; i se va extrage din baza de date levelul de admin si i se va returna pe server, mai precis, cand se conecteaza are levelul de admin , care i-a fost setat de owner         SpawnPlayer(playerid);// si se va da spawn     }     else// altfel , daca parola este gresita     {         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");// ii va da dialogul cu mesajul specific.     }     return 1; } Iar la final punem la OnGameModeExit();
      public OnGameModeExit() {     mysql_close( handle ) ;// deconectam serverul de la baza de date, daca se inchide     return 1; } Acum , o sa recapitulam.
      Playerul are nevoie de ID, Nume, Parola si IP, deci 4 coloane in tabel.
      Tabelul se numeste "conturi", deoarece interogarea se face acolo "mysql_format(handle, query, sizeof(query), "SELECT * FROM conturi"-conturi este tabelul unde vor aparea ID ,Nume, Parola, IP
      Baza de date se numeste "bazadate" din: #define mysql_db "bazadate"
       
      O sa va arat acum cum se creaza tabelul.
      Pasul 1. Definim baza de date cu numele "basedate":

      Pasul 2: Se selecteaza noua baza:

      Pasul 3: Se creaza tabelul cu cele 4 coloane:

      Pasul 4: Se definesc coloanele , cu fiecare setare

      La tip    INT = intenger= numar de cifre.
                   Varchar = string = sir de caractere(litere)
      la Lungimea / setare se selecteaza cat spatiu se acorda, adica cate caractere incap maxim in acel tabel
       la id va fi maxim 9999999999(sun 10 cifre consecutive de "9", adica acel numar va fi maximul de playeri care pot avea cont)
       la nume, se va putea salva doar numele care contine doar 25 de caractere(adica daca numele depaseste 25 litere, doar primele 25 se vor salva)
      la interclasare la Varchar , mereu sa puneti latin1_sweadich_ci, de ce, asta nu pot spune nici eu , dar , stiu ca asa trebuie
      La ID tot timpul sa bifati casuta "A_I(auto Increment)" care va genera singur id-ul, altfel nu va merge tabelul conturi
       
      Asa ar trebui sa va arata , atunci cand va inregistrati:

       
      Atentie tutorial creat 100% de Widualk. Nerespectarea creditelor va duce la sanctiuni!
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.