KICK/BAN COMMANDS
#1

Hello Guys i Need Kick And Ban Commands Someone can help me cuz i scripted it with full bugs
Reply
#2

since you didn't passed enough informations to us, also we can't give you 100% optimized /ban and /kick cmds.

for this command you'll need y_commands and sscanf2 includes

pawn Код:
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;
}
Reply
#3

Just download ZCMD and sscanf2 if you do not already have them.


pawn Код:
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;
}
Reply
#4

Include Needed:
[Include] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009)
SolidFiles for ZCMD 0.3.1

Include:
pawn Код:
#include <zcmd>
Define:
pawn Код:
#define COLOR_RED 0xFF0000FF
Forward and Public Callback:
pawn Код:
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;
}
Ban:
pawn Код:
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;
}
Kick:
pawn Код:
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;
}
Just Change "if(!IsPlayerAdmin(playerid))" into your VIP or Administrator Level Function for Example "if(PlayerInfo[playerid][AdminLevel] >= 2)",

if(PlayerInfo[playerid][AdminLevel] >= 2) = Is my Administrator Level Function.

ZCMD:
[Include] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009)

Check your "PAWNO > includes" Directory, and Look for "zcmd.inc",

If you don't have "zcmd.inc",

(NOTE: Make sure you open the same PAWNO that contains all your stuff)

Download it here,

[Include] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009)
SolidFiles for ZCMD 0.3.1

Installation:
  1. Copy the whole include codes in Notepad, Wordpad, etc..
  2. Save it as "include's name.inc", and Save it in "PAWNO > include".
  3. Open your Gamemode Script using PAWNO Compiler.
  4. Add "#include <include's name>" at the Top of your Gamemode Script.
  5. Compile it, Save it, and Finish.
and/or
  1. Download the Include File, Copy it.
  2. Paste it in "PAWNO > include".
  3. Open your Gamemode Script using PAWNO Compiler.
  4. Add "#include <include's name>" at the Top of your Gamemode Script.
  5. Compile it, Save it, and Finish.
Reply
#5

hey thanks guys <3 <3
Reply
#6

There are a lot of tutorials regarding this question.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)