11.11.2010, 18:18
pawn Code:
dcmd_sellhouse(playerid, params[])
{
#pragma unused params
for(new h = 0; h < MAX_HOUSES; h++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[h][hEntrancePosX], HouseInfo[h][hEntrancePosY], HouseInfo[h][hEntrancePosZ]))
{
new pName[MAX_PLAYER_NAME],string[128];GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
if(!strcmp(HouseInfo[h][hOwner], pName, false) && HouseInfo[h][hOwned] == 1) //You have to be the owner of the house ;) (the only problem is, if you are using someone elses name, you can sell it too, but you can integrate this script with another script of course ;)
{
HouseInfo[h][hOwned] = 0;
strdel(HouseInfo[h][hOwner], 0, strlen(HouseInfo[h][hOwner]));
GivePlayerMoney(playerid, (HouseInfo[h][hPrice]/2)); //Let's return the half of the price
DestroyMapIcon(HOUSE_ICON[h]); DestroyPickup(HOUSE_PICKUP[h]);
HOUSE_ICON[h] = CreateMapIcon(31, 0, HouseInfo[h][hEntrancePosX], HouseInfo[h][hEntrancePosY], HouseInfo[h][hEntrancePosZ]);
HOUSE_PICKUP[h] = CreatePickup(1272, 1, HouseInfo[h][hEntrancePosX], HouseInfo[h][hEntrancePosY], HouseInfo[h][hEntrancePosZ]);
format(string, sizeof(string), "** %s has selled a house", pName);
SendClientMessageToAll(0x00FF00AA, string);
SaveAllHouses();
return 1;
}
else return SendClientMessage(playerid, 0xFF0000AA, "** You can only sell your own houses ;)");
}
}
return 1;
}