Jump to content
  • 0

Problema actualizare preturi


LeetRomania

Question

56 minutes ago, RWRobiBG said:

P.S: In caz ca in baza de date id-ul nu incepe de la 0 ci de la 1, foloseste asta:


for ( new i = 1, j = cache_get_row_count ( ); i != j; i++)

si schimba new x = i cu new x = i - 1;

 

Multumesc ca m-ai ajutat si tu tot daca ne-am cam certat.  Ai si tu +1

 

O mica problema mai este. De ce cand editez pretul masinii din joc, pretul se updateaza in baza de date dar in /buycar nu?

 

 

Link to comment
Share on other sites

Recommended Posts

  • 0
Acum 1 minut, LeetRomania a spus:

Am facut cum ai spus tu si apare corect in /buycar si toate astea. De la mine ai +1. Multumesc mult de ajutor.

O mica problema mai este. De ce cand editez pretul masinii din joc, pretul se updateaza in baza de date dar in /buycar nu?

Da-ne repede comanda sa ti-o rezolvam si pe aia, si sa inchidem acest subiect.

                        

 

 

Link to comment
Share on other sites

  • 0
5 minutes ago, RWRobiBG said:

Da-ne repede comanda sa ti-o rezolvam si pe aia, si sa inchidem acest subiect.

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new tableid, car[10], price, stockk, query[256], string[256];
		
		if(sscanf(params, "s[10]di", car, price, stockk)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [vehicleid] [price] [stock]");

		tableid = MySQLCheckCar(car);
		if(tableid == 0) return S(playerid,COLOR_GREY,"Invalid car name.");

		Stock[tableid][vStock] = stockk;
		Stock[tableid][vPrice] = price;
		
		mysql_format(handle, query, sizeof(query), "UPDATE `stock` SET `Price`= '%d', `Stock`= '%d' WHERE `ID`= '%d'", Stock[tableid][vPrice], Stock[tableid][vStock], tableid);
  		mysql_tquery(handle, query, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s | Stock: %d", GetName(playerid), car, NumberFormat(price), stockk);
		submitToAdmins(string, -1);
		
		

 	}
 	return 1;
}

 

Link to comment
Share on other sites

  • 0

Nu iti seteaza cumva la a2-a masina?

 

Ia incearca asta:

 

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new tableid, car[10], price, stockk, query[256], string[256];
		
		if(sscanf(params, "s[10]di", car, price, stockk)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [vehicleid] [price] [stock]");

		tableid = MySQLCheckCar(car);
		if(tableid == 0) return S(playerid,COLOR_GREY,"Invalid car name.");

		for(new idm = 0; idm < MAX_DEALERSHIP_CARS; idm++)
		{
			if(strcmp(Stock[idm][vName],car,true) == 0)
			{
				Stock[idm][vStock] = stockk;
				Stock[idm][vPrice] = price;
			}
		}
		mysql_format(handle, query, sizeof(query), "UPDATE `stock` SET `Price`= '%d', `Stock`= '%d' WHERE `ID`= '%d'", Stock[tableid][vPrice], Stock[tableid][vStock], tableid);
  		mysql_tquery(handle, query, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s | Stock: %d", GetName(playerid), car, NumberFormat(price), stockk);
		submitToAdmins(string, -1);
 	}
 	return 1;
}

 

Edited by RWRobiBG

                        

 

 

Link to comment
Share on other sites

  • 0
4 minutes ago, RWRobiBG said:

Nu iti seteaza cumva la a2-a masina?

 

Ia incearca asta:

 


CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new tableid, car[10], price, stockk, query[256], string[256];
		
		if(sscanf(params, "s[10]di", car, price, stockk)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [vehicleid] [price] [stock]");

		tableid = MySQLCheckCar(car);
		if(tableid == 0) return S(playerid,COLOR_GREY,"Invalid car name.");

		for(new idm = 0; idm < MAX_DEALERSHIP_CARS; idm)
		{
			if(strcmp(Stock[idm][vName],car,true) == 0)
			{
				Stock[idm][vStock] = stockk;
				Stock[idm][vPrice] = price;
			}
		}
		mysql_format(handle, query, sizeof(query), "UPDATE `stock` SET `Price`= '%d', `Stock`= '%d' WHERE `ID`= '%d'", Stock[tableid][vPrice], Stock[tableid][vStock], tableid);
  		mysql_tquery(handle, query, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s | Stock: %d", GetName(playerid), car, NumberFormat(price), stockk);
		submitToAdmins(string, -1);
 	}
 	return 1;
}

 

