AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ban snapshot (https://forums.alliedmods.net/showthread.php?t=116947)

numbmlg 01-27-2010 15:59

Ban snapshot
 
It is part of amxcmd, I want to add snapshot, but I do not understand where the error occurred.

Code:

public cmdBan(id, level, cid)
{
    if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED

    new target[32], minutes[8], reason[64]
   
    read_argv(1, target, 31)
    read_argv(2, minutes, 7)
    read_argv(3, reason, 63)
   
    new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
   
    if (!player)
        return PLUGIN_HANDLED

    new authid[32], name2[32], authid2[32], name[32], ipadd[32], hostname[64], CurrentTime[9]
    new userid2 = get_user_userid(player)

    get_user_authid(player, authid2, 31)
    get_user_authid(id, authid, 31)
    get_user_name(player, name2, 31)
    get_user_name(id, name, 31)
    get_user_ip(player,ipadd,31)
    get_cvar_string("hostname",hostname,63)

    client_print(player, print_chat, "[Banned] %s",hostname)
    client_print(player, print_chat, "[Banned] %s [Steamid] %s @ IP - %s", userid2, authid2, ipadd)
    get_time("%m/%d/%Y - %H:%M:%S", CurrentTime, 31)
    client_print(player, print_chat, "[Banned] %s", CurrentTime)
    client_cmd(player, "wait;wait;snapshot;wait;snapshot")
   
    log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
   
    new temp[64], banned[16], nNum = str_to_num(minutes)
    if (nNum)
        format(temp, 63, "%L", player, "FOR_MIN", minutes)
    else
        format(temp, 63, "%L", player, "PERM")

    format(banned, 15, "%L", player, "BANNED")

    if (reason[0])
        server_cmd("kick #%d ^"%s (%s %s)^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, reason, banned, temp, minutes, authid2)
    else
        server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)

   
    // Display the message to all clients

    new msg[256];
    new len;
    new maxpl = get_maxplayers();
    for (new i = 1; i <= maxpl; i++)
    {
        if (is_user_connected(i) && !is_user_bot(i))
        {
            len = formatex(msg, charsmax(msg), "%L", i, "BAN");
            len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
            if (nNum)
            {
                formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
            }
            else
            {
                formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
            }
            if (strlen(reason) > 0)
            {
                formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
            }
            show_activity_id(i, id, name, msg);
        }
    }
   
    console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
   
    return PLUGIN_HANDLED
}

public cmdBanIP(id, level, cid)
{
    if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED
   
    new target[32], minutes[8], reason[64]
   
    read_argv(1, target, 31)
    read_argv(2, minutes, 7)
    read_argv(3, reason, 63)
   
    new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
   
    if (!player)
    {
        // why is this here?
        // no idea
        // player = cmd_target(id, target, 9);
        return PLUGIN_HANDLED
    }
   
    new authid[32], name2[32], authid2[32], name[32], ipadd[32], hostname[64], CurrentTime[9]
    new userid2 = get_user_userid(player)
   
    get_user_authid(player, authid2, 31)
    get_user_authid(id, authid, 31)
    get_user_name(player, name2, 31)
    get_user_name(id, name, 31)
    get_user_ip(player,ipadd,31)
    get_cvar_string("hostname",hostname,63)

    client_print(player, print_chat, "[Banned] %s",hostname)
    client_print(id, print_chat, "[Banned] %s [Steamid] %s @ IP - %s", userid2, authid2, ipadd)
    get_time("%m/%d/%Y - %H:%M:%S", CurrentTime, 31)
    client_print(player, print_chat, "[Banned] %s", CurrentTime)
    client_cmd(player, "wait;wait;snapshot;wait;snapshot")
   
    log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)

    new temp[64], banned[16], nNum = str_to_num(minutes)
    if (nNum)
        format(temp, 63, "%L", player, "FOR_MIN", minutes)
    else
        format(temp, 63, "%L", player, "PERM")
    format(banned, 15, "%L", player, "BANNED")

    new address[32]
    get_user_ip(player, address, 31, 1)

    if (reason[0])
        server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address)
    else
        server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)

    // Display the message to all clients

    new msg[256];
    new len;
    new maxpl = get_maxplayers();
    for (new i = 1; i <= maxpl; i++)
    {
        if (is_user_connected(i) && !is_user_bot(i))
        {
            len = formatex(msg, charsmax(msg), "%L", i, "BAN");
            len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
            if (nNum)
            {
                formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
            }
            else
            {
                formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
            }
            if (strlen(reason) > 0)
            {
                formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
            }
            show_activity_id(i, id, name, msg);
        }
    }

    console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
   
    return PLUGIN_HANDLED
}


wrecked_ 01-27-2010 16:21

Re: Ban snapshot
 
Did you get an error message with a specified line? o.o

numbmlg 01-28-2010 07:36

Re: Ban snapshot
 
Quote:

Originally Posted by wrecked_ (Post 1069915)
Did you get an error message with a specified line? o.o

No error
Code:

//// admincmd.sma
// Header size:          1812 bytes
// Code size:            40868 bytes
// Data size:            26368 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:  85432 bytes
// Done.
//
// Compilation Time: 1,31 sec
// ----------------------------------------


YamiKaitou 01-28-2010 10:16

Re: Ban snapshot
 
If there is no error, then what error are you talking about?


All times are GMT -4. The time now is 07:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.