[Plugin] [REL] MySQL Plugin (Now on github!)

yea, I solved the problem lolz.
The real problem was that, I didnt have "Stuff".cfg xD

But yeah now its problem with "OnPlayerLogin". Everytime I log in, then samp-server.exe stops working.
I think I have done wrong in OnPlayerlogin edit.
Here my current code.

Код:
public OnPlayerLogin(playerid,password[])
{
	MySQLCheckConnection();

	new tmp2[256];
  new string2[64];
	new playername2[MAX_PLAYER_NAME];
	new playernamesplit[3][MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername2, sizeof(playername2));
	split(playername2, playernamesplit, '_');
	MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pKey]);
	if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
	{
		new Data[1024];
		new Field[64];
		MySQLFetchAcctRecord(PlayerInfo[playerid][pSQLID], Data);
		//new idx;
		//new Fields = mysql_field_count();
		for(new rcnt = 1; mysql_fetch_field(rcnt, Field); rcnt++)
		{
			// The rcnt values here represent the order of the columns in the characters table, so don't mess with them
			// If you add a column to the table, just add a new line with a +1 rcnt to the block below
			// Start it at 3 to skip the first few records we don't need (id, player name, password)
			if (rcnt == 3) PlayerInfo[playerid][pLevel] = strval(Field);
			if (rcnt == 4) PlayerInfo[playerid][pAdmin] = strval(Field);
			if (rcnt == 5) PlayerInfo[playerid][pDonateRank] = strval(Field);
			if (rcnt == 6) PlayerInfo[playerid][gPupgrade] = strval(Field);
			if (rcnt == 7) PlayerInfo[playerid][pConnectTime] = strval(Field);
			if (rcnt == 8) PlayerInfo[playerid][pReg] = strval(Field);
			if (rcnt == 9) PlayerInfo[playerid][pSex] = strval(Field);
			if (rcnt == 10) PlayerInfo[playerid][pAge] = strval(Field);
			if (rcnt == 11) PlayerInfo[playerid][pOrigin] = strval(Field);
			if (rcnt == 12) PlayerInfo[playerid][pCK] = strval(Field);
			if (rcnt == 13) PlayerInfo[playerid][pMuted] = strval(Field);
			if (rcnt == 14) PlayerInfo[playerid][pExp] = strval(Field);
			if (rcnt == 15) PlayerInfo[playerid][pCash] = strval(Field);
			if (rcnt == 16) PlayerInfo[playerid][pAccount] = strval(Field);
			if (rcnt == 17) PlayerInfo[playerid][pCrimes] = strval(Field);
			if (rcnt == 18) PlayerInfo[playerid][pKills] = strval(Field);
			if (rcnt == 19) PlayerInfo[playerid][pDeaths] = strval(Field);
			if (rcnt == 20) PlayerInfo[playerid][pArrested] = strval(Field);
			if (rcnt == 21) PlayerInfo[playerid][pWantedDeaths] = strval(Field);
			if (rcnt == 22) PlayerInfo[playerid][pPhoneBook] = strval(Field);
			if (rcnt == 23) PlayerInfo[playerid][pLottoNr] = strval(Field);
			if (rcnt == 24) PlayerInfo[playerid][pFishes] = strval(Field);
			if (rcnt == 25) PlayerInfo[playerid][pBiggestFish] = strval(Field);
			if (rcnt == 26) PlayerInfo[playerid][pJob] = strval(Field);
			if (rcnt == 27) PlayerInfo[playerid][pPayCheck] = strval(Field);
			if (rcnt == 28) PlayerInfo[playerid][pHeadValue] = strval(Field);
			if (rcnt == 29) PlayerInfo[playerid][pJailed] = strval(Field);
			if (rcnt == 30) PlayerInfo[playerid][pJailTime] = strval(Field);
			if (rcnt == 31) PlayerInfo[playerid][pMats] = strval(Field);
			if (rcnt == 32) PlayerInfo[playerid][pDrugs] = strval(Field);
			if (rcnt == 33) PlayerInfo[playerid][pLeader] = strval(Field);
			if (rcnt == 34) PlayerInfo[playerid][pMember] = strval(Field);
			if (rcnt == 35) PlayerInfo[playerid][pFMember] = strval(Field);
			if (rcnt == 36) PlayerInfo[playerid][pRank] = strval(Field);
			if (rcnt == 37) PlayerInfo[playerid][pChar] = strval(Field);
			if (rcnt == 38) PlayerInfo[playerid][pContractTime] = strval(Field);
			if (rcnt == 39) PlayerInfo[playerid][pDetSkill] = strval(Field);
			if (rcnt == 40) PlayerInfo[playerid][pSexSkill] = strval(Field);
			if (rcnt == 41) PlayerInfo[playerid][pBoxSkill] = strval(Field);
			if (rcnt == 42) PlayerInfo[playerid][pLawSkill] = strval(Field);
			if (rcnt == 43) PlayerInfo[playerid][pMechSkill] = strval(Field);
			if (rcnt == 44) PlayerInfo[playerid][pJackSkill] = strval(Field);
			if (rcnt == 45) PlayerInfo[playerid][pCarSkill] = strval(Field);
			if (rcnt == 46) PlayerInfo[playerid][pNewsSkill] = strval(Field);
			if (rcnt == 47) PlayerInfo[playerid][pDrugsSkill] = strval(Field);
			if (rcnt == 48) PlayerInfo[playerid][pCookSkill] = strval(Field);
			if (rcnt == 49) PlayerInfo[playerid][pFishSkill] = strval(Field);
			if (rcnt == 50) PlayerInfo[playerid][pSHealth] = floatstr(Field);
			if (rcnt == 51) PlayerInfo[playerid][pHealth] = floatstr(Field);
			if (rcnt == 52) PlayerInfo[playerid][pInt] = strval(Field);
			if (rcnt == 53) PlayerInfo[playerid][pLocal] = strval(Field);
			if (rcnt == 54) PlayerInfo[playerid][pTeam] = strval(Field);
			if (rcnt == 55) PlayerInfo[playerid][pModel] = strval(Field);
			if (rcnt == 56) PlayerInfo[playerid][pPnumber] = strval(Field);
			if (rcnt == 57) PlayerInfo[playerid][pPhousekey] = strval(Field);
			if (rcnt == 58) PlayerInfo[playerid][pPcarkey] = strval(Field);
			if (rcnt == 59) PlayerInfo[playerid][pPbiskey] = strval(Field);
			if (rcnt == 60) PlayerInfo[playerid][pPos_x] = floatstr(Field);
			if (rcnt == 61) PlayerInfo[playerid][pPos_y] = floatstr(Field);
			if (rcnt == 62) PlayerInfo[playerid][pPos_z] = floatstr(Field);
			if (rcnt == 63) PlayerInfo[playerid][pCarLic] = strval(Field);
			if (rcnt == 64) PlayerInfo[playerid][pFlyLic] = strval(Field);
			if (rcnt == 65) PlayerInfo[playerid][pBoatLic] = strval(Field);
			if (rcnt == 66) PlayerInfo[playerid][pFishLic] = strval(Field);
			if (rcnt == 67) PlayerInfo[playerid][pGunLic] = strval(Field);
			if (rcnt == 68) PlayerInfo[playerid][pGun1] = strval(Field);
			if (rcnt == 69) PlayerInfo[playerid][pGun2] = strval(Field);
			if (rcnt == 70) PlayerInfo[playerid][pGun3] = strval(Field);
			if (rcnt == 71) PlayerInfo[playerid][pGun4] = strval(Field);
			if (rcnt == 72) PlayerInfo[playerid][pAmmo1] = strval(Field);
			if (rcnt == 73) PlayerInfo[playerid][pAmmo2] = strval(Field);
			if (rcnt == 74) PlayerInfo[playerid][pAmmo3] = strval(Field);
			if (rcnt == 75) PlayerInfo[playerid][pAmmo4] = strval(Field);
			if (rcnt == 76) PlayerInfo[playerid][pCarTime] = strval(Field);
			if (rcnt == 77) PlayerInfo[playerid][pPayDay] = strval(Field);
			if (rcnt == 78) PlayerInfo[playerid][pPayDayHad] = strval(Field);
			if (rcnt == 79) PlayerInfo[playerid][pCDPlayer] = strval(Field);
			if (rcnt == 80) PlayerInfo[playerid][pWins] = strval(Field);
			if (rcnt == 81) PlayerInfo[playerid][pLoses] = strval(Field);
			if (rcnt == 82) PlayerInfo[playerid][pAlcoholPerk] = strval(Field);
			if (rcnt == 83) PlayerInfo[playerid][pDrugPerk] = strval(Field);
			if (rcnt == 84) PlayerInfo[playerid][pMiserPerk] = strval(Field);
			if (rcnt == 85) PlayerInfo[playerid][pPainPerk] = strval(Field);
			if (rcnt == 86) PlayerInfo[playerid][pTraderPerk] = strval(Field);
			if (rcnt == 87) PlayerInfo[playerid][pTut] = strval(Field);
			if (rcnt == 88) PlayerInfo[playerid][pMissionNr] = strval(Field);
			if (rcnt == 89) PlayerInfo[playerid][pWarns] = strval(Field);
			if (rcnt == 90) PlayerInfo[playerid][pAdjustable] = strval(Field);
			if (rcnt == 91) PlayerInfo[playerid][pFuel] = strval(Field);
			if (rcnt == 92) PlayerInfo[playerid][pMarried] = strval(Field);
			if (rcnt == 93) PlayerInfo[playerid][pMarriedTo] = strmid(PlayerInfo[playerid][pMarriedTo], Field, 0, strlen(Field)-1, 255);
			if (rcnt == 94) PlayerInfo[playerid][pLocked] = strval(Field);
			if (rcnt == 95) PlayerInfo[playerid][pLinked] = strval(Field);
			if (rcnt == 96) PlayerInfo[playerid][pCrashed] = strval(Field);
			if (rcnt == 97) PlayerInfo[playerid][pToitumus] = strval(Field);
			if (rcnt == 98) PlayerInfo[playerid][pPcarkey2] = strval(Field);
			if (rcnt == 99) PlayerInfo[playerid][pPcarkey3] = strval(Field);
			if (rcnt == 100) PlayerInfo[playerid][pEaglep] = strval(Field);
			if (rcnt == 101) PlayerInfo[playerid][pSDpistolp] = strval(Field);
			if (rcnt == 102) PlayerInfo[playerid][pMP5p] = strval(Field);
			if (rcnt == 103) PlayerInfo[playerid][pShotgunp] = strval(Field);
			if (rcnt == 104) PlayerInfo[playerid][pAk47p] = strval(Field);
			if (rcnt == 105) PlayerInfo[playerid][pM4p] = strval(Field);
			if (rcnt == 106) PlayerInfo[playerid][pRiflep] = strval(Field);
		}
		//mysql_free_result();
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "SERVER: Vale parool !");
	  gPlayerLogTries[playerid] += 1;
	  if(gPlayerLogTries[playerid] == 4) { PlayerInfo[playerid][pLocked] = 1; }
	  return 1;
	}
	PlayerInfo[playerid][pAdjustable] = 0;
	ResetPlayerMoney(playerid);
	ConsumingMoney[playerid] = 1;
	SafeGivePlayerMoney(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] = 50.0;
		PlayerInfo[playerid][pPos_x] = 1612.3240;
		PlayerInfo[playerid][pPos_y] = -2330.1670;
		PlayerInfo[playerid][pPos_z] = 13.5469;
		PlayerInfo[playerid][pInt] = 15;
		PlayerInfo[playerid][pLocal] = 255;
		PlayerInfo[playerid][pTeam] = 3;
		PlayerInfo[playerid][pModel] = 26;
		new randphone = 100000 + random(899999);//minimum 1000 max 9999 //giving one at the start
		PlayerInfo[playerid][pPnumber] = randphone;
		PlayerInfo[playerid][pPhousekey] = 255;
		PlayerInfo[playerid][pPbiskey] = 255;
		PlayerInfo[playerid][pPcarkey] = 999;
		PlayerInfo[playerid][pPcarkey2] = 999;
		PlayerInfo[playerid][pPcarkey3] = 999;
		PlayerInfo[playerid][pAccount] = 500;
		PlayerInfo[playerid][pReg] = 1;
	}
	/*if(PlayerInfo[playerid][pLevel] == -999) //autoban
	{
		Ban(playerid);
	}*/
	else if(PlayerInfo[playerid][pCK] > 0)
	{
		  Kick(playerid);
	}
	ClearChatbox(playerid, 8);
	SendClientMessage(playerid, COLOR_GREEN, "=============================================");
	format(string2, sizeof(string2), " Teretulemast Ьhendatud Rollimдngu serverisse, %s.",playernamesplit[0]);
	SendClientMessage(playerid, COLOR_WHITE,string2);
	SendClientMessage(playerid, COLOR_GREEN, "=============================================");
	SendClientMessage(playerid, COLOR_WHITE, "Server skriptud: AruLa ning MadeMan poolt.");
	SendClientMessage(playerid, COLOR_WHITE, "MySQL: Martin & Nicholas.");
	SendClientMessage(playerid, COLOR_WHITE, "Mumble IP: urp.live.playcode.eu:7100");
	SendClientMessage(playerid, COLOR_WHITE, "Koduleht: www.u-rp.com");
	format(string2, sizeof(string2), "Hetkel jooksva skripti versioon: %s.",SCRIPT_VERSION);
	SendClientMessage(playerid, COLOR_WHITE, string2);
	if (PlayerInfo[playerid][pDonateRank] > 0)
	{
		SendClientMessage(playerid, COLOR_WHITE,"SERVER: Sa oled preemium konto kasutaja!");
	}
	if (PlayerInfo[playerid][pLinked] == 0)
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: Su kasuta pole aktiveeritud. Su хigused on piiratud!");
	}
	if (PlayerInfo[playerid][pAdmin] > 0)
	{
		format(string2, sizeof(string2), "SERVER: Sa oled sisse logitud kui %d admin.",PlayerInfo[playerid][pAdmin]);
		SendClientMessage(playerid, COLOR_WHITE,string2);
	}
	SendClientMessage(playerid, COLOR_GREEN, "=============================================");
	SendClientMessage(playerid, COLOR_WHITE, " ");
	printf("%s has logged in.",playername2);

	// Unset Crash
	SetTimerEx("UnsetCrash", 5000, false, "i", playerid);

	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;
	SpawnPlayer(playerid);
	if(PlayerInfo[playerid][pCrashed] == 0)
	{
		format(tmp2, sizeof(tmp2), "~w~Tere Tulemast ~n~~y~  %s", playername2);
	}
	else
	{
	  	SendClientMessage(playerid, COLOR_WHITE, "SERVER: Teie ьhendus katkes teadmata pхhjusel ennem vдljumist.");
	  	SendClientMessage(playerid, COLOR_YELLOW2, "Crash sьsteem: Teie positsioon taastati..");
	}
	DateProp(playerid);
	if(PlayerInfo[playerid][pFMember] < 255)
	{
	  format(tmp2, sizeof(tmp2), "Family MOTD: %s.", FamilyInfo[PlayerInfo[playerid][pFMember]][FamilyMOTD]);
	  SendClientMessage(playerid, COLOR_YELLOW, tmp2);
	}
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	  if(IsPlayerConnected(i))
	  {
	    if(PlayerInfo[i][pMaskuse] == 1)
	    {
	      ShowPlayerNameTagForPlayer(playerid, i, 0);
	    }
	  }
	}
	return 1;
}
Reply

