/say Problem
#1

Код:
dcmd_say(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  new tmp[256], idx;
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /say (text) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Announces a adminґs text global. ||");
   return true;
  }
  tmp = strrest(params,idx);
  new pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(playerid, pname2, sizeof(pname2));
  format(string, sizeof(string), "|| Administrator %s: %s ||", pname2, tmp);
  SendClientMessageToAll(COLOR_ORANGE, string);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "[!] You are not logged into RCON.");
}
This is my command, but the text doesnt want to show up. Whats wrong?
Reply
#2

Why are you using strtok inside dcmd ? dcmd was made for you to not use slow and unefficient strtok

pawn Код:
dcmd_say(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  if(!strlen(params))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /say (text) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Announces a adminґs text global. ||");
   return true;
  }
  new pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(playerid, pname2, sizeof(pname2));
  format(string, sizeof(string), "|| Administrator %s: %s ||", pname2, params);
  SendClientMessageToAll(COLOR_ORANGE, string);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "[!] You are not logged into RCON.");
}
Reply
#3

The text still doesnt want to show up..
Reply
#4

Anyone know why?
Reply
#5

You'll need sscanf, and you don't need 256 cells, use 128.

pawn Код:
dcmd_say(playerid, params[])
{
    new message[128], string[128], name[MAX_PLAYER_NAME];
    if (sscanf(params, "s", message)) SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /say [message]");
    else
    {
      if(IsPlayerAdmin(playerid))
      {
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "RCON Admin %s: %s.", name, message); // You will probably want to re-format this.
        SendClientMessageToAll(COLOR_ORANGE, string);
      }
      else
      {
        SendClientMessage(playerid, COLOR_ORANGE, "You're not an RCON administrator.");
      }
      return 1;
    }
}
Reply
#6

C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\ad. rcon admin system\advancedrconadmin.pwn(210) : error 017: undefined symbol "sscanf"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\ad. rcon admin system\advancedrconadmin.pwn(225) : warning 209: function "dcmd_say" should return a value

Huh`?
Reply
#7

I removed the error, how can I remove the warning?
Reply
#8

This will work . I put the return in the wrong part, anyway, so you have sscanf now? Good, it's much easier to use it and more efficient.

pawn Код:
dcmd_say(playerid, params[])
{
    new message[128], string[128], name[MAX_PLAYER_NAME];
    if (sscanf(params, "s", message)) SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /say [message]");
    else
    {
      if(IsPlayerAdmin(playerid))
      {
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "RCON Admin %s: %s.", name, message); // You will probably want to re-format this.
        SendClientMessageToAll(COLOR_ORANGE, string);
      }
      else
      {
        SendClientMessage(playerid, COLOR_ORANGE, "You're not an RCON administrator.");
      }
    }
    return 1;
}
Reply
#9

Thank you very much Finally my first script is finished! Thanks again
Reply
#10

Quote:
Originally Posted by Mo3
Thank you very much Finally my first script is finished! Thanks again
No problem, have fun scripting. I highly suggest you review SSCANF (https://sampwiki.blast.hk/wiki/Dcmd) as it's a much more efficient way of scripting, also easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)