Help please
#1

How would i make a /kick and /ban cmd with Zcmd and Sscanf ?

And the /ban command bans the people in days, thx!
Reply
#2

i dont know the ban command in DAYS but here's the kick command:

pawn Код:
command(kick, playerid, params[])
{
    new reason[128], pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], str[128], ID;

    GetPlayerName(playerid, aname, sizeof(aname));

    if(PlayerInfo[playerid][pAdminLevel] >= 1) {
        if(sscanf(params, "us[128]", ID, reason)) {
            SendClientMessage(playerid, red, "Usage: /kick [playerid] [reason]");
            return 1;
        }
        if(!IsPlayerConnected(ID)) {
            SendClientMessage(playerid, red, "INVALID ID");
            return 1;
        }
        GetPlayerName(ID, pname, sizeof(pname));
        format(str, sizeof(str), "Admin {4ADAED}%s(%d){FF0000} has kicked {5F4AED}%s(%d){FF0000} Reason: %s", aname, playerid, pname, ID, reason);
        SendClientMessageToAll(red, str);
        Kick(ID);
        return 1;
    }

    else if(PlayerInfo[playerid][pAdminLevel] < 1)  {

        SendClientMessage(playerid, red, "You are not an Admin!");
    }
    return 1;
}
you need to change
pawn Код:
if(PlayerInfo[playerid][pAdminLevel] >= 1) {
this line according to your variables..
if this gives errors you can tell here..
Reply
#3

Ty very much.
Reply
#4

What about if i wanted to save the kick logs in a file?
Reply
#5

pawn Код:
stock Log(const filename[], const string[])
{
    new hour, minute, second;
    gettime(hour, minute, second);
    new year, month, day;
    getdate(year, month, day);
    new timestamp[32];
    format(timestamp, sizeof(timestamp), "[%02d/%02d/%02d | %02d:%02d:%02d] ", day, month, year, hour, minute, second);
    new File:logfile = fopen(filename, io_append);
    fwrite(logfile, timestamp);
    fwrite(logfile, string);
    fwrite(logfile, "\r\n");
    fclose(logfile);
}
Use this function

pawn Код:
SendClientMessageToAll(red, str);
Log("kicks.txt", str);
Kick(ID);
Reply
#6

Ty MadeMan
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)