Raised This Month: $ Target: $400
 0% 

[CSGO] Custom Message on Ban ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-17-2016 , 03:47   [CSGO] Custom Message on Ban ?
Reply With Quote #1

I want to know if i can do this from basebans...
I tried to do with this code but i recive error from argument 4 at BanClient(...) If you can help me it's perfect :

PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod Basecommands
 * Functionality related to banning.
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

void PrepareBan(int clientint targetint time, const char[] reason)
{
    
int originalTarget GetClientOfUserId(g_BanTargetUserId[client]);

    if (
originalTarget != target)
    {
        if (
client == 0)
        {
            
PrintToServer("[SM] %t""Player no longer available");
        }
        else
        {
            
PrintToChat(client"[SM] %t""Player no longer available");
        }

        return;
    }

    
char name[MAX_NAME_LENGTH];
    
GetClientName(targetnamesizeof(name));

    if (!
time)
    {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : N/A"clientname);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : %s"clientnamereason);
        }
    } else {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : N/A"clientnametime);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : %s"clientnametimereason);
        }
    }

    
LogAction(clienttarget"\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")"clienttargettimereason);

    if (
reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : N/A"client), ("Ai luat ban de la adminul %N cu motivul : N/A"client), "sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), "sm_ban"client);
    }
}

void DisplayBanTargetMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanPlayerList);

    
char title[100];
    
Format(titlesizeof(title), "%T:""Ban player"client);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
AddTargetsToMenu2(menuclientCOMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED);

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanTimeMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanTimeList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban player"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
menu.AddItem("0""Permanent");
    
menu.AddItem("10""10 Minutes");
    
menu.AddItem("30""30 Minutes");
    
menu.AddItem("60""1 Hour");
    
menu.AddItem("240""4 Hours");
    
menu.AddItem("1440""1 Day");
    
menu.AddItem("10080""1 Week");

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanReasonMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanReasonList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban reason"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;
    
    
//Add custom chat reason entry first
    
