18.02.2012, 22:34
Look:
That's the original code. Now I will make it different so that you might understand it.
This code is exactly doing the same. In fact, this is what the code Ricardo provided actually does.
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;
}
pawn Code:
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;
}