19.01.2014, 09:41
pawn Код:
Use this but its not tested soo good luck :D
CMD:sellhouse(playerid, params[])
{
new bool:HouseHasCars= false, CarSlot, HouseID;
HouseID = APlayerData[playerid][CurrentHouse];
for(new i; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.50, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ]))
{
new pName[MAX_PLAYER_NAME], string2[128], string3[128], string4[128];
GetPlayerName(playerid, pName, sizeof(pName));
if(strmatch(AHouseData[i][Owner], pName))
{
for (CarSlot = 0; CarSlot < 20; CarSlot++)
if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
HouseHasCars = true;
if(HouseHasCars == false)
{
GivePlayerCash(playerid, floatround(AHouseData[i][price] * 0.75));
format(string2, sizeof(string2), "UPDATE Houses SET Houseowner = '' WHERE HouseID = '%d'", i);
mysql_function_query( Handle, string2, false, "", "" );
SendClientMessage(playerid, 0xFF0000, "Your house has been sold");
format(string3, sizeof(string3), "UPDATE Users SET Houses = '%d' WHERE Name = '%s'", APlayerData[playerid][Houses]--, APlayerData[playerid][Name]);
mysql_function_query( Handle, string3, false, "", "" );
DestroyDynamicPickup(HousePickup[i]);
HousePickup[i] = CreateDynamicPickup(1273, 1, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ], -1);
format(string4, sizeof(string4), "{FFFFFF}This house is for sale!\nPrice: %i Level: %i\n Type /buyhouse to buy\nHouse ID: %i", AHouseData[i][price], AHouseData[i][Houselevel], i);
UpdateDynamic3DTextLabelText(AHouseData[i][HouseLabel], COLOR_GREY, string4);
strdel(AHouseData[i][Owner], 0, 24); //Owner = "" Anyway why the pickup wont get deleted? :| old pickupwill stay
SavePlayer(playerid);
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "You can not sell a house with cars assigned to it.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "This house is not owned by you!");
}
}
return 1;
}
}