menu.AddItem("""Custom reason (type in chat)");
    
    
//Loading configurable entries from the kv-file
    
char reasonName[100];
    
char reasonFull[255];
    
    
//Iterate through the kv-file
    
g_hKvBanReasons.GotoFirstSubKey(false);
    do
    {
        
g_hKvBanReasons.GetSectionName(reasonNamesizeof(reasonName));
        
g_hKvBanReasons.GetString(NULL_STRINGreasonFullsizeof(reasonFull));
        
        
//Add entry
        
menu.AddItem(reasonFullreasonName);
        
    } while (
g_hKvBanReasons.GotoNextKey(false));
    
    
//Reset kvHandle
    
g_hKvBanReasons.Rewind();

    
menu.Display(clientMENU_TIME_FOREVER);
}

public 
void AdminMenu_Ban(TopMenu topmenu,
                              
TopMenuAction action,
                              
TopMenuObject object_id,
                              
int param,
                              
char[] buffer,
                              
int maxlength)
{
    
//Reset chat reason first
    
g_IsWaitingForChatReason[param] = false;
    
    if (
action == TopMenuAction_DisplayOption)
    {
        
Format(buffermaxlength"%T""Ban player"param);
    }
    else if (
action == TopMenuAction_SelectOption)
    {
        
DisplayBanTargetMenu(param);
    }
}

public 
int MenuHandler_BanReasonList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        if(
param2 == 0)
        {
            
//Chat reason
            
g_IsWaitingForChatReason[param1] = true;
            
PrintToChat(param1"[SM] %t""Custom ban reason explanation""sm_abortban");
        }
        else
        {
            
char info[64];
            
            
menu.GetItem(param2infosizeof(info));
            
            
PrepareBan(param1g_BanTarget[param1], g_BanTime[param1], info);
        }
    }
}

public 
int MenuHandler_BanPlayerList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32], name[32];
        
int useridtarget;

        
menu.GetItem(param2infosizeof(info), _namesizeof(name));
        
userid StringToInt(info);

        if ((
target GetClientOfUserId(userid)) == 0)
        {
            
PrintToChat(param1"[SM] %t""Player no longer available");
        }
        else if (!
CanUserTarget(param1target))
        {
            
PrintToChat(param1"[SM] %t""Unable to target");
        }
        else
        {
            
g_BanTarget[param1] = target;
            
g_BanTargetUserId[param1] = userid;
            
DisplayBanTimeMenu(param1);
        }
    }
}

public 
int MenuHandler_BanTimeList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32];

        
menu.GetItem(param2infosizeof(info));
        
g_BanTime[param1] = StringToInt(info);

        
DisplayBanReasonMenu(param1);
    }
}

public 
Action Command_Ban(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"★ \x04[HNS] \x01Usage: \x07sm_ban \x02<target> \x01[durata|0] \x01[reason]");
        return 
Plugin_Handled;
    }

    
int lennext_len;
    
char Arguments[256];
    
GetCmdArgString(Argumentssizeof(Arguments));

    
char arg[65];
    
len BreakString(Argumentsargsizeof(arg));

    
int target FindTarget(clientargtrue);
    if (
target == -1)
    {
        return 
Plugin_Handled;
    }

    
char s_time[12];
    if ((
next_len BreakString(Arguments[len], s_timesizeof(s_time))) != -1)
    {
        
len += next_len;
    }
    else
    {
        
len 0;
        
Arguments[0] = '\0';
    }

    
int time StringToInt(s_time);

    
g_BanTargetUserId[client] = GetClientUserId(target);

    
PrepareBan(clienttargettimeArguments[len]);

    return 
Plugin_Handled;


Last edited by cristian20042; 12-17-2016 at 03:47.
cristian20042 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-17-2016 , 04:41   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #2

if i rember correctly, you can ban with custom reason already with sourcemod
__________________
8guawong is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-17-2016 , 04:47   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
if i rember correctly, you can ban with custom reason already with sourcemod
I want to know if i can change the kick message with name of admin , reason etc.

Last edited by cristian20042; 12-17-2016 at 12:31.
cristian20042 is offline
quake84
Junior Member
Join Date: Aug 2014
Location: Poland
Old 12-18-2016 , 14:18   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #4

You can, but that will require you to manually keep track of bans rather than using BanClient/BanIdentity.

Which will in result welcome you to the glorious and frustrating world of SQL+SourceMod, where a single fuckup can hang the server with a lingering database thread.

On a serious note, you will have to rewrite the plugin to keep track of bans in a separate source (like a sqlite database, or (better) a mysql database) and on each "OnClientAuthorized" check that database for bans, and if the user is banned - kick them.

I don't think you can change the kickmessage for BanClient as that uses the game's internal ban system which has a predefined & unchangeable kick message (which also is translated by the client to the language it's in)
__________________
...
quake84 is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-22-2016 , 11:11   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #5

Quote:
Originally Posted by quake84 View Post
You can, but that will require you to manually keep track of bans rather than using BanClient/BanIdentity.

Which will in result welcome you to the glorious and frustrating world of SQL+SourceMod, where a single fuckup can hang the server with a lingering database thread.

On a serious note, you will have to rewrite the plugin to keep track of bans in a separate source (like a sqlite database, or (better) a mysql database) and on each "OnClientAuthorized" check that database for bans, and if the user is banned - kick them.

I don't think you can change the kickmessage for BanClient as that uses the game's internal ban system which has a predefined & unchangeable kick message (which also is translated by the client to the language it's in)
Ok... Look at this script :

PHP Code:
void PrepareBan(int clientint targetint time, const char[] reason)
{
    
int originalTarget GetClientOfUserId(g_BanTargetUserId[client]);

    if (
originalTarget != target)
    {
        if (
client == 0)
        {
            
PrintToServer("[SM] %t""Player no longer available");
        }
        else
        {
            
PrintToChat(client"[SM] %t""Player no longer available");
        }

        return;
    }

    
char name[MAX_NAME_LENGTH];
    
GetClientName(targetnamesizeof(name));

    if (!
time)
    {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : N/A"clientname);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : %s"clientnamereason);
        }
    } else {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : N/A"clientnametime);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : %s"clientnametimereason);
        }
    }

    
LogAction(clienttarget"\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")"clienttargettimereason);

    if (
reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : N/A"client), ("Ai luat ban de la adminul %N cu motivul : N/A"client), "sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), "sm_ban"client);
    }

As you can see I made something like this :

PHP Code:
    if (reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : N/A"client), ("Ai luat ban de la adminul %N cu motivul : N/A"client), "sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), "sm_ban"client);
    } 
When i compile i recive errors :

basebans/ban.sp(76) : error 035: argument type mismatch (argument 4)

By something like that i can do what i want ???
Please help me...
cristian20042 is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 12-24-2016 , 11:35   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #6

What is on line 76...?
Addicted. is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-24-2016 , 13:32   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #7

Quote:
Originally Posted by oaaron99 View Post
What is on line 76...?
PHP Code:
    if (reason[0] == '\0'
    { 
        
// line 76 ▼▼▼▼
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : N/A"client), ("Ai luat ban de la adminul %N cu motivul : N/A"client), "sm_ban"client); // line 76
    

    else 
    { 
        
BanClient(targettimeBANFLAG_AUTO, ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), ("Ai luat ban de la adminul %N cu motivul : %s"clientreason), "sm_ban"client); 
    } 

Last edited by cristian20042; 12-24-2016 at 13:33.
cristian20042 is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 12-25-2016 , 00:41   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #8

PHP Code:
bool BanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany source
argument 4 is a string

PHP Code:
char banReason[120], kickReason[120];
Format(banReasonsizeof(banReason), "Ai luat ban de la adminul %N cu motivul : %s"clientreason);
Format(kickReasonsizeof(kickReason), "Ai luat ban de la adminul %N cu motivul : %s"clientreason);
BanClient(targettimeBANFLAG_AUTObanReasonkickReason"sm_ban"client); 

Last edited by Addicted.; 12-25-2016 at 11:00.
Addicted. is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-28-2016 , 13:16   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #9

Quote:
Originally Posted by oaaron99 View Post
PHP Code:
bool BanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany source
argument 4 is a string

PHP Code:
char banReason[120], kickReason[120];
Format(banReasonsizeof(banReason), "Ai luat ban de la adminul %N cu motivul : %s"clientreason);
Format(kickReasonsizeof(kickReason), "Ai luat ban de la adminul %N cu motivul : %s"clientreason);
BanClient(targettimeBANFLAG_AUTObanReasonkickReason"sm_ban"client); 
When i ban someone dosen't work to ban more than 9 minutes and on kick message it's VERY VERY wierd... Something like that : You are banned by (random player) for 1 minute ( i put for ex 5 minutes ) with reason : and reason works...

Script :

PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod Basecommands
 * Functionality related to banning.
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

void PrepareBan(int clientint targetint time, const char[] reason)
{
    
int originalTarget GetClientOfUserId(g_BanTargetUserId[client]);

    if (
originalTarget != target)
    {
        if (
client == 0)
        {
            
PrintToServer("[SM] %t""Player no longer available");
        }
        else
        {
            
PrintToChat(client"[SM] %t""Player no longer available");
        }

        return;
    }

    
char name[MAX_NAME_LENGTH];
    
GetClientName(targetnamesizeof(name));

    if (!
time)
    {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : N/A"clientname);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01permanently banned \x02%s \x01with \x07reason : %s"clientnamereason);
        }
    } else {
        if (
reason[0] == '\0')
        {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : N/A"clientnametime);
        } else {
            
PrintToChatAll("★ \x04[HNS] Admin \x02%N \x01banned \x02%s \x01for \x07{%d} minutes \x01with \x07reason : %s"clientnametimereason);
        }
    }

    
LogAction(clienttarget"\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")"clienttargettimereason);

        
char banReason[120], kickReason[120]; 
        
Format(banReasonsizeof(banReason), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>%s</b>"clienttimereason); 
        
Format(kickReasonsizeof(kickReason), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>%s</b>"clienttimereason); 
        
        
char banReason2[120], kickReason2[120]; 
        
Format(banReason2sizeof(banReason2), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>N/A</b>"clienttime); 
        
Format(kickReason2sizeof(kickReason2), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>N/A</b>"clienttime); 
        
        
char banReason3[120], kickReason3[120];
        
Format(banReason3sizeof(banReason3), "Ai luat <b>BAN</b> <b>permanent</b> de la adminul <b>%N</b> cu motivul : <b>%s</b>"clientreason); 
        
Format(kickReason3sizeof(kickReason3), "Ai luat <b>BAN</b> <b>permanent</b> de la adminul <b>%N</b> cu motivul : <b>%s</b>"client,  reason); 
        
        
char banReason4[120], kickReason4[120]; 
        
Format(banReason4sizeof(banReason4), "Ai luat <b>BAN</b> <b>permanent</b> de la adminul <b>%N</b> cu motivul : <b>N/A</b>"client); 
        
Format(kickReason4sizeof(kickReason4), "Ai luat <b>BAN</b> <b>permanent</b> de la adminul <b>%N</b> cu motivul : <b>N/A</b>"client);         
        
        if (!
time)
        {
    if (
reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTObanReason3kickReason3"sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTObanReason4kickReason4"sm_ban"client);
    }
    }
    else
    {
    if (
reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTObanReason2kickReason2"sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTObanReasonkickReason"sm_ban"client);
    }
    }
}

void DisplayBanTargetMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanPlayerList);

    
char title[100];
    
Format(titlesizeof(title), "%T:""Ban player"client);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
AddTargetsToMenu2(menuclientCOMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED);

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanTimeMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanTimeList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban player"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
menu.AddItem("0""Permanent");
    
menu.AddItem("10""10 Minutes");
    
menu.AddItem("30""30 Minutes");
    
menu.AddItem("60""1 Hour");
    
menu.AddItem("240""4 Hours");
    
menu.AddItem("1440""1 Day");
    
menu.AddItem("10080""1 Week");

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanReasonMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanReasonList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban reason"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;
    
    
//Add custom chat reason entry first
    
menu.AddItem("""Custom reason (type in chat)");
    
    
//Loading configurable entries from the kv-file
    
char reasonName[100];
    
char reasonFull[255];
    
    
//Iterate through the kv-file
    
g_hKvBanReasons.GotoFirstSubKey(false);
    do
    {
        
g_hKvBanReasons.GetSectionName(reasonNamesizeof(reasonName));
        
g_hKvBanReasons.GetString(NULL_STRINGreasonFullsizeof(reasonFull));
        
        
//Add entry
        
menu.AddItem(reasonFullreasonName);
        
    } while (
g_hKvBanReasons.GotoNextKey(false));
    
    
//Reset kvHandle
    
g_hKvBanReasons.Rewind();

    
menu.Display(clientMENU_TIME_FOREVER);
}

