Near Player - 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: Near Player (
/showthread.php?tid=632071)
Near Player -
silverms - 08.04.2017
so don't ask why I need this but I need it I have made this thing so that it give me the near players from 100meters away from me but this give me 1 player what if I need to get all the players that are near me what should I do here is the code:
PHP код:
CMD:pnear(playerid, params[])
{
new string[64], Float:tx[MAX_PLAYERS], Float:ty[MAX_PLAYERS], Float:tz[MAX_PLAYERS], tname[MAX_PLAYER_NAME];
if(adlvl(playerid) <5) return 0;
SendClientMessage(playerid, COLOR_YELLOW, "* Listing all Player(s) within 100 meters of you...");
for(new i=1; i<MAX_PLAYERS ; i++)
{
GetPlayerPos(i, tx[i], ty[i], tz[i]);
if(IsPlayerInRangeOfPoint(playerid, 100.0, tx[i], ty[i], tz[i]) && i!=playerid)
{
GetPlayerName(i, tname, sizeof(tname));
format(string, sizeof(string), "Playerid: %d | Name: %s", i, tname);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}
Re: Near Player -
LazzyBoy - 08.04.2017
Код:
GetPlayerPos(playerid,tx[i], ty[i], tz[i]);// First get player's pos
if(IsPlayerInRangeOfPoint(i, 100.0, tx[i], ty[i], tz[i]) && i!=playerid) // loop throught all players that are near that pos
{
not sure if it is what you wanted but give it a try.
Re: Near Player -
silverms - 09.04.2017
no what I want is when it format the string it format It with all the players that are around nor only one
Re: Near Player -
LazzyBoy - 09.04.2017
Код:
format(string, sizeof(string), "%s Playerid: %d | Name: %s",string, i, tname);
Not sure if this works for SendClientMessage but it works with GameText since im using that.
Re: Near Player -
Threshold - 09.04.2017
PHP код:
CMD:pnear(playerid, params[])
{
if(adlvl(playerid) < 5) return 0;
new string[48], Float:tx, Float:ty, Float:tz, tname[MAX_PLAYER_NAME];
SendClientMessage(playerid, COLOR_YELLOW, "* Listing all Player(s) within 100 meters of you...");
GetPlayerPos(playerid, tx, ty, tz);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i) || i == playerid) continue;
if(GetPlayerDistanceFromPoint(i, tx, ty, tz) < 100.0)
{
GetPlayerName(i, tname, sizeof(tname));
format(string, sizeof(string), "Playerid: %d | Name: %s", i, tname);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}