Mda, imi da crash..

Link to comment
Share on other sites

  • 0
Chiar acum, LeetRomania a spus:

Nu mai pot face nimic pe server.. Nici o comanda nu poate fi folosita.. 

Nu are cum, cred ca nu s-a compilat pentru ca am uitat sa pun idm++

schimba cu asta

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new tableid, car[10], price, stockk, query[256], string[256];
		
		if(sscanf(params, "s[10]di", car, price, stockk)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [vehicleid] [price] [stock]");

		tableid = MySQLCheckCar(car);
		if(tableid == 0) return S(playerid,COLOR_GREY,"Invalid car name.");

		for(new idm = 0; idm < MAX_DEALERSHIP_CARS; idm++)
		{
			if(strcmp(Stock[idm][vName],car,true) == 0)
			{
				Stock[idm][vStock] = stockk;
				Stock[idm][vPrice] = price;
			}
		}
		mysql_format(handle, query, sizeof(query), "UPDATE `stock` SET `Price`= '%d', `Stock`= '%d' WHERE `ID`= '%d'", Stock[tableid][vPrice], Stock[tableid][vStock], tableid);
  		mysql_tquery(handle, query, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s | Stock: %d", GetName(playerid), car, NumberFormat(price), stockk);
		submitToAdmins(string, -1);
 	}
 	return 1;
}

                        

 

 

Link to comment
Share on other sites

  • 0
3 minutes ago, RWRobiBG said:

Nu are cum, cred ca nu s-a compilat pentru ca am uitat sa pun idm++

schimba cu asta


CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new tableid, car[10], price, stockk, query[256], string[256];
		
		if(sscanf(params, "s[10]di", car, price, stockk)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [vehicleid] [price] [stock]");

		tableid = MySQLCheckCar(car);
		if(tableid == 0) return S(playerid,COLOR_GREY,"Invalid car name.");

		for(new idm = 0; idm < MAX_DEALERSHIP_CARS; idm++)
		{
			if(strcmp(Stock[idm][vName],car,true) == 0)
			{
				Stock[idm][vStock] = stockk;
				Stock[idm][vPrice] = price;
			}
		}
		mysql_format(handle, query, sizeof(query), "UPDATE `stock` SET `Price`= '%d', `Stock`= '%d' WHERE `ID`= '%d'", Stock[tableid][vPrice], Stock[tableid][vStock], tableid);
  		mysql_tquery(handle, query, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s | Stock: %d", GetName(playerid), car, NumberFormat(price), stockk);
		submitToAdmins(string, -1);
 	}
 	return 1;
}

Uite cum apare :)) http://imgur.com/a/PhYwy

Link to comment
Share on other sites

  • 0
CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [id stock (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `ID`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel vehicul in stock.");
		Stock[id][vPrice] = pret;
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `ID`= '%d'", Stock[id][vPrice], id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[id][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
 	}
 	return 1;
}

 

                        

 

 

Link to comment
Share on other sites

  • 0
3 minutes ago, RWRobiBG said:

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [id stock (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `ID`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel vehicul in stock.");
		Stock[id][vPrice] = pret;
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `ID`= '%d'", Stock[id][vPrice], id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[id][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
 	}
 	return 1;
}

 

Da, este ok, se modifica pretul masinii, dar ordinea din /buycar nu. De ce? 

Link to comment
Share on other sites

  • 0
Chiar acum, LeetRomania a spus:

Ar trebui sa pot sa modific dupa modelul masinii nu dupa ID-ul din baza de date.

Si unde pot IniStock(); ? In comanda?

Merge facut si dupa model, vrei sa ti-l fac cu tot cu IniStock si tot?

 

                        

 

 

Link to comment
Share on other sites

  • 0
