Whisper problem -
Bogdan1992 - 16.01.2012
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 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]");
for( i = 0; i < MAX_PLAYERS; i++){
GetPlayerPos(i, x, y, z);
if(!(IsPlayerInRangeOfPoint(playerid, 10, x, y, z))) return SendClientMessage(playerid, COLOR_SILVER,"You are to far from that person.");
}
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;
}
Re: Whisper problem -
rinori - 16.01.2012
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;
}
Re: Whisper problem -
Bogdan1992 - 16.01.2012
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(playerid, params[])
{
new Float:x, Float:y, Float:z, Float: x1, Float: y1, Float: z1, Float: dist, i, ok = 0;
if(sscanf(params,"u",mystring)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: {FFFFFF}/w [message]");
GetPlayerPos(playerid, x, y, z);
for( i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerPos(i, x1, y1, z1);
dist = floatsqroot((x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1));
if(dist <= 10.0)
{
GetPlayerName(playerid, pname, sizeof(pname));
format(mystring, sizeof(mystring),"%s whispred: %s", pname, params);
SetPlayerChatBubble(playerid, params, COLOR_ORANGE, 10.0, 10000);
SendClientMessage(i ,COLOR_ORANGE, mystring);
if(i != playerid)
{
ok = 1;
}
}
}
if(ok == 0)
{
SendClientMessage(playerid ,COLOR_ORANGE, "You are to for from anybody");
}
return 1;
}
Re: Whisper problem -
Tanush123 - 16.01.2012
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
Re: Whisper problem -
Bogdan1992 - 16.01.2012
I've tried like that, didn't work, well something similar.
Re: Whisper problem -
Tanush123 - 17.01.2012
the command doesnt work? or its saying to everyone??
Re: Whisper problem -
2KY - 17.01.2012
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;
}