Near House
#1

I want to send those two messages when a player near the houses and I tried this it didn't work out for me.
Код:
forward NearHouse(playerid, targetid, houseid);
public NearHouse(playerid, targetid, houseid)
{
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
		for(new i = 0; i < sizeof(HouseInfo); i++)
		{
			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;
}
Reply
#2

forward NearHouse(playerid, targetid, houseid);
public NearHouse(playerid, targetid, houseid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 4.0, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ]) && GetWorld(targetid) == GetWorld(playerid))
{
format(string, sizeof(string), "%s,SanAndreas"'HouseInfo[houseid][address]);
SCM(playerid,string)

SCM(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout), /ddo, /knock");

}
}
}
return 1;
}
Reply
#3

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;
}
Reply
#4

First of thank you but I tried both of it and nothing happened
Reply
#5

Quote:
Originally Posted by RudeWorld
Посмотреть сообщение
First of thank you but I tried both of it and nothing happened
Show the code where you're using this callback.
Reply
#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


Forum Jump:


Users browsing this thread: 3 Guest(s)