Whisper problem
#1

Hello, i have this whisper command, and works quite good but i have a little problem. It works only if all players are in that range, and i don't want that. Do you have any idea how should i fix this?

PHP код:
public SendWHISPERMessage(color,const string[])
{
    for(new 
0MAX_PLAYERSi++)
    {
    if(
IsPlayerConnected(i) == 1)
    
SendClientMessage(iCOLOR_ORANGE ,string);
    }
    return 
1;
}
CMD:w(playeridparams[])
{
    new 
Float:xFloat:yFloat:zi;
    if(
sscanf(params,"u",mystring)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [message]");
    for( 
0MAX_PLAYERSi++){
    
GetPlayerPos(ixyz);
    if(!(
IsPlayerInRangeOfPoint(playerid10xyz))) return SendClientMessage(playeridCOLOR_SILVER,"You are to far from that person.");
    }
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(mystringsizeof(mystring),"%s whispred: %s"pnameparams);
    
SetPlayerChatBubble(playeridparamsCOLOR_ORANGE10.010000);
    
SendWHISPERMessage(COLOR_ORANGEmystring);
     return 
1;

Reply
#2

pawn Код:
public SendWHISPERMessage(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) == 1)
    SendClientMessage(i, COLOR_ORANGE ,string);
    }
    return 1;
}
CMD:w(playerid, params[])
{
    new Float:x, Float:y, Float:z, i;
    if(sscanf(params,"u",mystring)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [message]");

    GetPlayerName(playerid, pname, sizeof(pname));
    format(mystring, sizeof(mystring),"%s whispred: %s", pname, params);

    SetPlayerChatBubble(playerid, params, COLOR_ORANGE, 10.0, 10000);

    SendWHISPERMessage(COLOR_ORANGE, mystring);
     return 1;
}
Reply
#3

When i'm away from anybody it gives me 2 msg's, 1 with the params and one with You are to ..etc?
Any ideas why?

PHP код:
CMD:w(playeridparams[])
{
    new 
Float:xFloat:yFloat:zFloatx1Floaty1Floatz1Floatdistiok 0;
    if(
sscanf(params,"u",mystring)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [message]");
    
GetPlayerPos(playeridxyz);
    for( 
0MAX_PLAYERSi++)
    {
        
GetPlayerPos(ix1y1z1);
        
dist floatsqroot((x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1));
         if(
dist <= 10.0)
         {
            
GetPlayerName(playeridpnamesizeof(pname));
            
format(mystringsizeof(mystring),"%s whispred: %s"pnameparams);
            
SetPlayerChatBubble(playeridparamsCOLOR_ORANGE10.010000);
            
SendClientMessage(,COLOR_ORANGEmystring);
            if(
!= playerid)
            {
                
ok 1;
            }
         }
    }
if(
ok == 0)
{
SendClientMessage(playerid ,COLOR_ORANGE"You are to for from anybody");
}
 return 
1;

Reply
#4

i made this shorter and im sure this will work
pawn Код:
CMD:w(playerid,params[])
{
                new Nam[MAX_PLAYER_NAME],Float:X,Float:Y,Float:Z,message[128],str[128];
        if(sscanf(params,"s[128",message)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [text]");
        GetPlayerName(playerid,Nam,sizeof(Nam));
        GetPlayerPos(playerid,X,Y,Z);
        format(str,sizeof(str),"%s Whispers: %s",Nam, message);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                if(IsPlayerInRangeOfPoint(i, 5.0, X,Y,Z))
                {
                    SendClientMessage(i,COLOR_ORANGE,str);
                     SetPlayerChatBubble(playerid,str, COLOR_ORANGE, 10.0, 10000);
                }
        }
        return 1;
}
rep me please
Reply
#5

I've tried like that, didn't work, well something similar.
Reply
#6

the command doesnt work? or its saying to everyone??
Reply
#7

As I do not have your color codes, I cannot compile; but other than that, every thing seems to be in working order. Oh, and I made your command faster by destroying the need for a whole different function..

pawn Код:
CMD:whisper(playerid, params[])
{
    new
        TextSent[128],
        Float:P[3],
        p_Name[MAX_PLAYER_NAME]
    ;
   
    if(sscanf(params, "s[128]", TextSent)) //Did they type the correct syntax? If not, this is called.
        return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [message]");
       
    //Correct syntax below.
   
    GetPlayerPos(playerid, P[0], P[1], P[2]);
    GetPlayerName(playerid, p_Name, 24);
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 10, P[0], P[1], P[2]))
        {
            new
                whisstring[128]
            ;
           
            SetPlayerChatBubble(playerid, params, COLOR_ORANGE, 10.0, 10000);
           
            format(whisstring, sizeof(whisstring), "%s whispered: %s", p_Name, TextSent);
            SendClientMessage(i, COLOR_ORANGE, whisstring);
            return 1;
        }
        else return SendClientMessage(playerid, COLOR_SILVER, "You are to far from that person.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)