when we silence a player, we can't set a time. If the player enters the server and gets silenced is silenced. this plugin is her solution.
Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION ""
#include <sourcemod>
#include <sdktools>
#include <multicolors>
new GagSorgulama[MAXPLAYERS+1];
new g_gagaccess[MAXPLAYERS+1];
new g_secildi[MAXPLAYERS+1];
new Handle:g_timer[MAXPLAYERS+1];
new toplam_sure;
new String:mydata[PLATFORM_MAX_PATH];
new Float:g_kalan[MAXPLAYERS+1];
public Plugin myinfo =
{
name = "",
author = PLUGIN_AUTHOR,
description = "",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
LoadTranslations("common.phrases");
LoadTranslations("sgag.phrases");
RegAdminCmd("sm_sgag", SureliGag, ADMFLAG_ROOT);
RegAdminCmd("sm_sgagkaldir", SureliGagSil, ADMFLAG_ROOT);
RegConsoleCmd("sm_gagkontrol", gagkontrol);
}
public void OnMapStart()
{
BuildPath( Path_SM, mydata, sizeof(mydata),"configs/sgag.txt" );
}
public Action:SureliGagSil(client,args)
{
if( args < 1 )
{
return Plugin_Handled;
}
decl String:arg[32];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
if( g_gagaccess[target] != 1 )
{
CPrintToChat(client,"%t", "GagDegil", target);
return Plugin_Handled;
}
if(IsClientConnected(target))
{
yetkisil(target);
if( g_timer[target] != null )
{
KillTimer(g_timer[target]);
g_timer[target] = null;
}
CPrintToChat(client,"%t", "GagSilindi", client, target);
}
return Plugin_Handled;
}
public Action:SureliGag(client,args)
{
if(IsClientConnected(client))
{
toplam_sure = 0;
for( int i = 1; i <= MaxClients; i++ )
{
if(IsClientConnected(i) && g_secildi[i] == 1 )
{
g_secildi[i] = 0;
}
}
Menu menu = new Menu(SureliGag_Handled);
menu.SetTitle("Oyuncu Seçin");
decl String:name[MAX_NAME_LENGTH];
decl String:list[32];
for( int i = 1; i <= MaxClients; i++ )
{
if(IsClientConnected(i))
{
GetClientName(i, name, sizeof(name));
Format(list, sizeof(list), "%i", i);
menu.AddItem(list, name );
}
}
menu.Display(client, MENU_TIME_FOREVER);
}
}
public SureliGag_Handled(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new target = StringToInt(info);
if( target != 0 )
{
g_secildi[target] = 1;
SureMenu(param1);
}
}
}
public SureMenu(client)
{
if(IsClientConnected(client))
{
Menu menu = new Menu(SureMenu_Handled);
menu.SetTitle("Süre Belirle");
menu.AddItem("gun", "Kaç Gün ?");
menu.AddItem("saat", "Kaç Saat ?");
menu.AddItem("dakika", "Kaç Dakika ?");
menu.AddItem("ver", "Cezayı Ver");
menu.Display(client, MENU_TIME_FOREVER);
}
}
public SureMenu_Handled(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
switch(param2)
{
case 0:
{
GunBelirle(param1);
}
case 1:
{
SaatBelirle(param1);
}
case 2:
{
DakikaBelirle(param1);
}
case 3:
{
YetkiVer(param1);
}
}
}
}
public GunBelirle(client)
{
if(IsClientConnected(client))
{
Menu menu = new Menu(GunBelirle_Handled);
menu.SetTitle("Kaç Gün?");
menu.AddItem("1", "1 Gün");
menu.AddItem("2", "2 Gün");
menu.AddItem("3", "3 Gün");
menu.AddItem("4", "4 Gün");
menu.AddItem("5", "5 Gün");
menu.AddItem("6", "6 Gün");
menu.Display(client, MENU_TIME_FOREVER);
}
}
public GunBelirle_Handled(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new ekle = StringToInt(info);
toplam_sure += ekle*86400;
CPrintToChat(param1,"%t", "GagGun", ekle );
new days = toplam_sure/86400;
new hrs = (toplam_sure/3600)%24;
new mins = (toplam_sure/60)%60;
CPrintToChat(param1,"%t", "GagToplam", days, hrs, mins);
SureMenu(param1);
}
}
public SaatBelirle(client)
{
if(IsClientConnected(client))
{
Menu menu = new Menu(SaatBelirle_Handled);
menu.SetTitle("Kaç Saat?");
menu.AddItem("1", "1 Saat");
menu.AddItem("2", "2 Saat");
menu.AddItem("3", "3 Saat");
menu.AddItem("4", "4 Saat");
menu.AddItem("5", "5 Saat");
menu.AddItem("6", "6 Saat");
menu.Display(client, MENU_TIME_FOREVER);
}
}
public SaatBelirle_Handled(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new ekle = StringToInt(info);
toplam_sure += ekle*3600;
CPrintToChat(param1,"%t", "GagSaat", ekle );
new days = toplam_sure/86400;
new hrs = (toplam_sure/3600)%24;
new mins = (toplam_sure/60)%60;
CPrintToChat(param1,"%t", "GagToplam", days, hrs, mins);
SureMenu(param1);
}
}
public DakikaBelirle(client)
{
if(IsClientConnected(client))
{
Menu menu = new Menu(DakikaBelirle_Handled);
menu.SetTitle("Kaç Dakika?");
menu.AddItem("1", "1 Dakika");
menu.AddItem("10", "10 Dakika");
menu.AddItem("15", "15 Dakika");
menu.AddItem("20", "20 Dakika");
menu.AddItem("25", "25 Dakika");
menu.AddItem("30", "30 Dakika");
menu.Display(client, MENU_TIME_FOREVER);
}
}
public DakikaBelirle_Handled(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new ekle = StringToInt(info);
toplam_sure += ekle*60;
CPrintToChat(param1,"%t", "GagDakika", ekle );
new days = toplam_sure/86400;
new hrs = (toplam_sure/3600)%24;
new mins = (toplam_sure/60)%60;
CPrintToChat(param1,"%t", "GagToplam", days, hrs, mins);
SureMenu(param1);
}
}
public YetkiVer(client)
{
for( int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i))
{
if(g_secildi[i] == 1)
{
decl String:buffer[128];
GetClientAuthId(i, AuthId_Steam2, buffer, sizeof(buffer));
new Handle:kv = CreateKeyValues("sgag");
FileToKeyValues(kv, mydata);
KvJumpToKey(kv, buffer, true);
KvSetNum(kv, "sure", GetTime() + toplam_sure);
KvRewind(kv);
KeyValuesToFile(kv, mydata);
CloneHandle(kv);
g_timer[i] = CreateTimer(float(toplam_sure), GagEnd, i);
new days = toplam_sure/86400;
new hrs = (toplam_sure/3600)%24;
new mins = (toplam_sure/60)%60;
GagSorgulama[i] = GetTime() + toplam_sure;
g_gagaccess[i] = 1;
CPrintToChatAll("%t", "GagAt", client, i, days, hrs, mins);
}
}
else
{
if(g_secildi[i] == 1)
{
CPrintToChat(client,"%t", "GagYok",i);
}
}
}
toplam_sure = 0;
}
public OnClientPostAdminCheck(client)
{
gagkontrolzaman(client);
}
gagkontrolzaman(client)
{
decl String:buffer[128];
decl String:s_name[128];
GetClientAuthId(client, AuthId_Steam2, buffer, sizeof(buffer));
new Handle:kv = CreateKeyValues("sgag");
FileToKeyValues(kv, mydata);
if(!KvGotoFirstSubKey(kv))
{
CloseHandle(kv);
return;
}
do
{
KvGetSectionName(kv, s_name,sizeof(s_name));
if(StrEqual(s_name,buffer))
{
GagSorgulama[client] = KvGetNum(kv, "sure" );
if(GagSorgulama[client] > GetTime())
{
g_kalan[client] = float(GagSorgulama[client] - GetTime());
g_timer[client] = CreateTimer( g_kalan[client], GagEnd, client);
g_gagaccess[client] = 1;
}
else
{
yetkisil(client);
}
}
}
while(KvGotoNextKey(kv));
CloseHandle(kv);
}
public Action:GagEnd(Handle:timer, any:client)
{
yetkisil(client);
g_timer[client] = null;
CPrintToChat(client, "%t", "GagSuresiSonaErdi" );
return Plugin_Continue;
}
yetkisil(client)
{
g_gagaccess[client] = 0;
decl String:buffer[128];
decl String:s_name[128];
GetClientAuthId(client, AuthId_Steam2, buffer, sizeof(buffer));
new Handle:kv = CreateKeyValues("sgag");
FileToKeyValues(kv, mydata);
KvJumpToKey(kv, buffer, true);
do
{
KvGetSectionName(kv, s_name, sizeof(s_name));
if(StrEqual(buffer,s_name,false))
{
KvDeleteThis(kv);
KeyValuesToFile(kv, mydata);
break;
}
}
while(KvGotoNextKey(kv));
CloseHandle(kv);
}
public Action:gagkontrol(client,args)
{
if(g_gagaccess[client] == 1 )
{
new kalan = GagSorgulama[client] - GetTime();
new days = kalan/86400;
new hrs = (kalan/3600)%24;
new mins = (kalan/60)%60;
new sec = kalan%60;
CPrintToChat(client, "%t", "GagSorgulama", days, hrs, mins, sec);
}
else
{
CPrintToChat(client, "%t", "GagNo" );
}
return Plugin_Handled;
}
public OnClientDisconnect(client)
{
g_secildi[client] = 0;
if( g_gagaccess[client] )
{
KillTimer(g_timer[client]);
g_timer[client] = null;
}
}
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
{
if (client && g_gagaccess[client] == 1)
{
new kalan = GagSorgulama[client] - GetTime();
new days = kalan/86400;
new hrs = (kalan/3600)%24;
new mins = (kalan/60)%60;
new sec = kalan%60;
CPrintToChat(client, "%t", "GagSorgulama", days, hrs, mins, sec);
return Plugin_Stop;
}
return Plugin_Continue;
}