Quote:
Originally Posted by MenaceX^
You should change your behavior because you are wrong. There is not a REPLACEMENT for mysql_strtok. E.g:
samp_mysql_fetch_row is here mysql_fetch_row_format.
But there is NOTHING related to strtok in this plugin than fetching a whole row.
Like anyone ever said anything about strtok and connection to this plugin.
Reply

You did, you talked about samp_mysql_strtok.. God..
Reply

Hey, does anyone have problem with crashing server after using commands like "fetch_row", "row_count" etc, etc... (0.3 ofc.)? It's really anoying.
Reply

You store a result?
Reply

Hi all !!
I am sorry to post here but i have a problem, and i know that you have ever speak of the samp_mysql_strtok, but i don't understand how can i do .
My problem: I use moderntopia gm, when i /login on my server, it crash.
In the script, there is:

samp_mysql_strtok(Field, "|", Data);
while (samp_mysql_strtok(Field, "|", "")==1)
{

What i have to do please ? I am working on it but i don't have any solution !!
Reply

Your script is using other mysql plugin.
Reply

Ok i didn't know
So why my server crash when i login, it's strange
Reply

Quote:
Originally Posted by Albus_Dumbledore
Hi all !!
I am sorry to post here but i have a problem, and i know that you have ever speak of the samp_mysql_strtok, but i don't understand how can i do .
My problem: I use moderntopia gm, when i /login on my server, it crash.
In the script, there is:

samp_mysql_strtok(Field, "|", Data);
while (samp_mysql_strtok(Field, "|", "")==1)
{

What i have to do please ? I am working on it but i don't have any solution !!
The crash reason is the plugin, the other plugin (Adrenaline) doesn't work well. Use this one, even though this doesn't work well either.
Reply

All what doesn't work in this plugin is OnQueryFinish.
Reply

Quote:
Originally Posted by $ЂЯĢ
This would be possible fix.
pawn Code:
public FindPlayerSQL(playerid)
{
  CheckSQL();
  new
    query[128],
    pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid,pname,sizeof(pname));
  mysql_real_escape_string(pname,pname);
  format(query,sizeof(query),"SELECT playerid FROM `players` WHERE name='%s' LIMIT 1",pname);
  mysql_query(query);
  mysql_store_result();
  if(mysql_num_rows()>0)
  {
    PlayerInfo[playerid][pSQLId] = mysql_fetch_int();
    if(PlayerInfo[playerid][pSQLId] <= INVALID_SQL_ID)
    {
        SendClientMessage(playerid,0xFFFFFF,"SERVER: Your data hasn't loaded.");
        return Kick(playerid);
    }
  }
  mysql_free_result();
  return 1;
}
There's no reason for that because you check the rows, there can't be 3 rows but your sqlid will be 0.. It must be 1 2 or 3. (auto increment)
Reply

The only issue here can be that mysql_fetch_int doesn't do its job, so we make mysql_num_rows() to see if we got any data from SELECT query. If we got any data we fetch it in PlayerInfo[playerid][pSQLId]. If mysql_fetch_int() doesn't do its job we check if PlayerInfo[playerid][pSQLId] is higher than 0 (INVALID_SQL_ID). If it's not we know there is a data for that username already, but mysql_fetch_int didn't get row's ID which we wanted to get, so it's useless to continue that's why we kick player.

Understood?
Reply

out standing work !


Saif
Reply

Quote:
Originally Posted by $ЂЯĢ
The only issue here can be that mysql_fetch_int doesn't do its job, so we make mysql_num_rows() to see if we got any data from SELECT query. If we got any data we fetch it in PlayerInfo[playerid][pSQLId]. If mysql_fetch_int() doesn't do its job we check if PlayerInfo[playerid][pSQLId] is higher than 0 (INVALID_SQL_ID). If it's not we know there is a data for that username already, but mysql_fetch_int didn't get row's ID which we wanted to get, so it's useless to continue that's why we kick player.

Understood?
I believe this way has fixed my problem, Thanks
Reply

Aha. I do the same but I think it's stupid to kick the player in this function.. I just check later then..
Reply

Hi, i got this error when i want to connect to the database:
Code:
MySQL Connect Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Error ID: 2002)
Here the whole error:
Code:
[20:59:14] mysql_connect("*******","*******","*******","*******");
[20:59:14] MySQL Connect Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Error ID: 2002)
[21:03:40] MySQL Ping Error: "MySQL server has gone away"
[21:03:40] mysql_close();
What to do? ...
Reply

