10.02.2014, 03:07
I've read your code again and (maybe) found the problem,
Your code was designed to send this message on the first house.
Therefore i modified your code abit,
Also please read the comments beside each line.
Your code was designed to send this message on the first house.
Therefore i modified your code abit,
pawn Код:
CMD:buyprop(playerid,params[])
{
new bool:pnearhousecheck = false;
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; // no need, what if the house position was in negative?
if(GetPlayerMoney(playerid) >= HouseInfo[i][hPrice])
{
if(!strcmp(HouseInfo[i][hOwner],"",false)) // i guess it shouldn't be if(strcmp(HouseInfo[i][hOwner],"",false)) ?
{
format(HouseInfo[i][hOwner],24,"%s",pName(playerid));
pInfo[playerid][pHouse] = 1;
SendClientMessage(playerid, -1, "You've successfully bought this house.");
//format(string,sizeof(string),"You've successfully bought this house."); // Why not just use SendClientMessage? ^
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, "House Bought already."); // a SendClientMessage from me
}
else return SendClientMessage(playerid,COLOR_GREY,"You don't have enough money.");
pnearhousecheck = true;
break;
}
}
if(!pnearhousecheck)
SendClientMessage(playerid,COLOR_GREY,"You're nowhere close to a house.");
return 1;
}