/enter dosent work correctly - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /enter dosent work correctly (
/showthread.php?tid=153976)
/enter dosent work correctly -
WardenCS - 11.06.2010
Hey,i have the /enter command,it will enter to house,it should be if Explored is same as hId,but when my Explored is 1 i can enter any houses even if hId is 2,i hope you understood.thanks
Код:
if(strcmp(cmdtext, "/enter", true) == 0)
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 3 ,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
{
new Houseid;
Houseid = HouseInfo[ playerid ] [ hId ];
if(PlayerStatistics [playerid] [Explored] == Houseid)
{
SetPlayerInterior(playerid,HouseInfo[i][hInt]);
SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
}
else GameTextForPlayer(playerid, "~r~You have to Explore this first!", 5000, 6);
}
}
return 1;
}
Re: /enter dosent work correctly -
DJDhan - 11.06.2010
Код:
if(PlayerStatistics [playerid] [Explored] == Houseid)
The problem is that you are not going through all the elements of the array "Explored".
Код:
if(strcmp(cmdtext, "/enter", true,6) == 0)
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 3 ,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
{
new Houseid;
Houseid = HouseInfo[ playerid ] [ hId ];
for(new j=0; j<MAX_EXPLORED; j++) // here you go through all houses explored by the player (change the MAX_EXPLORED to anything you have as max array size)
{
if(PlayerStatistics [playerid] [j] == Houseid)
{
SetPlayerInterior(playerid,HouseInfo[i][hInt]);
SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
}
else GameTextForPlayer(playerid, "~r~You have to Explore this first!", 5000, 6);
}
}
}
return 1;
}
Re: /enter dosent work correctly -
WardenCS - 11.06.2010
Код:
if(PlayerStatistics [playerid] [j] == Houseid)
Gives me tag mismatch and wont work :S
now i cant enter any house
EDIT:
fixed it in my written command,i false wrote playerid,but i had to write i:P
Код:
Houseid = HouseInfo[ playerid ] [ hId ];
to
Код:
Houseid = HouseInfo[ i ] [ hId ];