Quote:
Originally Posted by Monoxid
Hi, i got this error when i want to connect to the database:
Code:
MySQL Connect Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Error ID: 2002)
Here the whole error:
Code:
[20:59:14] mysql_connect("*******","*******","*******","*******");
[20:59:14] MySQL Connect Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Error ID: 2002)
[21:03:40] MySQL Ping Error: "MySQL server has gone away"
[21:03:40] mysql_close();
What to do? ...
Either your data info in the script is incorrect or the database doesn't exist.
Reply

They are the same as in my PHP script but the PHP script works..
The database exists...
Reply

Hi, I got a big problem that I can't fix for HOURS.

here's the buggy function, actually totalannonce is supposed to be 10 but after the line "mysql_fetch_field_row(Field,"text");" it magically sets itself to 101 for no appearent reason...

pawn Code:
#define MAX_ANNOUNCEMENTS  10
enum rInfo
{
    rName[30],
    rText[128],
    rContact[20],
    rBusy
}new Recuiting[MAX_ANNOUNCEMENTS+1][rInfo];

stock LoadSQLRecuiting()
{
      new totalannonce;
    new Field[64];
    new Data[256];
    new sql[80];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM annonces");
    mysql_query(sql);
    mysql_store_result();
    mysql_fetch_row(Data);
    totalannonce = strval(Data);
    mysql_free_result();
    for (new idx=1; idx<=totalannonce; idx++)
    {
      format(sql, sizeof(sql), "SELECT * FROM annonces WHERE id=%d", idx);
      mysql_query(sql);
      mysql_store_result();
      if (mysql_num_rows() > 0)
      {
          mysql_fetch_row(Data);
     
          mysql_fetch_field_row(Field,"name");
          printf("%s, %d, %d", Field, totalannonce, idx);
          strmid(Recuiting[idx][rName],Field,0,strlen(Field),50);
          mysql_fetch_field_row(Field,"text");
          printf("%s, %d", Field, totalannonce);
          strmid(Recuiting[idx][rText],Field,0,strlen(Field),128);
          mysql_fetch_field_row(Field,"contact");
          printf("%s, %d", Field, totalannonce);
          strmid(Recuiting[idx][rContact],Field,0,strlen(Field),20);
          mysql_fetch_field_row(Field,"busy");
          Recuiting[idx][rBusy] = strval(Field);
        }
        mysql_free_result();
    }
    printf("%d recuiting announcements loaded from DB.", totalannonce);
    return 1;
}
Here are server logs:
Quote:

