Near House
#6

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
You're doing it wrong.

pawn Код:
//This doesn't need a house check as the callback itself will do it.
forward NearHouse(playerid);
public NearHouse(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 4.0, HouseInfo[i][ExitX], HouseInfo[i][ExitY], HouseInfo[i][ExitZ]) && GetWorld(targetid) == GetWorld(playerid))
            {
                sendMessage(playerid, COLOR_DARKGREEN, "%s, %s, San Andreas", ReturnLocationEx(i));
                SCM(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout), /ddo, /knock");
            }
        }
    }
    return 1;
}

//You must check the nearby house before you call this callback!
forward NearHouse(playerid, houseid);
public NearHouse(playerid, houseid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(IsPlayerInRangeOfPoint(playerid, 4.0, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ]) && GetWorld(targetid) == GetWorld(playerid))
        {
            sendMessage(playerid, COLOR_DARKGREEN, "%s, %s, San Andreas", ReturnLocationEx(i));
            SCM(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout), /ddo, /knock");
        }
    }
    return 1;
}
No need for any looping here at all use dynamic areas.
Reply


Messages In This Thread
Near House - by RudeWorld - 14.02.2019, 14:17
Re: Near House - by GeorgeLimit - 14.02.2019, 14:40
Re: Near House - by d3Pedro - 14.02.2019, 14:41
Re: Near House - by RudeWorld - 14.02.2019, 15:05
Re: Near House - by d3Pedro - 14.02.2019, 15:16
Re: Near House - by Pottus - 14.02.2019, 15:47

Forum Jump:


Users browsing this thread: 2 Guest(s)