1 minute ago, RWRobiBG said:

Merge facut si dupa model, vrei sa ti-l fac cu tot cu IniStock si tot?

 

Raman dator.. Mie unu tot nu imi iese cum ai facut tu comanda. De exemplu daca fac ca pretul sa fie mai mare si sa coboare mai jos nu se intampla decat dupa ce dau rr la server. Probabil e de la inistock..  Ajuta-ma si cu asta te rog.

Edited by LeetRomania
Link to comment
Share on other sites

  • 0
Chiar acum, LeetRomania a spus:

Raman dator.. Mie unu tot nu imi iese cum ai facut tu comanda. De exemplu daca fac ca pretul sa fie mai mare si sa coboare mai jos nu se intampla decat dupa ce dau rr la server. Probabil e de la inistock..  Ajuta-ma si cu asta te rog.

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [Mode masina (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `Model`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel model de vehicul in stock.");
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `ID`= '%d'", Stock[id][vPrice], id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[id][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
		IniStock();
 	}
 	return 1;
}

Ia vezi.

                        

 

 

Link to comment
Share on other sites

  • 0
1 minute ago, RWRobiBG said:

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [Mode masina (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `Model`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel model de vehicul in stock.");
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `ID`= '%d'", Stock[id][vPrice], id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[id][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
		IniStock();
 	}
 	return 1;
}

Ia vezi.

foloseste mysql_pquery, in loc de mysql_tquery.

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

Servicii Scripting de calitate:

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

Future Project: ExpertGame

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

Link to comment
Share on other sites

  • 0
3 minutes ago, RWRobiBG said:

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [Mode masina (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `Model`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel model de vehicul in stock.");
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `ID`= '%d'", Stock[id][vPrice], id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[id][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
		IniStock();
 	}
 	return 1;
}

Ia vezi.

Daca dau /dsprice 560 1 si nu am masina in baza de date e ok primesc mesaj

Dar daca dau /dsprice 411 1 imi da server unknown command. Am masina in baza :| 

Link to comment
Share on other sites

  • 0
Just now, LeetRomania said:

mysql_pquery daca pun asta spune ca nu e definit. 

ce versiune de mysql folosesti?

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

Servicii Scripting de calitate:

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

Future Project: ExpertGame

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

Link to comment
Share on other sites

  • 0
Acum 1 minut, LeetRomania a spus:

Daca dau /dsprice 560 1 si nu am masina in baza de date e ok primesc mesaj

Dar daca dau /dsprice 411 1 imi da server unknown command. Am masina in baza :| 

hopa scuze, doua secunde doar.

Edit: 

CMD:dsprice(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
		if(playerVariables[playerid][pAdminLevel] < 6) return S(playerid, -1, AdminOnly);

		new idm;
		new pret,id,sqlselect[300],eroare = 0;
	
		if(sscanf(params, "ii", id,pret)) return S(playerid, COLOR_GREY, "Syntax: {FFFFFF}/dsprice [Mode masina (db)] [pret]");
		mysql_format(handle, sqlselect, sizeof(sqlselect), "SELECT * FROM `stock` WHERE `Model`='%d'",id);
		new Cache: verificare = mysql_query(handle, sqlselect);
		eroare = cache_get_row_count();
		if(eroare > 0)
		{
			for(new i = 0; i < eroare; i++)
			{
				idm = cache_get_field_content_int(i, "ID");
			}
		}
		cache_delete(verificare);
		if(eroare < 1) return SendClientMessage(playerid, -1, "Nu exista acel model de vehicul in stock.");
		
		mysql_format(handle, sqlselect, sizeof(sqlselect), "UPDATE `stock` SET `Price`= '%d' WHERE `Model`= '%d'", pret, id);
  		mysql_tquery(handle, sqlselect, "","");
  		
  		format(string, sizeof(string), "{F0DF52}/dsprice: Owner %s changed data for %s | Price: $%s", GetName(playerid), Stock[idm][vName], NumberFormat(pret));
		submitToAdmins(string, -1);
		IniStock();
 	}
 	return 1;
}

Ia vezi acum.

 

 

                        

 

 

Link to comment
Share on other sites

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.