CMD:enterhouse(playerid,params[]) { for(new h=0;h<MAX_HOUSES+1;h++) { if(IsPlayerInRangeOfPoint(playerid,1.0,HouseInfo[h][hEnterX],HouseInfo[h][hEnterY],HouseInfo[h][hEnterZ])) { SetPlayerPos(playerid,HouseInfo[h][hExitX],HouseInfo[h][hExitY],HouseInfo[h][hExitZ]); SetPlayerInterior(playerid,HouseInfo[h][hInterior]); } } return 1; }
Because HouseInfo goes out of bounds. Replace with MAX_HOUSES+1 with sizeof (HouseInfo) in the loop.
When a player is in range of a house, set their interior and position and stop the loop using break; |
CMD:buyhouse(playerid,params[]) { for(new h=0;h<sizeof(HouseInfo);h++) { if(IsPlayerInRangeOfPoint(playerid,1.0,HouseInfo[h][hEnterX],HouseInfo[h][hEnterY],HouseInfo[h][hEnterZ])) { if(GetPlayerMoney(playerid) >= HouseInfo[h][hPrice]) { new hpath[256]; format(hpath,sizeof(hpath),"/Houses/%d.ini",h); dini_IntSet(hpath,"hOwned",1); dini_Set(hpath,"hOwner",GetName(playerid)); PlayerHouse[playerid] = h; Delete3DTextLabel(HouseInfo[h][Label]); LoadHouses(); break; } } } return 1; }