public 
void AdminMenu_Ban(TopMenu topmenu,
                              
TopMenuAction action,
                              
TopMenuObject object_id,
                              
int param,
                              
char[] buffer,
                              
int maxlength)
{
    
//Reset chat reason first
    
g_IsWaitingForChatReason[param] = false;
    
    if (
action == TopMenuAction_DisplayOption)
    {
        
Format(buffermaxlength"%T""Ban player"param);
    }
    else if (
action == TopMenuAction_SelectOption)
    {
        
DisplayBanTargetMenu(param);
    }
}

public 
int MenuHandler_BanReasonList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        if(
param2 == 0)
        {
            
//Chat reason
            
g_IsWaitingForChatReason[param1] = true;
            
PrintToChat(param1"[SM] %t""Custom ban reason explanation""sm_abortban");
        }
        else
        {
            
char info[64];
            
            
menu.GetItem(param2infosizeof(info));
            
            
PrepareBan(param1g_BanTarget[param1], g_BanTime[param1], info);
        }
    }
}

public 
int MenuHandler_BanPlayerList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32], name[32];
        
int useridtarget;

        
menu.GetItem(param2infosizeof(info), _namesizeof(name));
        
userid StringToInt(info);

        if ((
target GetClientOfUserId(userid)) == 0)
        {
            
PrintToChat(param1"[SM] %t""Player no longer available");
        }
        else if (!
CanUserTarget(param1target))
        {
            
PrintToChat(param1"[SM] %t""Unable to target");
        }
        else
        {
            
g_BanTarget[param1] = target;
            
g_BanTargetUserId[param1] = userid;
            
DisplayBanTimeMenu(param1);
        }
    }
}

