House help.
#1

Basically when i do /sellhouse the house stats change to 13
Images:
http://imgur.com/a/aaxxv
Код:
CMD:sellhouse(playerid, params[])
{
	new string[128];
	new house = PlayerInfo[playerid][pPhousekey];
	new house2 = PlayerInfo[playerid][pPhousekey2];
	new houseid;

	if(house == INVALID_HOUSE_ID && house2 == INVALID_HOUSE_ID)
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "You don't own a house.");
		return 1;
	}

	if(IsPlayerInRangeOfPoint(playerid, 1.0,HouseInfo[house][hExteriorX],HouseInfo[house][hExteriorY],HouseInfo[house][hExteriorZ]))
	{
		ClearHouse(house);
		HouseInfo[house][hLock] = 1;
		format( HouseInfo[house][hOwner], 128, "Nobody" );
		GivePlayerCash(playerid,HouseInfo[house][hValue]);
		HouseInfo[house][hGLUpgrade] = 1;
		PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		format(string, sizeof(string), "~w~Congratulations~n~ You have sold your property for ~n~~g~$%d", HouseInfo[house][hValue]);
		GameTextForPlayer(playerid, string, 4000, 3);
		PlayerInfo[playerid][pPhousekey] = INVALID_HOUSE_ID;
		if(PlayerInfo[playerid][pVW] == house+6000)
		{
			SetPlayerInterior(playerid,0);
			SetPlayerPos(playerid,HouseInfo[house][hExteriorX],HouseInfo[house][hExteriorY],HouseInfo[house][hExteriorZ]);
			PlayerInfo[playerid][pInt] = 0;
			PlayerInfo[playerid][pPhousekey] = INVALID_HOUSE_ID;
		}
		PlayerInfo[playerid][pInsurance] = 0;
		OnPlayerStatsUpdate(playerid);
		DestroyDynamicPickup(HouseInfo[house][hPickupID]);
		HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
		DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
		format(string, sizeof(string), "{CCFFFF}((For Sale))%s\nPrice: $%d\n Level: %d\nID: %d",HouseInfo[houseid][hDescription],HouseInfo[houseid][hValue],HouseInfo[houseid][hLevel],houseid);
		HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5, 30.0, .testlos = 1);
		new ip[32];
		GetPlayerIp(playerid,ip,sizeof(ip));
		format(string,sizeof(string),"%s (IP: %s) has sold their house (ID %d) for $%d.",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hValue]);
		Log("logs/house.log", string);
		//SaveHouses();
		//DestroyDynamicPickup(HouseInfo[house][hPickupID]);
		//HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
		//DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
		DestroyDynamicPickup(HouseInfo[houseid][hPickupID]);
		DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]);
		format(string, sizeof(string), "{CCFFFF}((For Sale))%s\nPrice: $%d\n Level: %d\nID: %d",HouseInfo[houseid][hDescription],HouseInfo[houseid][hValue],HouseInfo[houseid][hLevel],houseid);
		HouseInfo[houseid][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
		HouseInfo[houseid][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ]);
		//LoadHouses();
		return 1;
	}
Код:
CMD:buyhouse(playerid, params[])
{
    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( 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]);
						if(HouseInfo[h][hCustomInterior] == 1)
						{
							TogglePlayerControllable(playerid, 0);
							GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
							SetPVarInt(playerid, "LoadingObjects", 1);
							SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
						}
						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!");
						SaveHouses();
						OnPlayerStatsUpdate(playerid);
						PlayerInfo[playerid][pLocal] = h+6000;
						PlayerInfo[playerid][pVW] = h+6000;
						SetPlayerVirtualWorld(playerid, h+6000);
						DestroyDynamicPickup(HouseInfo[h][hPickupID]);
						HouseInfo[h][hPickupID] = CreateDynamicPickup(1272, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]);
						format(string, sizeof(string), "Owner:  %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
						UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string);
						new ip[32];
						GetPlayerIp(playerid,ip,sizeof(ip));
						format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),ip,h,HouseInfo[h][hValue]);
						Log("logs/house.log", string);
						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]);
						if(HouseInfo[h][hCustomInterior] == 1)
						{
							TogglePlayerControllable(playerid, 0);
							GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
							SetPVarInt(playerid, "LoadingObjects", 1);
							SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
						}
						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!");
						SaveHouses();
						OnPlayerStatsUpdate(playerid);
						PlayerInfo[playerid][pLocal] = h+6000;
						PlayerInfo[playerid][pVW] = h+6000;
						SetPlayerVirtualWorld(playerid, h+6000);
						DestroyDynamicPickup(HouseInfo[h][hPickupID]);
						HouseInfo[h][hPickupID] = CreateDynamicPickup(1272, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]);
						format(string, sizeof(string), "Owner: %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
						UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string);
						new ip[32];
						GetPlayerIp(playerid,ip,sizeof(ip));
						format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),ip,h,HouseInfo[h][hValue]);
						Log("logs/house.log", string);
						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;
}
Reply
#2

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)