CMD:enter(playerid, params[])
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z]))
{
if(HouseInfo[i][Lock] == 0)
{
SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
SetPlayerInterior(playerid, HouseInfo[i][Int]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]);
return 1;
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
}
return 1;
}
//LoadHouses
forward LoadHouses();
public LoadHouses()
{
for(new i = 1; i < sizeof(HouseInfo); i++)
{
format(file, sizeof(file), "RRP/houses/%d.ini", i);
if(fexist(file))
{
HouseInfo[i][X] = dini_Int(file, "X");
HouseInfo[i][Y] = dini_Int(file, "Y");
HouseInfo[i][Z] = dini_Int(file, "Z");
HouseInfo[i][Int] = dini_Int(file, "Int");
HouseInfo[i][Vw] = dini_Int(file, "Vw");
HouseInfo[i][Owner] = dini_Int(file, "Owner");
HouseInfo[i][Lock] = dini_Int(file, "Lock");
HouseInfo[i][Price] = dini_Int(file, "Price");
HouseInfo[i][IntX] = dini_Int(file, "IntX");
HouseInfo[i][IntY] = dini_Int(file, "IntY");
HouseInfo[i][IntZ] = dini_Int(file, "IntZ");
}
}
print("[RRP]: Houses Loadeds");
return 1;
}
CMD:enter(playerid, params[])
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z]))
{
if(HouseInfo[i][Lock] == 0)
{
SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
SetPlayerInterior(playerid, HouseInfo[i][Int]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]);
return 1; //REMOVE THIS LINE
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
}
return 1;
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
That's still wrong though. In fact, that return 1 can stay as the correct house has been found and no further checking is required. The culprit is this line:
pawn Code:
|
CMD:enter(playerid, params[])
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z]))
{
if(HouseInfo[i][Lock] == 0)
{
SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
SetPlayerInterior(playerid, HouseInfo[i][Int]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]);
return 1;
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
}
return 1;
}
CMD:enter(playerid, params[]) //The command is performed
{
for(new i = 0; i < sizeof(HouseInfo); i++) //Loop through the variable HouseInfo (=300)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[i][X], HouseInfo[i][Y], HouseInfo[i][Z])) //Is the player in the X+Y+Z? (Range 10 - Way too big)
{
if(HouseInfo[i][Lock] == 0) //When the variable 'Lock' is 0 (unlocked)
{
SetPlayerPos(playerid, HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ]);
SetPlayerInterior(playerid, HouseInfo[i][Int]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][Vw]); //Set pos etc
return 1;
}
else //When the house is locked
{
SendClientMessage(playerid, 0xFFFFFFFF, "This house is locked.");
return 1; //The return! Does the same as 'return SendClientMessage...' in the previous command. Loop stopped
}
}
else //When the player ain't near a house
{
SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a house.");
return 1; //Again...
}
}
return 1;
}
CMD:enter(playerid, params[])
{
for(new h=0; h<sizeof(House); h++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, House[h][henx], House[h][heny], House[h][henz]))
{
if(IsInHouse[playerid] == 0)
{
if(House[h][hlocked] == 0)
{
GetPlayerPos(playerid, PP[playerid], PP2[playerid], PP3[playerid]);
SetPlayerPos(playerid, House[h][hexx], House[h][hexy], House[h][hexz]);
SetPlayerInterior(playerid, House[h][hint]);
SetPlayerVirtualWorld(playerid, House[h][hvw]);
IsInHouse[playerid] = 1;
IsInHouseID[playerid] = h;
}
else return SendClientMessage(playerid, COLOR_GREY, "This house is locked!");
}
}
for(new b = 0; b < sizeof(BizzInfo); b++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizzInfo[b][benx], BizzInfo[b][beny], BizzInfo[b][benz]))
{
if(IsInBizz[playerid] == 0)
{
if(BizzInfo[b][bopen] == 1)
{
if(BizzInfo[b][bprods] >= 1)
{
if(BizzInfo[b][btype] != 6 && BizzInfo[b][btype] != 7)
{
GetPlayerPos(playerid, PP[playerid], PP2[playerid], PP3[playerid]);
SetPlayerPos(playerid, BizzInfo[b][bexx], BizzInfo[b][bexy], BizzInfo[b][bexz]);
SetPlayerInterior(playerid, BizzInfo[b][bint]);
SetPlayerVirtualWorld(playerid, BizzInfo[b][bvw]);
IsInBizz[playerid] = 1;
GivePlayerMinusCash(playerid, BizzInfo[b][bfee]);
BizzInfo[b][bbank] = BizzInfo[b][bbank] + BizzInfo[b][bfee];
IsInBizzID[playerid] = b;
BizzInfo[b][customers] = BizzInfo[b][customers] + 1;
IsInBizzType[playerid] = BizzInfo[b][btype];
BizzInfo[b][bprods] = BizzInfo[b][bprods] -1;
}
else return SendClientMessage(playerid, COLOR_GREY, "Can't enter this business!");
}
else return SendClientMessage(playerid, COLOR_GREY, "This business is out of stock!");
}
else return SendClientMessage(playerid, COLOR_GREY, "Business is Closed!!");
}
}
}
}
return 1;
}