Hello guys.
I wanted to ask you can you find the bug in this code , cause i want to make player spawn in the bed if it is taken ,but it sends me to the point where i should be after i get healed.
pawn Код:
enum e_LigoninesLovos
{
bool: LL_taken,
Float: LL_pos[4]
};
new LigoninesLovos[][e_LigoninesLovos] =
{
{false, {-197.1666,-1759.9664,676.4661,272.1911}},
{false, {-200.7865,-1763.9344,676.4661,271.3739}},
{false, {-196.8234,-1771.7848,676.4661,357.3743}},
{false, {-197.1552,-1767.9449,676.4661,4.5810}},
{false, {-197.2890,-1763.8800,676.4661,357.3743}}
};
public OnPlayerSpawn(playerid)
{
if(PlayerInfo[playerid][Dead] == true)
{
PlaceToHospitalBed(playerid); // this doesnt work
ApplyAnimation(playerid,"CRACK","crckdeth2",4.1, 1, 1, 1, 1, 1);
SetTimerEx("HospitalHealing",30000,false,"i",playerid); // and it sends me here
TogglePlayerControllable(playerid, 0);
TogglePlayerSpectating(playerid, 0);
SetPlayerCameraPos(playerid,-198.4837,-1759.2366,676.7687);
SetPlayerCameraLookAt(playerid, -198.4377,-1765.7754,675.7687);
SetPlayerInterior(playerid,3);
GameTextForPlayer(playerid,"~w~Gydomas",30000,6);
}
return 1;
}
forward HospitalHealing(playerid);
public HospitalHealing(playerid)
{
PlayerInfo[playerid][Dead] = false;
SetPlayerInterior(playerid,3);
SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687); //and sets my position to here
GameTextForPlayer(playerid,"~w~Pagydytas",3000,6);
TogglePlayerControllable(playerid,1);
TogglePlayerSpectating(playerid,0);
SetCameraBehindPlayer(playerid);
ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
for(new i;i < sizeof(LigoninesLovos); i++)
{
LigoninesLovos[i][LL_taken] = false;
}
return 1;
}
stock PlaceToHospitalBed(playerid)
{
new bool: full = true;
for (new i; i != sizeof (LigoninesLovos); ++i)
{
if (!LigoninesLovos[i][LL_taken])
{
full = false;
break;
}
}
if (full)
{
SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687);
SendClientMessage(playerid,COL_RED,"Palatose nera vietu todel buvai greit pagydytas ant operacinio stalo.");
}
else
{
new Random, count;
for (;;)
{
Random = random(sizeof (LigoninesLovos));
if (LigoninesLovos[Random][LL_taken]) continue;
SetPlayerPos(playerid, LigoninesLovos[Random][LL_pos][0], LigoninesLovos[Random][LL_pos][1], LigoninesLovos[Random][LL_pos][2]);
SetPlayerFacingAngle(playerid, LigoninesLovos[Random][LL_pos][3]);
LigoninesLovos[Random][LL_taken] = true;
if (++count == sizeof (LigoninesLovos)) break;
}
}
return 1;
}
pawn Код:
SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687); //and sets my position to here
if (full)
{
SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687);
SendClientMessage(playerid,COL_RED,"Palatose nera vietu todel buvai greit pagydytas ant operacinio stalo.");
}
This isn't a fix, I just wanted to point out that these 2 coords are the same. Perhaps the loop that checks if the beds are full is always outputting "true."