/me radius
#1

Hi, i got this cmd from one a/me
Код:
if(strcmp(cmdtext, "/me", true, 3)==0) { // 3 is the length of /me
 new str[256], pname[256]; GetPlayerName(playerid, pname, 256);
 format(str, 256, "*** %s %s", pname, cmdtext[4]);
 SendClientMessageToAll(COLOR_LIGHTBLUE, str);
  }
 return 1;
 }
But when i use it all people can see it.. I want to that command only player in Radius: 30

Thank for helping
Reply
#2

In OnPlayerCommand

pawn Код:
if(strcmp(cmdtext, "/me", true, 3)==0) // 3 is the length of /me
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(Float:GetDistanceBetweenPlayers(playerid, i) < 30.0)
      {
        new str[256], pname[256]; GetPlayerName(playerid, pname, 256);
        format(str, 256, "*** %s %s", pname, cmdtext[4]);
        SendClientMessageToAll(COLOR_LIGHTBLUE, str);
      }
    }
  }
  return 1;
}
Bottom of script:

pawn Код:
stock Float:GetDistanceBetweenPlayers(playerid, giveplayerid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(giveplayerid,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
Reply
#3

Quote:
Originally Posted by Mentis
In OnPlayerCommand

pawn Код:
if(strcmp(cmdtext, "/me", true, 3)==0) // 3 is the length of /me
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(Float:GetDistanceBetweenPlayers(playerid, i) < 30.0)
      {
        new str[256], pname[256]; GetPlayerName(playerid, pname, 256);
        format(str, 256, "*** %s %s", pname, cmdtext[4]);
        SendClientMessageToAll(COLOR_LIGHTBLUE, str);
      }
    }
  }
  return 1;
}
Bottom of script:

pawn Код:
stock Float:GetDistanceBetweenPlayers(playerid, giveplayerid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(giveplayerid,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
E:\Database\Lagre 2008.06\06.06.08\Diverse\Programering\samp022serve r.win32\gamemodes\Daniel_Mod.pwn(706) : warning 208: function with tag result used before definition, forcing reparse

And that is line:
pawn Код:
stock Float:GetDistanceBetweenPlayers(playerid, giveplayerid)
Reply
#4

well never had that happen with a stock myself but maybe try moving

Код:
stock Float:GetDistanceBetweenPlayers(playerid, giveplayerid)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	GetPlayerPos(playerid,x1,y1,z1);
	GetPlayerPos(giveplayerid,x2,y2,z2);
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
to the top of the script will fix the problem, better yet, make a new text file, paste the above into it, save the file as a .inc, and add the include line for the file to the top, if you dont understand that then just put it at the top

Good luck

regards orph
Reply
#5

Quote:
Originally Posted by Orpheus
well never had that happen with a stock myself but maybe try moving

Код:
stock Float:GetDistanceBetweenPlayers(playerid, giveplayerid)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	GetPlayerPos(playerid,x1,y1,z1);
	GetPlayerPos(giveplayerid,x2,y2,z2);
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
to the top of the script will fix the problem, better yet, make a new text file, paste the above into it, save the file as a .inc, and add the include line for the file to the top, if you dont understand that then just put it at the top

Good luck

regards orph
I done that you said.. but still other player far away Ёcan see it
Reply
#6

if(strcmp(cmdtext, "/me", true, 3)==0) // 3 is the length of /me
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Float:GetDistanceBetweenPlayers(playerid, i) < 30.0)
{
new str[256], pname[256]; GetPlayerName(playerid, pname, 256);
format(str, 256, "*** %s %s", pname, cmdtext[4]);
SendClientMessageToAll(COLOR_LIGHTBLUE, str);
}
return 1; <yes its in this errror <send msg>
}
}
return 0; < says no its not in this area
}

something like that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)