SA-MP Forums Archive
/kick Command error - 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)
+--- Thread: /kick Command error (/showthread.php?tid=602624)



/kick Command error - hariyanuar - 10.03.2016

Hello, i am newbie scripter. I got this /kick error when kicking other player, and that player is not kicked but the AdmCmd is showing. Can someone help me pls the error is /kick command and /skick command.

This is the /kick code

Код:
    if(strcmp(cmd, "/kick", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerNPC(giveplayerid)) return 1;
			if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 4)
			{
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
					    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[96];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason]");
							return 1;
						}
						new logstring[256];
						new year, month, day;
						getdate(year, month, day);
						if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
						{
						    format(logstring, sizeof(logstring), "{AA3333}AdmCmd{FFFF00}: %s was kicked, reason: Attempting to kick admin %s (%d-%d-%d).", sendername, giveplayer,month,day,year);
						    KickLog(logstring);
						    format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was kicked, reason: Attempting to kick a higher admin.", sendername);
							SendClientMessageToAll(COLOR_LIGHTRED, string);
							SetTimerEx("GettingKicked", 2000, false, "i", giveplayer);
							return 1;
						}
						format(logstring, sizeof(logstring), "{AA3333}AdmCmd{FFFF00}: %s was kicked by %s, reason: %s (%d-%d-%d).", giveplayer, sendername, (result),month,day,year);
						KickLog(logstring);
						format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was kicked by %s, reason: %s", giveplayer, sendername, (result));
						SendClientMessageToAll(COLOR_LIGHTRED, string);
						SetTimerEx("GettingKicked", 2000, false, "i", giveplayer);
						return 1;
					}
				}
				else
				{
					format(string, sizeof(string), "   %d is not an active player !", giveplayerid);
					SendClientMessage(playerid, COLOR_GRAD1, string);
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}
And this is the /skick code

Код:
	if(strcmp(cmd, "/skick", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /skick [playerid/PartOfName]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
			if(PlayerInfo[playerid][pAdmin] >= 2)
			{
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
				        GetPlayerName(playerid, sendername, sizeof(sendername));
				        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				        if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
						{
						    format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was skicked, reason: Attempting to silent kick a higher admin.", sendername);
							ABroadCast(COLOR_LIGHTRED, string, 1);
							SetTimerEx("GettingKicked", 2000, false, "i", sendername);
							return 1;
						}
						format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was skicked by %s", giveplayer, sendername);
						ABroadCast(COLOR_LIGHTRED, string, 1);
				        SetTimerEx("GettingKicked", 2000, false, "i", giveplayer);
				    }
				}
				else
				{
					format(string, sizeof(string), "   %d is not an active player !", giveplayerid);
					SendClientMessage(playerid, COLOR_GRAD1, string);
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}
That's all thanks.


Re: /kick Command error - MicroKyrr - 10.03.2016

First of all , i recommended you to use ZCMD
Second , use sscanf because it's very fast

PHP код:
#include <samp>
#include <zcmd>
CMD:kick(playeridparams[])
{
  if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pHelper] >= 4
  {
      new 
PID//define the playerid we wanna kick
      
new reason[64]; //the reason, put into a string
      
new str[128]; //a new message string
      
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
      
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
      
GetPlayerName(PIDPlayernamesizeof(Playername));
      if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
      
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
      
format(strsizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
      
SendClientMessageToAll(COLOR_REDstr); //send that message to all
      
Kick(PID); //kick the playerid we've defined
  
}
  else 
//if he has not got the permissions
  
{
      
SendClientMessage(playeridLIGHT_RED"[Security] You dont have a permission to use this command!"); //return this message
   
}
   return 
1;




Re: /kick Command error - hariyanuar - 10.03.2016

Its "sscanf" or "sscanf2" to use?


Re: /kick Command error - MicroKyrr - 10.03.2016

sscanf2