Need help with this!!!
#1

I made a whisper command by myself ,there are no compiling errors though,there is a problem.

pawn Код:
new countn3;
new counttimer3;
new PlayerText3D:BC;

COMMAND:bc(playerid,params[])
{
   new str[128],str2[128];
   new whisperer[MAX_PLAYER_NAME];
   new Float:x,Float:y,Float:z;
   if(sscanf(params,"u",str2)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/bc [Text]");
   GetPlayerPos(playerid,x,y,z);
   GetPlayerName(playerid,whisperer,sizeof(whisperer));
   format(str,sizeof(str),"(WHISPER FROM)%s(%d):%s",whisperer,playerid,str2);
   BC = CreatePlayer3DTextLabel(playerid,str2,COLOR_YELLOW,x,y,z+0.1,5.0,playerid,INVALID_VEHICLE_ID,0);
   countn3 = 40;
   counttimer3 = SetTimer("WhisperCountDown",1000,true);
   if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) return SendClientMessageToAll(COLOR_YELLOW,str);
   return true;
}
public WhisperCountDown(playerid)
{
  countn3--;
  if(countn3 <= -1)
  {
    KillTimer(counttimer3);
    DeletePlayer3DTextLabel(playerid,BC);
  }
  return 1;
}
Ok,so here's problem,in main chat I can't see only this (WHISPER FROM) NAME(ID):y; name is displayed but as second string I see the letter y with 2 points above it.And I can't see my message above the head,but I think that's OK,because on other server was same(I mean I couldn't see my message only on main chat.but other players could see it on mainchat and above my head also).Can some1 help?(Don't tell me just to paste a whisper command I like doing things by myself).
Reply
#2

This might help you a bit:
SetPlayerChatBubble

And you should use SetTimerEx. But incase of chat bubble, it already has a time limit of itself.
Reply
#3

OK,thanks it really helped but what's wrong now lol 1 warning xD

pawn Код:
new BC;

COMMAND:bc(playerid,params[])
{
   new str[128],str2[128];
   new whisperer[MAX_PLAYER_NAME];
   new Float:x,Float:y,Float:z;
   if(sscanf(params,"u",str2)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/bc [Text]");
   GetPlayerPos(playerid,x,y,z);
   GetPlayerName(playerid,whisperer,sizeof(whisperer));
   format(str,sizeof(str),"WHISPER FROM %s(%d):%s",whisperer,playerid,str2);
   BC = SetPlayerChatBubble(playerid,str2,COLOR_YELLOW,15.0,5000);
   for (new i = 0;i<MAX_PLAYERS;i++)
   {
      if(IsPlayerInRangeOfPoint(i,5.0,x,y,z)) return SendClientMessage(i,COLOR_YELLOW,str);
   }
   return true;
}
Reply
#4

No need to make a new variable for the chat bubble.

Just Let it be SetPlayerChatBubble(....
without the BC = SetPlayerChatBubble(....
Reply
#5

Thanks very much,I guess it works,but still the text displayed in main chat is "y",and not the message that should be displayed(str2)
Reply
#6

I'll make a corrected thing.. EDITING when its done.
pawn Код:
COMMAND:bc(playerid,params[])
{
   new str[128], str2[100];
   new whisperer[MAX_PLAYER_NAME];
   new Float:x,Float:y,Float:z;
   if(sscanf(params,"s[100]",str2)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/bc [Text]");
   GetPlayerPos(playerid,x,y,z);
   GetPlayerName(playerid,whisperer,sizeof(whisperer));
   format(str,sizeof(str),"WHISPER FROM %s(%d):%s",whisperer,playerid,str2);
   SetPlayerChatBubble(playerid,str2,COLOR_YELLOW,15.0,5000);
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if(IsPlayerInRangeOfPoint(i,5.0,x,y,z)) SendClientMessage(i,COLOR_YELLOW,str);
   }
   return true;
}
Let's see what things have been corrected:
- Use "s[LENTGH]" when you format a string with sscanf. You used "u" which is for a USER.
- On Loop, you added return after the range check.. I removed it and it seems to work. IDK why lol.

EDITED.
Reply
#7

thanks in advance,altoguh I don't see what's wrong in my code
Reply
#8

Here's new version:

pawn Код:
COMMAND:bc(playerid,params[])
{
   new str[128],str2[128];
   new whisperer[MAX_PLAYER_NAME];
   new Float:x,Float:y,Float:z;
   if(sscanf(params,"u",str2)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/bc [Text]");
   GetPlayerPos(playerid,x,y,z);
   GetPlayerName(playerid,whisperer,sizeof(whisperer));
   format(str,sizeof(str),"(WHISPER FROM) %s(%d):%s",whisperer,playerid,str2);
   SetPlayerChatBubble(playerid,str2,COLOR_YELLOW,15.0,5000);
   for (new i = 0;i<MAX_PLAYERS;i++)
   {
      if(IsPlayerInRangeOfPoint(i,5.0,x,y,z)) return printf("%s",str);
   }
   return true;
}
In-game is not working,but I'd like help with that pls,as I said made by myself,or if you already almost made it,then thx but I will sue it as example
Reply
#9

You're right thanks forget 2nd version thanks very much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)