COMMAND:kick(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
if(PlayerInfo[playerid][pAdminlevel] >= 1) // player level more (>) 0
{
new otherplayerid, reason[128];
if(sscanf(params, "uz", otherplayerid, reason)) // split input string and check level value 0 to 5
SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
else if(otherplayerid == INVALID_PLAYER_ID) // Check player connected
SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
else
{
new string[32];
format(string, sizeof(string), "Admin %s kicked %s | Reason: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(otherplayerid), reason);
SendClientMessageToAll(0xFFFFFFFF,string);
Kick(otherplayerid);
}
}
else
{
SendClientMessage(playerid, 0xAAAAAAAA, "You are not admin or the required level.");
}
return 1;
}
if(sscanf(params, "uz", otherplayerid, reason))
What happened to "z", the optional string? z has been removed (you can still use it but will get a server warning) to make way for the new optional parameter system described later on. |
COMMAND:kick( playerid, params[ ] )
{
if( PlayerInfo[ playerid ][ pAdminLevel ] == 0 ) return SendClientMessage( playerid, 0xAAAAAAAA, "You are not admin or the required level." );
new
ID,
Reason[ 101 ]
;
if( sscanf( params, "us[101]", ID, Reason ) ) return SendClientMessage( playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]" );
if( ID == INVALID_PLAYER_ID || ID == playerid ) return SendClientMessage( playerid, 0xFFFFFFFF, "This player is not connected" );
if( strlen( Reason ) > 100 ) return SendClientMessage( playerid, 0xFFFFFFFF, "Reason is too long.. [Max chars - 100]" );
new
String[ 188 ]
;
format( String, 188, "Admin %s kicked kicked %s. | Reason: %s", GetPlayerNameEx( playerid ), GetPlayerNameEx( ID ), Reason );
SendClientMessageToAll( 0xFFFFFFFF, String );
Kick( ID );
return true;
}
[12:38:23] Admin Otto Kling kicked Otto Kl [12:38:23] Server closed the connection.
if( ID == INVALID_PLAYER_ID || ID == playerid )
COMMAND:kick(playerid, params[])
{
new pid;
if(PlayerInfo[playerid][pAdminlevel] >= 1)
{
if(sscanf(params, "us[128]", pid, params[2])) return SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
GetPlayerName(pid, paramname, sizeof(paramname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, params[2]);
SendClientMessageToAll(AdminColor, string);
Kick(pid);
} else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, 0xAAAAAAAA, "You are not admin or the required level.");
return 1;
}
COMMAND:kick(playerid, params[])
{
new pid, reason[105];
if(PlayerInfo[playerid][pAdminlevel] >= 1) return SendClientMessage(playerid, 0xAAAAAAAA, "You are not admin or the required level.");
if(sscanf(params, "uS(No Reason Given)[128]", pid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
if(IsPlayerConnected(pid) && pid != INVALID_PLAYER_ID && pid != playerid)
{
new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
GetPlayerName(pid, paramname, sizeof(paramname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, reason);
SendClientMessageToAll(AdminColor, string);
Kick(pid);
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected Or Is Yourself.");
return 1;
}