02.11.2013, 15:47
Hello Guys i Need Kick And Ban Commands Someone can help me cuz i scripted it with full bugs
YCMD:kick(playerid, params[], help)
{
#pragma unused help
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Admins only");
new player,reason[128];
if(sscanf(params, "us", player, reason)) return SendClientMessage(playerid, -1, "Usage: /kick [id] [reason]");
new playername[24], adminname[24], string[122+6];
GetPlayerName(player, playername, 24);
GetPlayerName(playerid, adminname, 24);
format(string, 128, "Admin %s has kicked %s, reason: %s", adminname, playername, reason);
SendClientMessageToAll(-1, string);
format(string, 128, "You have been kicked by Admin %s, reason: %s", adminname, reason);
SendClientMessage(player, -1, string);
Kick(player);
return true;
}
CMD:kick(playerid, params[])
{
new targetid, targetname[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME],reason[20], str[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "SERVER: You're not admin!");
if(targetid == playerid) return SendClientMessage(playerid, -1, "SERVER:You can't kick yourself!");
if(sscanf(params, "us[20]",targetid, reason)) return SendClientMessage(playerid, -1, "SERVER:/kick [ID][Reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "SERVER:This player is not connected!");
{
GetPlayerName(playerid, pName,sizeof(pName));
GetPlayerName(targetid, targetname, sizeof(targetname));
format(str, 128, "[SYSTEM] | %s had been kicked by %s for: %s", targetname, pName, reason);
SendClientMessageToAll(-1, str);
format(str, 128, "[SYSTEM] | You have been kicked by %s for %s", pName, reason);
SendClientMessage(targetid, -1, str);
DelayedKick(targetid);
}
return 1;
}
#include <zcmd>
#define COLOR_RED 0xFF0000FF
forward SaveIn(filename[],text[]);
public SaveIn(filename[],text[])
{
new File:Lfile;
new filepath[256];
new string[256];
new year,month,day;
new hour,minute,second;
getdate(year,month,day);
gettime(hour,minute,second);
format(filepath,sizeof(filepath),"1337SAMProductionsADMSys/Logs/%s.txt",filename);
Lfile = fopen(filepath,io_append);
format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
fwrite(Lfile,string);
fclose(Lfile);
return 1;
}
CMD:ban(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You must be an RCON Admin to use this Command.");
{
new targetid, tname[MAX_PLAYER_NAME], reason[128];
new name[MAX_PLAYER_NAME], string[128];
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can't Ban yourself !");
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid] [reason]");
if(targetid != INVALID_PLAYER_ID)
{
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, tname, sizeof(tname));
format(string, sizeof(string), "{EEEEEE}[Player: {FF0000}%s {EEEEEE}(ID: {FF0000}%d{EEEEEE})] has been banned in the server (Reason: {FF0000}%s{EEEEEE})", tname, targetid, reason);
SendClientMessageToAll(-1, string);
SaveIn("BanLog",string);
Ban(targetid);
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid PlayerID");
}
return 1;
}
CMD:kick(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You must be an RCON Admin to use this Command.");
{
new targetid, tname[MAX_PLAYER_NAME], reason[128];
new name[MAX_PLAYER_NAME], string[128];
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can't Kick yourself !");
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick [playerid] [reason]");
if(targetid != INVALID_PLAYER_ID)
{
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, tname, sizeof(tname));
format(string, sizeof(string), "{EEEEEE}[Player: {FF0000}%s {EEEEEE}(ID: {FF0000}%d{EEEEEE})] has been kicked in the server (Reason: {FF0000}%s{EEEEEE})", tname, targetid, reason);
SendClientMessageToAll(-1, string);
SaveIn("KickLog",string);
Kick(targetid);
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid PlayerID");
}
return 1;
}