Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support latest 1.11 sm syntax #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified addons/plugins/ban_disconnected.smx
Binary file not shown.
52 changes: 15 additions & 37 deletions addons/scripting/ban_disconnected.sp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma newdecls required

#define PLUGIN_VERSION "1.5"
#define PLUGIN_VERSION "1.6"

public Plugin myinfo =
{
Expand Down Expand Up @@ -85,11 +85,11 @@ public void OnPluginStart()


#if defined _updater_included
public int Updater_OnPluginUpdated()
public void Updater_OnPluginUpdated()
{
ServerCommand("sm_reload_translations");

ReloadPlugin(INVALID_HANDLE);
Updater_ReloadPlugin(INVALID_HANDLE);
}
#endif

Expand All @@ -116,7 +116,7 @@ public void OnAllPluginsLoaded()

}

void ReadBanReasons()
stock void ReadBanReasons()
{
char Path[PLATFORM_MAX_PATH];

Expand Down Expand Up @@ -182,8 +182,9 @@ public void OnClientDisconnect(int client)

public Action CommDisconnected(int client, int args)
{

return Plugin_Handled;
}

public Action BanDisconnected(int client, int args) {
if(args < 3)
{
Expand Down Expand Up @@ -302,7 +303,6 @@ void CheckAndPerformBan(int client, const char[] steamid, int minutes, const cha
else ReplyToCommand(client, "[sm_bandisconnected] You can't ban an admin with higher immunity than yourself");
}


void CheckAndPerformSilence(int client, const char[] steamid, int minutes, const char[] reason)
{
AdminId source_aid = GetUserAdmin(client), target_aid;
Expand Down Expand Up @@ -367,7 +367,6 @@ public void OnAdminMenuReady(Handle topmenu) {
}
}


public void AdminMenu_Ban(Handle topmenu,
TopMenuAction action, TopMenuObject object_id, int param, char[] buffer, int maxlength)
{
Expand All @@ -380,8 +379,6 @@ public void AdminMenu_Ban(Handle topmenu,
}
}



void DisplayBanTargetMenu(int client)
{
int size = Array_Bans.Length;
Expand Down Expand Up @@ -413,8 +410,6 @@ void DisplayBanTargetMenu(int client)
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_BanPlayerList(Handle menu, MenuAction action, int param1, int param2)
{
if(action == MenuAction_End)
Expand All @@ -431,20 +426,16 @@ public int MenuHandler_BanPlayerList(Handle menu, MenuAction action, int param1,
GetMenuItem(menu, param2, state_, sizeof(state_));
DisplayBanTimeMenu(param1, state_);
}
return 0;
}



void AddMenuItemWithState(Handle menu, const char[] state_, const char[] addstate, const char[] display) {
stock void AddMenuItemWithState(Handle menu, const char[] state_, const char[] addstate, const char[] display) {
char newstate[128];
Format(newstate, sizeof(newstate), "%s\n%s", state_, addstate);
AddMenuItem(menu, newstate, display);
}




void DisplayBanTimeMenu(int client, const char[] state_) {
stock void DisplayBanTimeMenu(int client, const char[] state_) {
Handle menu = CreateMenu(MenuHandler_BanTimeList);
SetMenuTitle(menu, "Ban disconnected player");
SetMenuExitBackButton(menu, true);
Expand All @@ -467,8 +458,6 @@ void DisplayBanTimeMenu(int client, const char[] state_) {
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_BanTimeList(Handle menu, MenuAction action, int param1, int param2) {
if(action == MenuAction_End)
CloseHandle(menu);
Expand All @@ -481,10 +470,9 @@ public int MenuHandler_BanTimeList(Handle menu, MenuAction action, int param1, i
GetMenuItem(menu, param2, state_, sizeof(state_));
DisplayBanReasonMenu(param1, state_);
}
return 0;
}



void DisplayBanReasonMenu(int client, const char[] state_)
{
Handle menu = CreateMenu(MenuHandler_BanReasonList);
Expand All @@ -504,8 +492,6 @@ void DisplayBanReasonMenu(int client, const char[] state_)
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_BanReasonList(Handle menu, MenuAction action, int param1, int param2) {
if(action == MenuAction_End)
CloseHandle(menu);
Expand All @@ -520,10 +506,9 @@ public int MenuHandler_BanReasonList(Handle menu, MenuAction action, int param1,
SetFailState("Bug in menu handlers");
else CheckAndPerformBan(param1, state_parts[0], StringToInt(state_parts[1]), state_parts[2]);
}
return 0;
}



public void AdminMenu_Comm(Handle topmenu,
TopMenuAction action, TopMenuObject object_id, int param, char[] buffer, int maxlength)
{
Expand All @@ -536,8 +521,6 @@ public void AdminMenu_Comm(Handle topmenu,
}
}



void DisplayCommTargetMenu(int client)
{
int size = Array_Bans.Length;
Expand Down Expand Up @@ -569,8 +552,6 @@ void DisplayCommTargetMenu(int client)
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_SilencePlayerList(Handle menu, MenuAction action, int param1, int param2)
{
if(action == MenuAction_End)
Expand All @@ -587,6 +568,7 @@ public int MenuHandler_SilencePlayerList(Handle menu, MenuAction action, int par
GetMenuItem(menu, param2, state_, sizeof(state_));
DisplaySilenceTimeMenu(param1, state_);
}
return 0;
}

void DisplaySilenceTimeMenu(int client, const char[] state_) {
Expand All @@ -613,8 +595,6 @@ void DisplaySilenceTimeMenu(int client, const char[] state_) {
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_SilenceTimeList(Handle menu, MenuAction action, int param1, int param2) {
if(action == MenuAction_End)
CloseHandle(menu);
Expand All @@ -627,10 +607,9 @@ public int MenuHandler_SilenceTimeList(Handle menu, MenuAction action, int param
GetMenuItem(menu, param2, state_, sizeof(state_));
DisplaySilenceReasonMenu(param1, state_);
}
return 0;
}



void DisplaySilenceReasonMenu(int client, const char[] state_)
{
Handle menu = CreateMenu(MenuHandler_SilenceReasonList);
Expand All @@ -650,8 +629,6 @@ void DisplaySilenceReasonMenu(int client, const char[] state_)
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}



public int MenuHandler_SilenceReasonList(Handle menu, MenuAction action, int param1, int param2) {
if(action == MenuAction_End)
CloseHandle(menu);
Expand All @@ -666,4 +643,5 @@ public int MenuHandler_SilenceReasonList(Handle menu, MenuAction action, int par
SetFailState("Bug in menu handlers");
else CheckAndPerformSilence(param1, state_parts[0], StringToInt(state_parts[1]), state_parts[2]);
}
}
return 0;
}