Jump to content

Question

Posted (edited)

Salut, as dori ca ce se updateaza in baza de date sa se updateze si in joc.

Eu am facut asa:

if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");
    	
		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");
		}
		cache_delete(jucatori);


		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				playerVariables[i][pQuestValue] = 0;
				Update(i, pQuestx);

				playerVariables[i][pQuest] = playerVariables[i][pQuest];
				Update(i, pQuestx);
			}
		}
	}

Problema este ca nu se updateaza pe loc si in joc. 

Edited by LeetRomania

13 answers to this question

Recommended Posts

  • 1
Posted (edited)

Nu tu ai facut asa, SA-MP.ro ti-a facut asa, 2 daca nu respecti modelul nu te mai ajut.

Cer T/C si subiectul sa fie marcat ca rezolvat.

 

Edited by [RW]Robi

                        

 

 

  • 0
Posted
if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");
    	
		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");
			for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(id == PlayerInfo[i][pSQLID]) // in gamemode presupun ca ai o variabila care iti incarca ID-ul din SQL, daca nu e pSQLID, schimba cu variabila care ti-l incarca.
					{
						playerVariables[i][pQuestValue] = value;
					}
				}
			}
		}
		cache_delete(jucatori);
	}

 

  • Upvote 1

                        

 

 

  • 0
Posted
On 1/21/2017 at 2:21 AM, [RW]Robi said:

if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");
    	
		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");
			for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(id == PlayerInfo[i][pSQLID]) // in gamemode presupun ca ai o variabila care iti incarca ID-ul din SQL, daca nu e pSQLID, schimba cu variabila care ti-l incarca.
					{
						playerVariables[i][pQuestValue] = value;
					}
				}
			}
		}
		cache_delete(jucatori);
	}

 

Rezolvat, multumesc. 

  • 0
Posted
21 hours ago, [RW]Robi said:

if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");
    	
		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");
			for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(id == PlayerInfo[i][pSQLID]) // in gamemode presupun ca ai o variabila care iti incarca ID-ul din SQL, daca nu e pSQLID, schimba cu variabila care ti-l incarca.
					{
						playerVariables[i][pQuestValue] = value;
					}
				}
			}
		}
		cache_delete(jucatori);
	}

 

A aparut o problema. Daca un player este conectat, doar lui ii seteaza noua variabila cu random. La ceilalti nu, de ce oare? 

Problema este doar cand un player este conectat. Daca nu este nimeni conectat se modifica la fiecare player, daca este cineva conectat doar la acel player. De ce? 

  • 0
Posted
Acum 35 minute, LeetRomania a spus:

A aparut o problema. Daca un player este conectat, doar lui ii seteaza noua variabila cu random. La ceilalti nu, de ce oare? 

Problema este doar cand un player este conectat. Daca nu este nimeni conectat se modifica la fiecare player, daca este cineva conectat doar la acel player. De ce? 

Nu are cum, probabil nu te-ai exprimat tu bine.

 

                        

 

 

  • 0
Posted
9 hours ago, [RW]Robi said:

Nu are cum, probabil nu te-ai exprimat tu bine.

 

Serios. 

Deci daca nu sunt playeri online pe server, la ora 00:00 se reseteaza la toti pQuest si pQuestValue.

Daca intru pe server doar cu un cont, mie imi modifica variabilele dar la ceilalti offline nu le mai modifica.

Daca sunt 2 sau mai multi playeri online, la fel, modifica doar la ID 0 variabilele iar la ceilalti ramane la fel. 

  • 0
Posted
Chiar acum, LeetRomania a spus:

Serios. 

Deci daca nu sunt playeri online pe server, la ora 00:00 se reseteaza la toti pQuest si pQuestValue.

Daca intru pe server doar cu un cont, mie imi modifica variabilele dar la ceilalti offline nu le mai modifica.

Daca sunt 2 sau mai multi playeri online, la fel, modifica doar la ID 0 variabilele iar la ceilalti ramane la fel. 

Cred ca inteleg ce vrei sa zici, ai adaugat la logare sa citeasca columnul din baza de date?

 

                        

 

 

  • 0
Posted
On 1/21/2017 at 2:45 PM, [RW]Robi said:

Cred ca inteleg ce vrei sa zici, ai adaugat la logare sa citeasca columnul din baza de date?

 

Te referi la onplayerconnect? Eu am pus doar asta pe care mi-ai dat-o tu:

if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");

		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");

	      	for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(id == playerVariables[i][pID])
				{
					playerVariables[i][pQuestValue] = 0;
					Update(i, pQuestValuex);

 					playerVariables[i][pQuest] = value;
				}
			}
		}
		cache_delete(jucatori);
	}

 

  • 0
Posted
if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");

		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");

	      	for(new x = 0; x < MAX_PLAYERS; x++)
			{
				if(id == playerVariables[x][pID])
				{
 					playerVariables[x][pQuest] = value;
				}
			}
		}
		cache_delete(jucatori);
	}

Schimba cu asta, 2. Ce face pQuestValue si de ce tot il setezi pe 0?

 

                        

 

 

  • 0
Posted
Just now, [RW]Robi said:

if(ora == 23 && minut == 59 && secunda == 59)
	{
		new str[256], sqlupdate[256], sqlcheck[512];

		mysql_format(handle, str, sizeof(str), "UPDATE `players` SET `QuestValue` = '0'");
    	mysql_tquery(handle, str, "","");

		mysql_format(handle, sqlcheck, sizeof(sqlcheck), "SELECT * FROM `players` ORDER BY `ID`");
		new Cache: jucatori = mysql_query(handle, sqlcheck);
		for(new i = 0, c = cache_get_row_count(); i < c; i++)
		{
			new id = cache_get_field_content_int(i, "ID");
			new value = random(10);
			mysql_format(handle, sqlupdate, sizeof(sqlupdate), "UPDATE `players` SET `Quest`='%d' WHERE `ID`='%d'", value, id);
			mysql_tquery(handle, sqlupdate, "", "");

	      	for(new x = 0; x < MAX_PLAYERS; x++)
			{
				if(id == playerVariables[x][pID])
				{
 					playerVariables[x][pQuest] = value;
				}
			}
		}
		cache_delete(jucatori);
	}

Schimba cu asta, 2. Ce face pQuestValue si de ce tot il setezi pe 0?

 

Pe questvalue se salveaza cat a facut playerul respectiv. De ex daca foloseste comanda: /fish sa se puna un +1 iar la 00:00 sa se reseteze si aia. 

  • 0
Posted
Acum 9 minute, LeetRomania a spus:

Pe questvalue se salveaza cat a facut playerul respectiv. De ex daca foloseste comanda: /fish sa se puna un +1 iar la 00:00 sa se reseteze si aia. 

Ok, ok, cu codul de mai sus ar trebuii sa functioneze totul corect..

 

                        

 

 

  • 0
Posted
On 1/21/2017 at 3:14 PM, [RW]Robi said:

Ok, ok, cu codul de mai sus ar trebuii sa functioneze totul corect..

 

Chiar a functionat. Multumesc mult. Te respect, ai +1. 

  • 0
Posted
1 hour ago, LeetRomania said:

Chiar a functionat. Multumesc mult. Te respect, ai +1. 

in loc de for(new x = 0; x < MAX_PLAYER; x++)

foloseste foreach

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Guest
This topic is now closed to further replies.
×
×
  • 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.