How to script ban and kick command?
#1

Guys? I don't know how to script a ban and a kick command, with dcmd, can someone give me an example?
I need it for my server, it has an admin system in the gamemode script, but there is no ban or kick, the prefix for admin is
pawn Код:
if(IsPlayerAdmin3(playerid))
.

This is an example of an admin command in my server.
pawn Код:
dcmd_makeadmin(playerid, params[])
{
    new tmp[256], tmp2[256], idx;
    tmp = strtok(params, idx);      // get player id parameter
    new id;
    tmp2 = strtok(params, idx);     // get admin level parameter
    new status = strval(tmp2);      // admin level to be set

    if(!IsNumeric(tmp))
        id = ReturnPlayerID(tmp);
    else
        id = strval(tmp);

    if(!IsPlayerRootAdmin(playerid)) SendClientMessageEx(playerid, COLOR_GREY, "Error: You need to be root admin to do that!"); // no access
    else if(!strlen(tmp) || !IsNumeric(tmp2) || !strlen(tmp2) || strval(tmp2) > 2 || strval(tmp2) < 0)
    {   // did not use command properly
        SendClientMessageEx(playerid, COLOR_GREY, "Usage: /makeadmin [player id/name] [admin level]");
        SendClientMessageEx(playerid, COLOR_GREEN, "Help - Levels: 0: Regular Player | 1: Administrator | 2: Root Admin");
    }
    else if(!IsPlayerConnected(id))
        return SendClientMessageEx(playerid, COLOR_GREY, "Error: Player not found."); // player doesnt exist
    else if(!Player[id][loggedin])
        return SendClientMessageEx(playerid, COLOR_GREY, "Error: Player not logged in."); // player not logged in
    else
    {
        new pfile[200];
        format(pfile, sizeof(pfile), "combinations/players/%s.ini", nick_encode(PlayerName(id))); // path to target players save file
        new pstatus[200];
        switch(status)
        {
            case 0: // Regular Player (Demotion)
            {
                format(pstatus, sizeof(pstatus), "** Admin %s has changed your account level to 0 (Regular Player)", PlayerName(playerid),GetPlayerLevelName(id));
                SendClientMessageEx(id, COLOR_GREEN, pstatus);
                #if DATA_SYSTEM == 1
                    dini_IntSet(pfile, "AdminLevel", 0);
                #elseif DATA_SYSTEM == 2
                    UpdateSqlUserDataInt(id, "AdminLevel", 0);
                #endif
                Player[id][pLevel] = 0;
                format(pstatus, sizeof(pstatus),"** Changed %s account level to 0 (%s)", PlayerName(id), GetPlayerLevelName(id));
                SendClientMessageEx(playerid, COLOR_GREEN, pstatus);
            }
            case 1: // Regular admin
            {
                #if DATA_SYSTEM == 1
                    dini_IntSet(pfile, "AdminLevel", 1);
                #elseif DATA_SYSTEM == 2
                    UpdateSqlUserDataInt(id, "AdminLevel", 1);
                #endif
                Player[id][pLevel] = 1;
                format(pstatus, sizeof(pstatus), "** Admin %s has changed your account level to 1 (%s)", PlayerName(playerid), GetPlayerLevelName(id));
                SendClientMessageEx(id, COLOR_GREEN, pstatus);
                format(pstatus, sizeof(pstatus),"** Changed %s account level to 1 (%s)", PlayerName(id), GetPlayerLevelName(id));
                SendClientMessageEx(playerid, COLOR_GREEN, pstatus);
                CallRemoteFunction("DC_MakeAdmin", "i", id);
            }
            case 2: // Root Admin
            {
                #if DATA_SYSTEM == 1
                    dini_IntSet(pfile, "AdminLevel", 2);
                #elseif DATA_SYSTEM == 2
                    UpdateSqlUserDataInt(id, "AdminLevel", 2);
                #endif
                Player[id][pLevel] = 2;
                format(pstatus, sizeof(pstatus),"** Admin %s has changed your account level to 2 (%s)", PlayerName(playerid), GetPlayerLevelName(id));
                SendClientMessageEx(id, COLOR_GREEN, pstatus);
                format(pstatus, sizeof(pstatus),"** Changed %s account level to 2 (%s)", PlayerName(id), GetPlayerLevelName(id));
                SendClientMessageEx(playerid, COLOR_GREEN, pstatus);
                CallRemoteFunction("DC_MakeAdmin", "i", id);
            }
        }

    }
    return 1;
}
I didn't make the script
Reply


Messages In This Thread
How to script ban and kick command? - by Hitman-97- - 18.05.2011, 07:19
Re: How to script ban and kick command? - by BloodMaster - 18.05.2011, 08:03
Re: How to script ban and kick command? - by Hitman-97- - 18.05.2011, 10:06
Re: How to script ban and kick command? - by DeadAhead - 18.05.2011, 10:40
Re: How to script ban and kick command? - by Hitman-97- - 19.05.2011, 07:15
Re: How to script ban and kick command? - by xalith - 19.05.2011, 07:49

Forum Jump:


Users browsing this thread: 1 Guest(s)