SA-MP Forums Archive
House System (Enter/Exit bug) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House System (Enter/Exit bug) (/showthread.php?tid=513219)



House System (Enter/Exit bug) - RenSoprano - 15.05.2014

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]);
            }
        }



Re: House System (Enter/Exit bug) - biker122 - 15.05.2014

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


Re: House System (Enter/Exit bug) - RenSoprano - 15.05.2014

Nope because my houses starts from 1


Re: House System (Enter/Exit bug) - Beckett - 15.05.2014

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]);
            }
        }