SA-MP Forums Archive
dcmd_kick help - reason not showing - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dcmd_kick help - reason not showing (/showthread.php?tid=97011)



dcmd_kick help - reason not showing - Striker_Moe - 12.09.2009

Код:
dcmd_kick(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  new tmp[256], idx;
  new reason[128];
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /kick (playerid) (reason) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Kicks the player from the server ||");
   return true;
  }
  new pid = strval(tmp);
  if(!IsPlayerConnected(pid))
  {
   SendClientMessage(playerid,COLOR_GREY,"Incorrect ID.");
   return true;
  }
  tmp = strrest(params,idx);
  new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(pid, pname, sizeof(pname));
  GetPlayerName(playerid, pname2, sizeof(pname2));
  tmp = strrest(params, idx);
  format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: % ||", pname2, pname, reason, tmp);
  SendClientMessageToAll(COLOR_RED, string);
  Kick(pid);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "You are not logged into RCON.");
}
Whats wrong here? The reason is not showing up.


Re: dcmd_kick help - reason not showing - [nl]daplayer - 12.09.2009

why are you using dcmd and strok?

dcmd is build to not use strtok xD.

Use sscanf : https://sampwiki.blast.hk/wiki/Fast_Commands

sscanf + dcmd = easyer and faster.


Re: dcmd_kick help - reason not showing - Striker_Moe - 12.09.2009

Lol, crap, Im pretty new to this whole scripting thingy. What needs to be changed then?


Re: dcmd_kick help - reason not showing - CJ101 - 12.09.2009


Код:
dcmd_kick(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  new tmp[256], idx;
  new reason[128];
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /kick (playerid) (reason) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Kicks the player from the server ||");
   return true;
  }
  new pid = strval(tmp);
  if(!IsPlayerConnected(pid))
  {
   SendClientMessage(playerid,COLOR_GREY,"Incorrect ID.");
   return true;
  }
  tmp = strrest(params,idx);
  new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(pid, pname, sizeof(pname));
  GetPlayerName(playerid, pname2, sizeof(pname2));
  tmp = strrest(params, idx);
  format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: %s ||", pname2, pname, reason, tmp);
  SendClientMessageToAll(COLOR_RED, string);
  Kick(pid);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "You are not logged into RCON.");
}
use this new code.


Re: dcmd_kick help - reason not showing - Striker_Moe - 12.09.2009

Will the reason show up? I dont think so


Re: dcmd_kick help - reason not showing - Karlip - 12.09.2009

The reason part was missing an s after %.

Also,

format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: %s ||", pname2, pname, reason, tmp);

?(See the bold and underlined)


Re: dcmd_kick help - reason not showing - Striker_Moe - 12.09.2009

Reason still not showing up. Actual command:

Код:
dcmd_kick(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  new tmp[256], idx;
  new reason[128];
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /kick (playerid) (reason) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Kicks the player from the server ||");
   return true;
  }
  new pid = strval(tmp);
  if(!IsPlayerConnected(pid))
  {
   SendClientMessage(playerid,COLOR_GREY,"[!] Incorrect ID.");
   return true;
  }
  tmp = strrest(params,idx);
  new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(pid, pname, sizeof(pname));
  GetPlayerName(playerid, pname2, sizeof(pname2));
  tmp = strrest(params, idx);
  format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: %s ||", pname2, pname, reason);
  SendClientMessageToAll(COLOR_RED, string);
  Kick(pid);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "[!] You are not logged into RCON.");
}



Re: dcmd_kick help - reason not showing - CJ101 - 12.09.2009

Quote:
Originally Posted by ! Karlip
The reason part was missing an s after %.

Also,

format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: %s ||", pname2, pname, reason, tmp);

?(See the bold and underlined)
^^ read that


Re: dcmd_kick help - reason not showing - Striker_Moe - 12.09.2009

I still dont get it. -.-


Re: dcmd_kick help - reason not showing - MadeMan - 12.09.2009

pawn Код:
dcmd_kick(playerid,params[])
{
  if(IsPlayerAdmin(playerid))
  {
  new tmp[256], idx;
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
   SendClientMessage(playerid,COLOR_GREY,"|| Usage: /kick (playerid) (reason) ||");
   SendClientMessage(playerid,COLOR_GREY,"|| Function: Kicks the player from the server ||");
   return true;
  }
  new pid = strval(tmp);
  if(!IsPlayerConnected(pid))
  {
   SendClientMessage(playerid,COLOR_GREY,"[!] Incorrect ID.");
   return true;
  }
  tmp = strrest(params,idx);
  new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[256];
  GetPlayerName(pid, pname, sizeof(pname));
  GetPlayerName(playerid, pname2, sizeof(pname2));
  format(string, sizeof(string), "|| Administrator %s kicked %s. Reason: %s ||", pname2, pname, tmp);
  SendClientMessageToAll(COLOR_RED, string);
  Kick(pid);
  return true;
  }
  else return SendClientMessage(playerid, COLOR_RED, "[!] You are not logged into RCON.");
}