1 space misses a letter - 2 spaces it's fine :S
#1

OK in my server say I do /akill Ryan Bugged.
It will come up **Admin Kill**Ryan(0)ugged.

If I do /akill Ryan Bugged. ((Notice the 2 spaces))
It will come up **Admin Kill**Ryan(0)Bugged.

Any ideas on how to resolve it so I only have to do one space?

Код:
if(strcmp(cmd, "/akill", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Admin Kill A Player
	{
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id)");
  return 1;
  }
  giveplayerid = strval(tmp);
  
  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id) ID Must be a number");
  return 1;
  }
  new output[255];
  AdminKilled[giveplayerid] =1;
  strmid(output,cmdtext,10,strlen(cmdtext));
  if (IsPlayerConnected(giveplayerid)) {
  GetPlayerName(giveplayerid, string, 24);
  format(string, 100, "**(ADMIN KILL)** %s(%d) %s", string,giveplayerid,output);
  printf("%s", string);
  SendClientMessageToAll(0xFF7F50AA, string);
  SetPlayerHealth(giveplayerid,0);
  }
  else {
  format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  }
  return 1;
  }
Edit: This happens with all admin commands involving reason.
Reply
#2

*BUMP*
Anyone?
Reply
#3

first of all, lower the cell amount on output to 128. Second of all use bigstrtok.

pawn Код:
stock bigstrtok(const string[], &idx)
{
    new length = strlen(string);
    while ((idx < length) && (string[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = string[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    return result;
}
Try this:

pawn Код:
if(strcmp(cmd, "/akill", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Admin Kill A Player
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id)");
        return 1;
        }
    giveplayerid = strval(tmp);

    if(!IsNumeric(tmp))
        {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id) ID Must be a number");
        return 1;
    }
    new output[128];
    AdminKilled[giveplayerid] =1;
    output = bigstrtok(cmdtext, idx);
    if (IsPlayerConnected(giveplayerid))
        {
        GetPlayerName(giveplayerid, string, 24);
        format(string, 100, "**(ADMIN KILL)** %s(%d) %s", string,giveplayerid,output);
        printf("%s", string);
        SendClientMessageToAll(0xFF7F50AA, string);
        SetPlayerHealth(giveplayerid,0);
    }
    else
        {
            format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
            SendClientMessage(playerid, COLOR_ERROR, string);
    }
    return 1;
  }
- Awaran
Reply
#4

Thanks, I will post you on the results.
Reply
#5

u see that 24 u have to lower that i had same problem
Reply
#6

Quote:
Originally Posted by @Drake@
u see that 24 u have to lower that i had same problem
To..
Reply
#7

Bump. Anyone know?
Reply
#8

pawn Код:
if(strcmp(cmd, "/akill", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Admin Kill A Player
{
  tmp = strtok(cmdtext, idx);

  if(!strlen(tmp))
  {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id)");
    return 1;
  }
  giveplayerid = strval(tmp);
 
  if(!IsNumeric(tmp))
  {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id) ID Must be a number");
    return 1;
  }

  new output[255];
  AdminKilled[giveplayerid] =1;
  strmid(output,cmdtext,9,strlen(cmdtext));

  if (IsPlayerConnected(giveplayerid))
  {
    GetPlayerName(giveplayerid, string, 24);
    format(string, 100, "**(ADMIN KILL)** %s(%d) %s", string,giveplayerid,output);
    printf("%s", string);
    SendClientMessageToAll(0xFF7F50AA, string);
    SetPlayerHealth(giveplayerid,0);
  }
  else
  {
    format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
  }
  return 1;
}
Try that, i just changed the 10 in strmid to 9 to pick up the message one charicter earlier

Untested
Reply
#9

Quote:
Originally Posted by WrathOfGenesis
pawn Код:
if(strcmp(cmd, "/akill", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Admin Kill A Player
{
  tmp = strtok(cmdtext, idx);

  if(!strlen(tmp))
  {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id)");
    return 1;
  }
  giveplayerid = strval(tmp);
 
  if(!IsNumeric(tmp))
  {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /akill (id) ID Must be a number");
    return 1;
  }

  new output[255];
  AdminKilled[giveplayerid] =1;
  strmid(output,cmdtext,9,strlen(cmdtext));

  if (IsPlayerConnected(giveplayerid))
  {
    GetPlayerName(giveplayerid, string, 24);
    format(string, 100, "**(ADMIN KILL)** %s(%d) %s", string,giveplayerid,output);
    printf("%s", string);
    SendClientMessageToAll(0xFF7F50AA, string);
    SetPlayerHealth(giveplayerid,0);
  }
  else
  {
    format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
  }
  return 1;
}
Try that, i just changed the 10 in strmid to 9 to pick up the message one charicter earlier

Untested
yea that works if not the it has to be 11
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)