"/me" bugged
#1

Hello!
This is my /me.

pawn Код:
if(strcmp(cmdtext, "/me", true) == 0)
    {
        new string[256], sendername[MAX_PLAYER_NAME];
        new idx;
      if(IsPlayerConnected(playerid))
      {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /me [action]");
                return 1;
            }
                format(string, sizeof(string), "* %s %s", sendername, result);
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            printf("%s", string);
            return 1;
    }
For some reasons, it is bugged and dont work.

if I type "/me"
It returns:
*** Christian_Hammer /me ***

if I type i.e "/me takes out a gun from his bag"
It returns nothing.

Help!
What is wrong?
Reply
#2

Why not just use:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
  {
    if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    SendClientMessageToAll(0xFFFF00AA, str);
    return 1;
  }
  return 0;
}
from https://sampwiki.blast.hk/wiki/Using_strcmp%28%29??
Reply
#3

Quote:
Originally Posted by Naxix
Why not just use:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
  {
    if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    SendClientMessageToAll(0xFFFF00AA, str);
    return 1;
  }
  return 0;
}
from https://sampwiki.blast.hk/wiki/Using_strcmp%28%29??
Ok, but why is it strcmp packed?
pawn Код:
!strcmp
Reply
#4

Hmm.. I'm not sure, but it should work :b
Reply
#5

It will not send the message to players in the distance you want.
Reply
#6

Quote:
Originally Posted by Naxix
Why not just use:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
  {
    if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    SendClientMessageToAll(0xFFFF00AA, str);
    return 1;
  }
  return 0;
}
from https://sampwiki.blast.hk/wiki/Using_strcmp%28%29??
Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)