10.02.2014, 00:43
pawn Код:
CMD:buyprop(playerid,params[])
{
if(pInfo[playerid][pHouse] == 1) return SendClientMessage(playerid,COLOR_GREY,"You cannot buy more than one house.");
for(new i = 1; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,HouseInfo[i][hX],HouseInfo[i][hY],HouseInfo[i][hZ]))
{
if(!HouseInfo[i][hX]) continue;
if(GetPlayerMoney(playerid) >= HouseInfo[i][hPrice])
{
if(strcmp(HouseInfo[i][hOwner],"",false))
{
format(HouseInfo[i][hOwner],24,"%s",pName(playerid));
pInfo[playerid][pHouse] = 1;
format(string,sizeof(string),"You've successfully bought this house.");
DestroyDynamicPickup(HouseInfo[i][hPickup]);
GivePlayerMoney(playerid,-HouseInfo[i][hPrice]);
format(string,sizeof(string),"Owner: %s",HouseInfo[i][hOwner]);
HouseInfo[i][hText] = CreateDynamic3DTextLabel(string, 0xFFFFFFFF, HouseInfo[i][hX],HouseInfo[i][hY],HouseInfo[i][hZ], 50, INVALID_PLAYER_ID,INVALID_VEHICLE_ID, 0, -1,0);
HouseInfo[i][hPickup] = CreateDynamicPickup(1272,1,HouseInfo[i][hX],HouseInfo[i][hY],HouseInfo[i][hZ],-1,0,-1,50.0);
}
}
else return SendClientMessage(playerid,COLOR_GREY,"You don't have enough money.");
}
else return SendClientMessage(playerid,COLOR_GREY,"You're nowhere close to a house.");
}
return 1;
}