Jump to content
  • 0

Problema buybusiness


Sprite_RoPlayers

Question

Salut am si eu urmatoare problema

Cand dau sa cumpar o casa imi zice ca nu am 30 de ore pentru a putea cumpara casa.

Si nu stiu cum sa scot chestia asta din comanda am incercat cu // verificarea dar degeaba nu imi cumpara casa.

YCMD:buybusiness(playerid, params[], help)
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		new string[128],sendername[25],stringcasa[128],strr[256],time,count;
		if(PlayerInfo[playerid][pPbiskey] != 255) return SendClientMessage(playerid, COLOR_GREY, "You already own a business, type /sellbiztostate if you want to buy this one.");
		for(new b = 1; b < sizeof(BizzInfo); b++)
		{
			if(PlayerToPoint(2.0, playerid, BizzInfo[b][bEntranceX], BizzInfo[b][bEntranceY], BizzInfo[b][bEntranceZ]))
			{
				if(PlayerInfo[playerid][pLevel] < BizzInfo[b][bLevelNeeded])
				{
					format(string, sizeof(string), "You must be level %d to purchase this business.",BizzInfo[b][bLevelNeeded]);
					SendClientMessage(playerid, COLOR_WHITE, string);
					return 1;
				}
				format(strr, sizeof(strr), "SELECT * FROM `timeplayed` WHERE `pid`='%d'", PlayerInfo[playerid][pSQLID]);
				new Cache: salut = mysql_query(SQL, strr);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					if(count < 30)
					{
						time += cache_get_field_content_int(i, "time");
						count++;
					}
				}
				cache_delete(salut);
				if(time < 36000) return SS(playerid, COLOR_LIGHTGREEN3, "Trebuie sa ai 10 ore jucate in ultimele 30 de zile (fara AFK/sleep) pentru a putea cumpara o proprietate.", "You need 10 played hours in last 30 days (without AFK/sleep) to buy a property.");
				if(BizzInfo[b][bOwned] == 0)
				{
					if(GetPlayerCash(playerid) >= BizzInfo[b][bBuyPrice])
					{
						PlayerInfo[playerid][pPbiskey] = b;
						BizzInfo[b][bOwned] = 1;
						GetPlayerName(playerid, sendername, sizeof(sendername));
						strmid(BizzInfo[b][bOwner], PlayerInfo[playerid][pNormalName], 0, 25, 255);
						GivePlayerCash(playerid,-BizzInfo[b][bBuyPrice]);
						if(BizzInfo[b][bSbiz] == 0)
						{
							PlayerInfo[playerid][pInt] = BizzInfo[b][bInterior];
							PlayerInfo[playerid][pLocal] = b ;
							InBussines[playerid] = b;
							SetPlayerInterior(playerid,BizzInfo[b][bInterior]);
							SetPlayerVirtualWorld(playerid, BizzInfo[b][bVirtual]);
							PlayerInfo[playerid][pInt] = BizzInfo[b][bInterior];
							SetPlayerPosEx(playerid,BizzInfo[b][bExitX],BizzInfo[b][bExitY],BizzInfo[b][bExitZ]);
						}
						SendClientMessage(playerid, COLOR_WHITE, "Congratulations on your purchase!");
						format(stringcasa, sizeof(stringcasa), "%s [user:%d] a cumparat bizz-ul [bizz:%d] de la Stat pentru $%s.",sendername,PlayerInfo[playerid][pSQLID],b,FormatNumber(BizzInfo[b][bBuyPrice]));
	                    ABroadCast(COLOR_YELLOW, stringcasa, 1);
	                    new var100[256],string2[256];
	 					mysql_real_escape_string(stringcasa, string2);
						mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`) VALUES ('%d','0','%s')", PlayerInfo[playerid][pSQLID],string2);
						mysql_tquery(SQL,var100,"","");
						new str1[256];
						mysql_format(SQL,str1,sizeof(str1),"UPDATE users SET `Money`='%d',`Bizz`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPbiskey],PlayerInfo[playerid][pNormalName]);
						mysql_tquery(SQL,str1,"","");
						mysql_format(SQL,str1,sizeof(str1),"UPDATE `bizz` SET `Owned`='1',`Owner`='%s' WHERE `ID`='%d'",BizzInfo[b][bOwner],b);
						mysql_tquery(SQL,str1,"","");
						OnPropTextdrawUpdate(2,b);
						return 1;
					}
					else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money.");
				}
				else if(BizzInfo[b][bOwned] == 1 && BizzInfo[b][bPrice] > 0)
				{
					if(GetPlayerCash(playerid) < BizzInfo[b][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money.");
					new ownerid, query[256];
					GetPlayerName(playerid, sendername, sizeof(sendername));
					PlayerInfo[playerid][pPbiskey] = b;
					BizzInfo[b][bOwned] = 1;
					format(query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s'", BizzInfo[b][bOwner]);
					new Cache: result = mysql_query(SQL, query);
					for(new i, j = cache_get_row_count (); i != j; ++i)
					{
						ownerid = cache_get_field_content_int(i, "id");
					}
					cache_delete(result);
					format(stringcasa, sizeof(stringcasa), "%s [user:%d] a cumparat bizz-ul [bizz:%d] de la %s [user:%d] pentru $%s.",sendername,PlayerInfo[playerid][pSQLID],b,BizzInfo[b][bOwner],ownerid,FormatNumber(BizzInfo[b][bPrice]));
	                ABroadCast(COLOR_YELLOW, stringcasa, 1);
	                strmid(BizzInfo[b][bOwner], PlayerInfo[playerid][pNormalName], 0, 25, 255);
					GivePlayerCash(playerid,-BizzInfo[b][bPrice]);
					if(BizzInfo[b][bSbiz] == 0)
					{
						PlayerInfo[playerid][pInt] = BizzInfo[b][bInterior];
						PlayerInfo[playerid][pLocal] = b ;
						InBussines[playerid] = b;
						SetPlayerInterior(playerid,BizzInfo[b][bInterior]);
						SetPlayerVirtualWorld(playerid, BizzInfo[b][bVirtual]);
						PlayerInfo[playerid][pInt] = BizzInfo[b][bInterior];
						SetPlayerPosEx(playerid,BizzInfo[b][bExitX],BizzInfo[b][bExitY],BizzInfo[b][bExitZ]);
					}
					SendClientMessage(playerid, COLOR_WHITE, "Congratulations on your purchase!");
					new var100[256],string2[256];
					mysql_real_escape_string(stringcasa, string2);
 					mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`) VALUES ('%d','%d','%s')", PlayerInfo[playerid][pSQLID], ownerid, string2);
					mysql_tquery(SQL,var100,"","");
					new str1[256];
					mysql_format(SQL,str1,sizeof(str1),"UPDATE users SET `Money`='%d',`Bizz`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPbiskey],PlayerInfo[playerid][pNormalName]);
					mysql_tquery(SQL,str1,"","");
					mysql_format(SQL,str1,sizeof(str1),"UPDATE `bizz` SET `Owned`='1',`Owner`='%s',`Prices`='0' WHERE `ID`='%d'", BizzInfo[b][bOwner], b);
					mysql_tquery(SQL,str1,"","");
					mysql_format(SQL,str1,sizeof(str1),"UPDATE users SET Bizz=255, Money=Money+%d WHERE id=%d", BizzInfo[b][bPrice], ownerid);
					mysql_tquery(SQL,str1,"","");
					foreach(new i : Player)
					{
						if(PlayerInfo[i][pSQLID] == ownerid)
						{
							PlayerInfo[i][pPbiskey] = 255;
							GivePlayerCash(i, BizzInfo[b][bPrice]);
							Update(i, pCashx);
						}
					}
					new name[30];
					GetPlayerName(playerid, name, sizeof(name));
					format(string2, sizeof(string2), "%s has bought your business for $%s.", name, FormatNumber(BizzInfo[b][bPrice]));
					mysql_real_escape_string(string2, var100);
					mysql_format(SQL, var100, sizeof(var100), "INSERT INTO `emails` (`playerid`,`Message`) VALUES('%d','%s')", ownerid, var100);
					mysql_tquery(SQL,var100,"","");
					BizzInfo[b][bPrice] = 0;
					OnPropTextdrawUpdate(2,b);
				}
			}
		}
	}
	return 1;
}

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
if(time < 36000) return SS(playerid, COLOR_LIGHTGREEN3, "Trebuie sa ai 10 ore jucate in ultimele 30 de zile (fara AFK/sleep) pentru a putea cumpara o proprietate.", "You need 10 played hours in last 30 days (without AFK/sleep) to buy a property.");
				

