HELP NEED HELP WITH /BUYHOUSE
#1

i /buyhouse and it don't buy it?

any suggestions?



Код:
CMD:buyhouse(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 100.0, 1109.0, 1537.0, 5.0) && PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_WHITE, "You cannot use this command in this area!");
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new h = 0; h < sizeof(HouseInfo); h++)
	{
        if(IsPlayerInRangeOfPoint(playerid,2.0,HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]) )
		{
		    if(PlayerInfo[playerid][pFreezeHouse] == 1)
		    {
		        return SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: Your house assets are frozen, you cannot buy a house!");
			}
            if( HouseInfo[h][hOwned] == 0 )
			{
                if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
				{
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", HouseInfo[h][hLevel]);
                    SendClientMessageEx(playerid, COLOR_GRAD5, string);
                    return 1;
                }
                if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID)
				{

					if(GetPlayerCash(playerid) > HouseInfo[h][hValue])
					{
						PlayerInfo[playerid][pPhousekey] = h;
						HouseInfo[h][hOwned] = 1;
						GetPlayerName(playerid, sendername, sizeof(sendername));
						strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
						GivePlayerCash(playerid,-HouseInfo[h][hValue]);
						SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]);
						SetPlayerPos(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]);
						GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
						PlayerInfo[playerid][pInt] = HouseInfo[h][hHInteriorWorld];
						SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
						SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
						SaveHouse(h);
						OnPlayerStatsUpdate(playerid);
						PlayerInfo[playerid][pVW] = h+6000;
						SetPlayerVirtualWorld(playerid, h+6000);
						DestroyDynamicPickup(HouseInfo[h][hPickupID]);
						HouseInfo[h][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]);
						format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
						UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string);
						format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),GetPlayerIpEx(playerid),h,HouseInfo[h][hValue]);
						Log("logs/house.log", string);
						if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME);
						return 1;
					}
					else
					{
						SendClientMessageEx(playerid, COLOR_WHITE, "   You don't have the cash for that!");
						return 1;
					}
				}
				else if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID)
				{
					if(GetPlayerCash(playerid) > HouseInfo[h][hValue])
					{
						PlayerInfo[playerid][pPhousekey2] = h;
						HouseInfo[h][hOwned] = 1;
						GetPlayerName(playerid, sendername, sizeof(sendername));
						strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
						GivePlayerCash(playerid,-HouseInfo[h][hValue]);
						SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]);
						SetPlayerPos(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]);
						GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
						PlayerInfo[playerid][pInt] = HouseInfo[h][hHInteriorWorld];
						SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
						SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
						SaveHouse(h);
						OnPlayerStatsUpdate(playerid);
						PlayerInfo[playerid][pVW] = h+6000;
						SetPlayerVirtualWorld(playerid, h+6000);
						DestroyDynamicPickup(HouseInfo[h][hPickupID]);
						HouseInfo[h][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]);
						format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
						UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string);
						format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),GetPlayerIpEx(playerid),h,HouseInfo[h][hValue]);
						Log("logs/house.log", string);
						if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME);
						return 1;
					}
					else
					{
						SendClientMessageEx(playerid, COLOR_WHITE, "   You don't have the cash for that!");
						return 1;
					}
				}
            }
            else
			{
                SendClientMessageEx( playerid, COLOR_WHITE, "This house is owned." );
            }
        }
    }
    return 1;
}
Код:
stock SaveHouse(houseid)
{
	new string[2048];

	format(string, sizeof(string), "UPDATE `houses` SET \
		`Owned`=%d, \
		`Level`=%d, \
		`HInteriorWorld`=%d, \
		`Description`='%s', \
		`Owner`='%s', \
		`ExteriorX`=%f, \
		`ExteriorY`=%f, \
		`ExteriorZ`=%f, \
		`ExteriorR`=%f, \
		`InteriorX`=%f, \
		`InteriorY`=%f, \
		`InteriorZ`=%f, \
		`InteriorR`=%f,",
		HouseInfo[houseid][hOwned],
		HouseInfo[houseid][hLevel],
		HouseInfo[houseid][hHInteriorWorld],
		HouseInfo[houseid][hDescription],
		HouseInfo[houseid][hOwner],
		HouseInfo[houseid][hExteriorX],
		HouseInfo[houseid][hExteriorY],
		HouseInfo[houseid][hExteriorZ],
		HouseInfo[houseid][hExteriorR],
		HouseInfo[houseid][hInteriorX],
		HouseInfo[houseid][hInteriorY],
		HouseInfo[houseid][hInteriorZ],
		HouseInfo[houseid][hInteriorR]
	);

	format(string, sizeof(string), "%s \
		`Lock`=%d, \
		`Rentable`=%d, \
		`RentFee`=%d, \
		`Value`=%d, \
		`SafeMoney`=%d, \
		`Pot`=%d, \
		`Crack`=%d, \
		`Materials`=%d, \
		`Weapons0`=%d, \
		`Weapons1`=%d, \
		`Weapons2`=%d, \
		`Weapons3`=%d, \
		`Weapons4`=%d, \
		`GLUpgrade`=%d, \
		`CustomInterior`=%d, \
		`CustomExterior`=%d, \
		`ExteriorA`=%f, \
		`InteriorA`=%f, \
		`MailX`=%f, \
		`MailY`=%f, \
		`MailZ`=%f, \
		`MailA`=%f, \
		`MailType`=%d WHERE `id`=%d",
		string,
		HouseInfo[houseid][hLock],
		HouseInfo[houseid][hRentable],
		HouseInfo[houseid][hRentFee],
		HouseInfo[houseid][hValue],
   		HouseInfo[houseid][hSafeMoney],
		HouseInfo[houseid][hPot],
		HouseInfo[houseid][hCrack],
		HouseInfo[houseid][hMaterials],
		HouseInfo[houseid][hWeapons][0],
		HouseInfo[houseid][hWeapons][1],
		HouseInfo[houseid][hWeapons][2],
		HouseInfo[houseid][hWeapons][3],
		HouseInfo[houseid][hWeapons][4],
		HouseInfo[houseid][hGLUpgrade],
		HouseInfo[houseid][hCustomInterior],
		HouseInfo[houseid][hCustomExterior],
		HouseInfo[houseid][hExteriorA],
		HouseInfo[houseid][hInteriorA],
		HouseInfo[houseid][hMailX],
		HouseInfo[houseid][hMailY],
		HouseInfo[houseid][hMailZ],
		HouseInfo[houseid][hMailA],
		HouseInfo[houseid][hMailType],
		houseid+1
	); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).

	mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
}

Код:
stock LoadHouse(houseid)
{
	new string[128];
	printf("[LoadHouse] Loading HouseID %d's data from database...", houseid);
	format(string, sizeof(string), "SELECT * FROM `houses` WHERE `id`=%d",houseid+1); // Array starts at zero, MySQL starts at one.
	mysql_function_query(MainPipeline, string, true, "OnLoadHouse", "i", houseid);
}
Reply
#2

I hope all support
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)