[17:35:14][17:35:14] Sweeper, 10, 1
[17:35:14] Vous conduisez une balayeuse а travers Los Santos afin de nettoyer les rues, 101
[17:35:14] ((/sweeper)), 101
[17:35:14] Aucun, 101, 2
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 3
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 4
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 5
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 6
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 7
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 8
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 9
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 10
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] 101 recuiting announcements loaded from DB.

here is a screen of the DB:


This is really annoying, so if anyone could help me... Thanks
Reply

Quote:
Originally Posted by Coicatak
Hi, I got a big problem that I can't fix for HOURS.

here's the buggy function, actually totalannonce is supposed to be 10 but after the line "mysql_fetch_field_row(Field,"text");" it magically sets itself to 101 for no appearent reason...

pawn Code:
#define MAX_ANNOUNCEMENTS 10
enum rInfo
{
    rName[30],
    rText[128],
    rContact[20],
    rBusy
}new Recuiting[MAX_ANNOUNCEMENTS+1][rInfo];

stock LoadSQLRecuiting()
{
      new totalannonce;
    new Field[64];
    new Data[256];
    new sql[80];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM annonces");
    mysql_query(sql);
    mysql_store_result();
    mysql_fetch_row(Data);
    totalannonce = strval(Data);
    mysql_free_result();
    for (new idx=1; idx<=totalannonce; idx++)
    {
      format(sql, sizeof(sql), "SELECT * FROM annonces WHERE id=%d", idx);
      mysql_query(sql);
      mysql_store_result();
      if (mysql_num_rows() > 0)
      {
         mysql_fetch_row(Data);
     
          mysql_fetch_field_row(Field,"name");
          printf("%s, %d, %d", Field, totalannonce, idx);
          strmid(Recuiting[idx][rName],Field,0,strlen(Field),50);
          mysql_fetch_field_row(Field,"text");
          printf("%s, %d", Field, totalannonce);
          strmid(Recuiting[idx][rText],Field,0,strlen(Field),128);
          mysql_fetch_field_row(Field,"contact");
          printf("%s, %d", Field, totalannonce);
          strmid(Recuiting[idx][rContact],Field,0,strlen(Field),20);
          mysql_fetch_field_row(Field,"busy");
          Recuiting[idx][rBusy] = strval(Field);
        }
        mysql_free_result();
    }
    printf("%d recuiting announcements loaded from DB.", totalannonce);
    return 1;
}
Here are server logs:
Quote:

[17:35:14][17:35:14] Sweeper, 10, 1
[17:35:14] Vous conduisez une balayeuse а travers Los Santos afin de nettoyer les rues, 101
[17:35:14] ((/sweeper)), 101
[17:35:14] Aucun, 101, 2
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 3
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 4
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 5
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 6
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 7
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 8
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 9
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101, 10
[17:35:14] Aucun, 101
[17:35:14] Aucun, 101
[17:35:14] 101 recuiting announcements loaded from DB.

here is a screen of the DB:


This is really annoying, so if anyone could help me... Thanks
This should go to scripting discussion. It's not a plugin bug, it's a script bug.
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)