maxresdefault.jpg

 

 

 

Link to comment
Share on other sites

  • 0
Quote
if(time < 36000) return SS(playerid, COLOR_LIGHTGREEN3, "Trebuie sa ai 10 ore jucate in ultimele 30 de zile (fara AFK/sleep) pentru a putea cumpara o proprietate.", "You need 10 played hours in last 30 days (without AFK/sleep) to buy a property.");

scoatel si va merge

Link to comment
Share on other sites

  • 0
La 18.12.2018 la 13:32, ASGOOD a spus:
if(time < 36000) return SS(playerid, COLOR_LIGHTGREEN3, "Trebuie sa ai 10 ore jucate in ultimele 30 de zile (fara AFK/sleep) pentru a putea cumpara o proprietate.", "You need 10 played hours in last 30 days (without AFK/sleep) to buy a property.");
				

 

Acum 20 ore, VolticHD a spus:

scoatel si va merge

Am scos ala si acu imi spune ca cica am deja un business si eu nu am. Am incercat si dupa alt cont si tot la fel.

 

Edited by Sprite_RoPlayers
Link to comment
Share on other sites

  • 0

Aici ai urmatoarea problema:

	if(PlayerInfo[playerid][pPbiskey] != 255)
	

 

E posibil ca in baza de date la incarcarea datelor sa fie setata pe 0 ce tine de pPbiskey, ea trebuie facuta default cand se inregistreaza jucatorul(adica sa fie definita pe 255 ca sa nu aibe bizz)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.