public 
int MenuHandler_BanTimeList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32];

        
menu.GetItem(param2infosizeof(info));
        
g_BanTime[param1] = StringToInt(info);

        
DisplayBanReasonMenu(param1);
    }
}

public 
Action Command_Ban(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"★ \x04[HNS] \x01Usage: \x07sm_ban \x02<target> \x01[durata|0] \x01[reason]");
        return 
Plugin_Handled;
    }

    
int lennext_len;
    
char Arguments[256];
    
GetCmdArgString(Argumentssizeof(Arguments));

    
char arg[65];
    
len BreakString(Argumentsargsizeof(arg));

    
int target FindTarget(clientargtrue);
    if (
target == -1)
    {
        return 
Plugin_Handled;
    }

    
char s_time[12];
    if ((
next_len BreakString(Arguments[len], s_timesizeof(s_time))) != -1)
    {
        
len += next_len;
    }
    else
    {
        
len 0;
        
Arguments[0] = '\0';
    }

    
int time StringToInt(s_time);

    
g_BanTargetUserId[client] = GetClientUserId(target);

    
PrepareBan(clienttargettimeArguments[len]);

    return 
Plugin_Handled;

cristian20042 is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 12-28-2016 , 17:06   Re: [CSGO] Custom Message on Ban ?
Reply With Quote #10

Quote:
Originally Posted by cristian20042 View Post
PHP Code:
char banReason[120], kickReason[120]; 
Format(banReasonsizeof(banReason), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>%s</b>"clienttimereason); 
Format(kickReasonsizeof(kickReason), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>%s</b>"clienttimereason); 
        
char banReason2[120], kickReason2[120]; 
Format(banReason2sizeof(banReason2), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>N/A</b>"clienttime); 
Format(kickReason2sizeof(kickReason2), "Ai luat <b>BAN</b> pentru <b>%d</b> minute de la adminul <b>%N</b> cu motivul : <b>N/A</b>"clienttime); 
You have %d %N and %s in the format but you are only providing two parameters: client and time.

EDIT: nvm you have time and client mixed up

Last edited by Addicted.; 12-28-2016 at 22:37.
Addicted. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:44.


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