House System (Enter/Exit bug)
#1

So I tried to fix a really annoying bug in my house system so I will explain it.

When you enter in house everything works perfect but when you exit it spawns you at last created house. I checked everything but I can't find why this happen.

pawn Код:
for(new i = 1; i < sizeof(HouseInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[i][hEnterX],HouseInfo[i][hEnterY],HouseInfo[i][hEnterZ]))
            {
                if(HouseInfo[i][hLock] == 1) return GameTextForPlayer(playerid, "~r~Locked", 3000, 6);
                SetPlayerPos(playerid, HouseInfo[i][hExitX],HouseInfo[i][hExitY],HouseInfo[i][hExitZ]);
                SetPlayerInterior(playerid, HouseInfo[i][hExitInt]);
                SetPlayerVirtualWorld(playerid, i+HouseInfo[i][hExitVW]);
            }
        }
       
        for(new i = 1; i < sizeof(HouseInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[i][hExitX],HouseInfo[i][hExitY],HouseInfo[i][hExitZ]))
            {
                SetPlayerPos(playerid, HouseInfo[i][hEnterX],HouseInfo[i][hEnterY],HouseInfo[i][hEnterZ]);
                SetPlayerInterior(playerid, 0);
                SetCameraBehindPlayer(playerid);
                SetPlayerVirtualWorld(playerid, HouseInfo[i][hEnterVW]);
            }
        }
Reply
#2

Shouldn't
pawn Код:
for(new i = 1; i < sizeof(HouseInfo); i++)
be
pawn Код:
for(new i = 0; i < sizeof(HouseInfo); i++)
?
Reply
#3

Nope because my houses starts from 1
Reply
#4

Just saying there's no need of you looping twice.

pawn Код:
for(new i = 1; i < sizeof(HouseInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[i][hEnterX],HouseInfo[i][hEnterY],HouseInfo[i][hEnterZ]))
            {
                if(HouseInfo[i][hLock] == 1) return GameTextForPlayer(playerid, "~r~Locked", 3000, 6);
                SetPlayerPos(playerid, HouseInfo[i][hExitX],HouseInfo[i][hExitY],HouseInfo[i][hExitZ]);
                SetPlayerInterior(playerid, HouseInfo[i][hExitInt]);
                SetPlayerVirtualWorld(playerid, i+HouseInfo[i][hExitVW]);
            }
            else if(IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[i][hExitX],HouseInfo[i][hExitY],HouseInfo[i][hExitZ]))
            {
                SetPlayerPos(playerid, HouseInfo[i][hEnterX],HouseInfo[i][hEnterY],HouseInfo[i][hEnterZ]);
                SetPlayerInterior(playerid, 0);
                SetCameraBehindPlayer(playerid);
                SetPlayerVirtualWorld(playerid, HouseInfo[i][hEnterVW]);
            }
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)