Buyhouse+buybiz bug
#1

There's a big bug in my server. When I create a new house with /createhouse and edit it about and try to buy it, it says I'm not near a buyable house, help? Same thing happens with businesses

Buyhouse:
Код:
CMD:buyhouse(playerid, params[])
{
 new string[128], done;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pHouse] && PlayerInfo[playerid][pVHouse] && PlayerInfo[playerid][pVIP] >= 3) return SendClientMessage(playerid, COLOR_GREY, "You already own two houses.");
 if(PlayerInfo[playerid][pHouse] && PlayerInfo[playerid][pVIP] < 3) return SendClientMessage(playerid, COLOR_GREY, "You already own a house.");
 for(new idx=1; idx<MAX_HOUSES; idx++)
 {
     if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
     {
   if(!strcmp("Infinity Roleplay", HouseInfo[idx][hOwner], false))
   {
       if(PlayerInfo[playerid][pMoney] < HouseInfo[idx][hPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this house.");
    GiveDodMoney(playerid, -HouseInfo[idx][hPrice]);
    if(PlayerInfo[playerid][pHouse]) PlayerInfo[playerid][pVHouse] = idx;
    else PlayerInfo[playerid][pHouse] = idx;
       format(HouseInfo[idx][hOwner], 32, "%s", RPNU(playerid));
       format(string, sizeof(string), "{00C0FF}House of %s\nHouse Type: %s\nStatus: %s", HouseInfo[idx][hOwner], HT(idx), RHS(idx));
    UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITE, string);
    SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a house.");
    SendClientMessage(playerid, COLOR_WHITE, " Type /househelp to view your house commands.");
    format(string, sizeof(string), "%s has bought house id %d.", RPN(playerid), idx);
    Log("logs/house.log", string);
    idx = MAX_HOUSES;
    done = 1;
   }
   if(idx == MAX_HOUSES-1 && !done)
   {
       SendClientMessage(playerid, COLOR_GREY, "This house is owned by someone else.");
   }
     }
     if(idx == MAX_HOUSES-1 && !done)
     {
         SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable house.");
     }
 }
 return 1;
}
Buybiz:
Код:
CMD:buybiz(playerid, params[])
{
	new string[128], done;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVBiz] && PlayerInfo[playerid][pVIP] >= 4) return SendClientMessage(playerid, COLOR_GREY, "You already own two businesses.");
	if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVIP] < 4) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
	for(new idx=1; idx<MAX_BIZ; idx++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
	    {
			if(!strcmp("Infinity Roleplay", BizInfo[idx][bOwner], false))
			{
			    if(PlayerInfo[playerid][pMoney] < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
				GiveDodMoney(playerid, -BizInfo[idx][bPrice]);
				if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
				else PlayerInfo[playerid][pBiz] = idx;
			    format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
			    format(string, sizeof(string), "Business of %s\nBusiness type: %s\n%s", BizInfo[idx][bOwner], RBT(idx), RBS(idx));
				UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
				SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
				SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
				format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
				Log("logs/business.log", string);
				idx = MAX_BIZ;
				done = 1;
			}
			if(idx == MAX_BIZ-1 && !done)
			{
			    SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
			}
	    }
	    if(idx == MAX_BIZ-1 && !done)
	    {
	        SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
	    }
	}
	return 1;
}
If you need any more code snippets or the full gamemode, comment below.

Thanks!
Reply
#2

Try that.
Код:
CMD:buyhouse(playerid, params[])
{
 new string[128], done;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pHouse] && PlayerInfo[playerid][pVHouse] && PlayerInfo[playerid][pVIP] >= 3) return SendClientMessage(playerid, COLOR_GREY, "You already own two houses.");
 if(PlayerInfo[playerid][pHouse] && PlayerInfo[playerid][pVIP] < 3) return SendClientMessage(playerid, COLOR_GREY, "You already own a house.");
 for(new idx=1; idx<MAX_HOUSES; idx++)
 {
     if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
     {
   if(!strcmp("Infinity Roleplay", HouseInfo[idx][hOwner], false))
   {
       if(PlayerInfo[playerid][pMoney] < HouseInfo[idx][hPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this house.");
    GiveDodMoney(playerid, -HouseInfo[idx][hPrice]);
    if(PlayerInfo[playerid][pHouse]) PlayerInfo[playerid][pVHouse] = idx;
    else PlayerInfo[playerid][pHouse] = idx;
       format(HouseInfo[idx][hOwner], 32, "%s", RPNU(playerid));
       format(string, sizeof(string), "{00C0FF}House of %s\nHouse Type: %s\nStatus: %s", HouseInfo[idx][hOwner], HT(idx), RHS(idx));
    UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITE, string);
    SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a house.");
    SendClientMessage(playerid, COLOR_WHITE, " Type /househelp to view your house commands.");
    format(string, sizeof(string), "%s has bought house id %d.", RPN(playerid), idx);
    Log("logs/house.log", string);
    idx = MAX_HOUSES;
    done = 1;
   }
   if(idx == MAX_HOUSES-1 && !done)
   {
       SendClientMessage(playerid, COLOR_GREY, "This house is owned by someone else.");
   }
     }
     if(idx == MAX_HOUSES && !done)
     {
         SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable house.");
     }
 }
 return 1;
}
Код:
CMD:buybiz(playerid, params[])
{
	new string[128], done;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVBiz] && PlayerInfo[playerid][pVIP] >= 4) return SendClientMessage(playerid, COLOR_GREY, "You already own two businesses.");
	if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVIP] < 4) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
	for(new idx=1; idx<MAX_BIZ; idx++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
	    {
			if(!strcmp("Infinity Roleplay", BizInfo[idx][bOwner], false))
			{
			    if(PlayerInfo[playerid][pMoney] < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
				GiveDodMoney(playerid, -BizInfo[idx][bPrice]);
				if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
				else PlayerInfo[playerid][pBiz] = idx;
			    format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
			    format(string, sizeof(string), "Business of %s\nBusiness type: %s\n%s", BizInfo[idx][bOwner], RBT(idx), RBS(idx));
				UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
				SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
				SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
				format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
				Log("logs/business.log", string);
				idx = MAX_BIZ;
				done = 1;
			}
			if(idx == MAX_BIZ-1 && !done)
			{
			    SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
			}
	    }
	    if(idx == MAX_BIZ && !done)
	    {
	        SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
	    }
	}
	return 1;
}
Reply
#3

I'll try it now
Reply
#4

Nope doesn't work, this:

Код:
if(!strcmp("Infinity Roleplay", BizInfo[idx][bOwner], false))
and this:

Код:
if(!strcmp("Infinity Roleplay", HouseInfo[idx][hOwner], false))
Were different when I got the gamemode but I changed them to my server name, do they need to be set to what they originally were?
Reply
#5

Quote:
Originally Posted by Gazzy
Посмотреть сообщение
Nope doesn't work, this:

Код:
if(!strcmp("Infinity Roleplay", BizInfo[idx][bOwner], false))
and this:

Код:
if(!strcmp("Infinity Roleplay", HouseInfo[idx][hOwner], false))
Were different when I got the gamemode but I changed them to my server name, do they need to be set to what they originally were?
Nah. that wouldn't really change anything.
Reply
#6

Nevermind couldn't find out how to fix it from anyone so started on a new GM, thanks anyway!
Reply
#7

Also, Wrong section man.
Reply
#8

And btw it was because of
Код:
if(!strcmp("Infinity Roleplay", HouseInfo[idx][hOwner], false))
it should have been
Код:
if(!strcmp("The State", HouseInfo[idx][hOwner], false))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)