24.05.2012, 19:11
pawn Код:
CMD:buyhouse(playerid, params[])
{
if(PlayerInfo[playerid][HouseKey] == 9999)
{
for(new h = 1; h < sizeof(HouseInfo); h++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[h][X], HouseInfo[h][Y], HouseInfo[h][Z]))
{
new string[128], Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
PlayerInfo[playerid][HouseKey] = h;
HouseInfo[h][Owner] = GetPlayerName(playerid, Name, sizeof(Name));
HouseInfo[h][Ownable] = 0;
DestroyPickup(housepickup[h]);
Delete3DTextLabel(housetext[h]);
housepickup[h] = CreatePickup(1272, 1, HouseInfo[h][X], HouseInfo[h][Y], HouseInfo[h][Z], 0);
format(string, sizeof(string), "This house is owned. Owner: %s", Name);
housetext[h] = Create3DTextLabel(string, COLOR_RED, HouseInfo[h][X], HouseInfo[h][Y], HouseInfo[h][Z], 10.0, 0);
format(file, sizeof(file), "RRP/houses/%d.ini", h);
if(fexist(file))
{
dini_Set(file, "Owner", Name);
dini_IntSet(file, "Ownable", 0);
}
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "HouseKey", h);
}
return 1;
}
}
return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near any house.");
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You already own a house.");
}

