Advertisement
Guest User

Untitled

a guest
Mar 9th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 38.45 KB | None | 0 0
  1. /*
  2.  * MyJailbreak - Warden Plugin.
  3.  * by: shanapu
  4.  * https://github.com/shanapu/MyJailbreak/
  5.  *
  6.  * This file is part of the MyJailbreak SourceMod Plugin.
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify it under
  9.  * the terms of the GNU General Public License, version 3.0, as published by the
  10.  * Free Software Foundation.
  11.  *
  12.  * This program is distributed in the hope that it will be useful, but WITHOUT
  13.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  14.  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  15.  * details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License along with
  18.  * this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  */
  20.  
  21.  
  22. /******************************************************************************
  23.                    STARTUP
  24. ******************************************************************************/
  25.  
  26.  
  27. //Includes
  28. #include <sourcemod>
  29. #include <sdktools>
  30. #include <sdkhooks>
  31. #include <cstrike>
  32. #include <emitsoundany>
  33. #include <smlib>
  34. #include <colors>
  35. #include <autoexecconfig>
  36. #include <warden>
  37.  
  38. //Optional Plugins
  39. #undef REQUIRE_PLUGIN
  40. #include <myjailbreak>
  41. #include <hosties>
  42. #include <lastrequest>
  43. #include <smartjaildoors>
  44. #include <voiceannounce_ex>
  45. #include <chat-processor>
  46. #define REQUIRE_PLUGIN
  47.  
  48. #include <mystocks>
  49.  
  50.  
  51. //Defines
  52. #define MAX_BUTTONS 25
  53.  
  54.  
  55. //Console Variables
  56. ConVar gc_bPlugin;
  57. ConVar gc_bVote;
  58. ConVar gc_bStayWarden;
  59. ConVar gc_bBecomeWarden;
  60. ConVar gc_bChooseRandom;
  61. ConVar gc_bSounds;
  62. ConVar gc_bOverlays;
  63. ConVar gc_sWarden;
  64. ConVar gc_sUnWarden;
  65. ConVar gc_sModelPathWarden;
  66. ConVar gc_bModel;
  67. ConVar gc_bBetterNotes;
  68. ConVar gc_sCustomCommandWarden;
  69. ConVar gc_sCustomCommandUnWarden;
  70. ConVar gc_sCustomCommandVetoWarden;
  71. ConVar gc_sCustomCommandSetWarden;
  72. ConVar gc_sCustomCommandRemoveWarden;
  73. ConVar gc_fRandomTimer;
  74.  
  75.  
  76. //3rd party Convars
  77. ConVar g_bMenuClose;
  78.  
  79.  
  80. //Booleans
  81. bool IsLR = false;
  82. bool gp_bMyJailBreak = false;
  83. bool gp_bHosties = false;
  84. bool gp_bLastRequest = false;
  85. bool gp_bSmartJailDoors = false;
  86. bool gp_bChatProcessor = false;
  87.  
  88.  
  89.  
  90.  
  91. //Integers
  92. int g_iWarden = -1;
  93.  
  94.  
  95.  
  96.  
  97. int g_iTempWarden[MAXPLAYERS+1] = -1;
  98. int g_iVoteCount;
  99. int g_iBeamSprite = -1;
  100. int g_iHaloSprite = -1;
  101. int g_iSmokeSprite;
  102. int g_iLastButtons[MAXPLAYERS+1];
  103. int g_iColors[8][4] =
  104. {
  105.     {255, 255, 255, 255},  //white
  106.     {255, 0, 0, 255},  //red
  107.     {20, 255, 20, 255},  //green
  108.     {0, 65, 255, 255},  //blue
  109.     {255, 255, 0, 255},  //yellow
  110.     {0, 255, 255, 255},  //cyan
  111.     {255, 0, 255, 255},  //magenta
  112.     {255, 80, 0, 255}  //orange
  113. };
  114. //ajout pookie
  115. Handle timerql;
  116. Handle timerquartier;
  117. int test=12;
  118. int pouic=120;
  119.  
  120. //Handles
  121. Handle gF_OnWardenCreated;
  122. Handle gF_OnWardenRemoved;
  123. Handle gF_OnWardenCreatedByUser;
  124. Handle gF_OnWardenCreatedByAdmin;
  125. Handle gF_OnWardenDisconnected;
  126. Handle gF_OnWardenDeath;
  127. Handle gF_OnWardenRemovedBySelf;
  128. Handle gF_OnWardenRemovedByAdmin;
  129. Handle RandomTimer;
  130.  
  131.  
  132. //Strings
  133. char g_sHasVoted[1500];
  134. char g_sModelPathPrevious[256];
  135. char g_sModelPathWarden[256];
  136. char g_sUnWarden[256];
  137. char g_sWarden[256];
  138. char g_sMyJBLogFile[PLATFORM_MAX_PATH];
  139.  
  140.  
  141. //Modules
  142. #include "MyJailbreak/Modules/Warden/celldoors.sp"
  143. #include "MyJailbreak/Modules/Warden/deputy.sp"
  144. #include "MyJailbreak/Modules/Warden/mute.sp"
  145. #include "MyJailbreak/Modules/Warden/bulletsparks.sp"
  146. #include "MyJailbreak/Modules/Warden/countdown.sp"
  147. #include "MyJailbreak/Modules/Warden/math.sp"
  148. #include "MyJailbreak/Modules/Warden/disarm.sp"
  149. #include "MyJailbreak/Modules/Warden/noblock.sp"
  150. #include "MyJailbreak/Modules/Warden/extendtime.sp"
  151. #include "MyJailbreak/Modules/Warden/friendlyfire.sp"
  152. #include "MyJailbreak/Modules/Warden/reminder.sp"
  153. #include "MyJailbreak/Modules/Warden/randomkill.sp"
  154. #include "MyJailbreak/Modules/Warden/handcuffs.sp"
  155. #include "MyJailbreak/Modules/Warden/backstab.sp"
  156. #include "MyJailbreak/Modules/Warden/gundrop.sp"
  157. #include "MyJailbreak/Modules/Warden/marker.sp"
  158. #include "MyJailbreak/Modules/Warden/color.sp"
  159. #include "MyJailbreak/Modules/Warden/laser.sp"
  160. #include "MyJailbreak/Modules/Warden/painter.sp"
  161. #include "MyJailbreak/Modules/Warden/rebel.sp"
  162. #include "MyJailbreak/Modules/Warden/counter.sp"
  163. #include "MyJailbreak/Modules/Warden/shootguns.sp"
  164. #include "MyJailbreak/Modules/Warden/orders.sp"
  165. #include "MyJailbreak/Modules/Warden/freedays.sp"
  166.  
  167.  
  168. //Compiler Options
  169. #pragma semicolon 1
  170. #pragma newdecls required
  171.  
  172.  
  173. //Info
  174. public Plugin myinfo = {
  175.     name = "MyJailbreak - Warden",
  176.     author = "shanapu, ecca, ESKO & .#zipcore",
  177.     description = "Jailbreak Warden script",
  178.     version = MYJB_VERSION,
  179.     url = MYJB_URL_LINK
  180. };
  181.  
  182.  
  183. //Start
  184. public void OnPluginStart()
  185. {
  186.     //Translation
  187.     LoadTranslations("MyJailbreak.Warden.phrases");
  188.    
  189.    
  190.     //Client commands
  191.     RegConsoleCmd("sm_warden", Command_BecomeWarden, "Allows the player taking the charge over prisoners");
  192.     RegConsoleCmd("sm_unwarden", Command_ExitWarden, "Allows the player to retire from the position");
  193.     RegConsoleCmd("sm_vetowarden", Command_VoteWarden, "Allows the player to vote to retire Warden");
  194.    
  195.    
  196.     //Admin commands
  197.     RegAdminCmd("sm_setwarden", AdminCommand_SetWarden, ADMFLAG_GENERIC);
  198.     RegAdminCmd("sm_removewarden", AdminCommand_RemoveWarden, ADMFLAG_GENERIC);
  199.    
  200.    
  201.     //Forwards
  202.     gF_OnWardenCreated = CreateGlobalForward("warden_OnWardenCreated", ET_Ignore, Param_Cell);
  203.     gF_OnWardenRemoved = CreateGlobalForward("warden_OnWardenRemoved", ET_Ignore, Param_Cell);
  204.     gF_OnWardenCreatedByUser = CreateGlobalForward("warden_OnWardenCreatedByUser", ET_Ignore, Param_Cell);
  205.     gF_OnWardenCreatedByAdmin = CreateGlobalForward("warden_OnWardenCreatedByAdmin", ET_Ignore, Param_Cell);
  206.     gF_OnWardenDisconnected = CreateGlobalForward("warden_OnWardenDisconnected", ET_Ignore, Param_Cell);
  207.     gF_OnWardenDeath = CreateGlobalForward("warden_OnWardenDeath", ET_Ignore, Param_Cell);
  208.     gF_OnWardenRemovedBySelf = CreateGlobalForward("warden_OnWardenRemovedBySelf", ET_Ignore, Param_Cell);
  209.     gF_OnWardenRemovedByAdmin = CreateGlobalForward("warden_OnWardenRemovedByAdmin", ET_Ignore, Param_Cell);
  210.    
  211.    
  212.     //AutoExecConfig
  213.     AutoExecConfig_SetFile("Warden", "MyJailbreak");
  214.     AutoExecConfig_SetCreateFile(true);
  215.    
  216.     AutoExecConfig_CreateConVar("sm_warden_version", MYJB_VERSION, "The version of this MyJailbreak SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  217.     gc_bPlugin = AutoExecConfig_CreateConVar("sm_warden_enable", "1", "0 - disabled, 1 - enable this MyJailbreak SourceMod plugin", _, true,  0.0, true, 1.0);
  218.     gc_sCustomCommandWarden = AutoExecConfig_CreateConVar("sm_warden_cmds_become", "w, simon", "Set your custom chat commands for become warden(!warden (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  219.     gc_sCustomCommandUnWarden = AutoExecConfig_CreateConVar("sm_warden_cmds_retire", "uw, unsimon", "Set your custom chat commands for retire from warden(!unwarden (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  220.     gc_sCustomCommandVetoWarden = AutoExecConfig_CreateConVar("sm_warden_cmds_veto", "vw, votewarden", "Set your custom chat commands for vote against warden(!vetowarden (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  221.     gc_sCustomCommandSetWarden = AutoExecConfig_CreateConVar("sm_warden_cmds_set", "sw, newwarden", "Set your custom chat commands for admins to set a new warden(!setwarden (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  222.     gc_sCustomCommandRemoveWarden = AutoExecConfig_CreateConVar("sm_warden_cmds_remove", "rw, firewarden, fw", "Set your custom chat commands for admins to remove a warden(!removewarden (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands)");
  223.     gc_bBecomeWarden = AutoExecConfig_CreateConVar("sm_warden_become", "1", "0 - disabled, 1 - enable !w / !warden - player can choose to be warden. If disabled you should need sm_warden_choose_random 1", _, true,  0.0, true, 1.0);
  224.     gc_bChooseRandom = AutoExecConfig_CreateConVar("sm_warden_choose_random", "0", "0 - disabled, 1 - enable pick random warden if there is still no warden after sm_warden_choose_time", _, true,  0.0, true, 1.0);
  225.     gc_fRandomTimer = AutoExecConfig_CreateConVar("sm_warden_choose_time", "45.0", "Time in seconds a random warden will picked when no warden was set. need sm_warden_choose_random 1", _, true,  1.0);
  226.     gc_bVote = AutoExecConfig_CreateConVar("sm_warden_vote", "1", "0 - disabled, 1 - enable player vote against warden", _, true,  0.0, true, 1.0);
  227.     gc_bStayWarden = AutoExecConfig_CreateConVar("sm_warden_stay", "1", "0 - disabled, 1 - enable warden stay after round end", _, true,  0.0, true, 1.0);
  228.     gc_bBetterNotes = AutoExecConfig_CreateConVar("sm_warden_better_notifications", "1", "0 - disabled, 1 - Will use hint and center text", _, true, 0.0, true, 1.0);
  229.     gc_bModel = AutoExecConfig_CreateConVar("sm_warden_model", "1", "0 - disabled, 1 - enable warden model", 0, true, 0.0, true, 1.0);
  230.     gc_sModelPathWarden = AutoExecConfig_CreateConVar("sm_warden_model_path", "models/player/custom_player/legacy/security/security.mdl", "Path to the model for warden.");
  231.     gc_bSounds = AutoExecConfig_CreateConVar("sm_warden_sounds_enable", "1", "0 - disabled, 1 - enable sounds ", _, true,  0.0, true, 1.0);
  232.     gc_sWarden = AutoExecConfig_CreateConVar("sm_warden_sounds_warden", "music/MyJailbreak/warden.mp3", "Path to the soundfile which should be played for a int warden.");
  233.     gc_sUnWarden = AutoExecConfig_CreateConVar("sm_warden_sounds_unwarden", "music/MyJailbreak/unwarden.mp3", "Path to the soundfile which should be played when there is no warden anymore.");
  234.     gc_bOverlays = AutoExecConfig_CreateConVar("sm_warden_overlays_enable", "1", "0 - disabled, 1 - enable overlays", _, true,  0.0, true, 1.0);
  235.    
  236.    
  237.     //Warden module
  238.     Deputy_OnPluginStart();
  239.     Mute_OnPluginStart();
  240.     Disarm_OnPluginStart();
  241.     BulletSparks_OnPluginStart();
  242.     Countdown_OnPluginStart();
  243.     Math_OnPluginStart();
  244.     NoBlock_OnPluginStart();
  245.     CellDoors_OnPluginStart();
  246.     ExtendTime_OnPluginStart();
  247.     FriendlyFire_OnPluginStart();
  248.     Reminder_OnPluginStart();
  249.     RandomKill_OnPluginStart();
  250.     //HandCuffs_OnPluginStart();
  251.     BackStab_OnPluginStart();
  252.     Marker_OnPluginStart();
  253.     GunDropPrevention_OnPluginStart();
  254.     Color_OnPluginStart();
  255.     Laser_OnPluginStart();
  256.     Painter_OnPluginStart();
  257.     MarkRebel_OnPluginStart();
  258.     Counter_OnPluginStart();
  259.     ShootGuns_OnPluginStart();
  260.     Orders_OnPluginStart();
  261.     Freedays_OnPluginStart();
  262.    
  263.    
  264.     //AutoExecConfig
  265.     AutoExecConfig_ExecuteFile();
  266.     AutoExecConfig_CleanFile();
  267.    
  268.    
  269.  
  270.     //Hooks
  271.     HookEvent("round_start", Event_RoundStart);
  272.     HookEvent("round_poststart", Event_PostRoundStart);
  273.     HookEvent("player_death", Event_PlayerDeath);
  274.     HookEvent("player_team", Event_PlayerTeam);
  275.     HookEvent("round_end", Event_RoundEnd);
  276.     HookConVarChange(gc_sModelPathWarden, OnSettingChanged);
  277.     HookConVarChange(gc_sUnWarden, OnSettingChanged);
  278.     HookConVarChange(gc_sWarden, OnSettingChanged);
  279.    
  280.    
  281.     //FindConVar
  282.     gc_sWarden.GetString(g_sWarden, sizeof(g_sWarden));
  283.     gc_sUnWarden.GetString(g_sUnWarden, sizeof(g_sUnWarden));
  284.     gc_sModelPathWarden.GetString(g_sModelPathWarden, sizeof(g_sModelPathWarden));
  285.    
  286.    
  287.     //Set directory for LogFile - must be created before
  288.     SetLogFile(g_sMyJBLogFile, "MyJB", "MyJailbreak");
  289.    
  290. }
  291.  
  292.  
  293. //ConVarChange for Strings
  294. public int OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
  295. {
  296.     if (convar == gc_sWarden)
  297.     {
  298.         strcopy(g_sWarden, sizeof(g_sWarden), newValue);
  299.         if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sWarden);
  300.     }
  301.     else if (convar == gc_sUnWarden)
  302.     {
  303.         strcopy(g_sUnWarden, sizeof(g_sUnWarden), newValue);
  304.         if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sUnWarden);
  305.     }
  306.     else if (convar == gc_sModelPathWarden)
  307.     {
  308.         strcopy(g_sModelPathWarden, sizeof(g_sModelPathWarden), newValue);
  309.         if (gc_bModel.BoolValue) PrecacheModel(g_sModelPathWarden);
  310.     }
  311. }
  312.  
  313.  
  314. //Initialize Plugin
  315. public void OnConfigsExecuted()
  316. {
  317.     Deputy_OnConfigsExecuted();
  318.     Math_OnConfigsExecuted();
  319.     RandomKill_OnConfigsExecuted();
  320.     CellDoors_OnConfigsExecuted();
  321.     Laser_OnConfigsExecuted();
  322.     Mute_OnConfigsExecuted();
  323.     NoBlock_OnConfigsExecuted();
  324.     Painter_OnConfigsExecuted();
  325.     Rebel_OnConfigsExecuted();
  326.     Countdown_OnConfigsExecuted();
  327.     ExtendTime_OnConfigsExecuted();
  328.     Counter_OnConfigsExecuted();
  329.     Orders_OnConfigsExecuted();
  330.     Freedays_OnConfigsExecuted();
  331.    
  332.     //Set custom Commands
  333.     int iCount = 0;
  334.     char sCommands[128], sCommandsL[12][32], sCommand[32];
  335.    
  336.    
  337.     //Become warden
  338.     gc_sCustomCommandWarden.GetString(sCommands, sizeof(sCommands));
  339.     ReplaceString(sCommands, sizeof(sCommands), " ", "");
  340.     iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  341.    
  342.     for (int i = 0; i < iCount; i++)
  343.     {
  344.         Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  345.         if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS)  //if command not already exist
  346.             RegConsoleCmd(sCommand, Command_BecomeWarden, "Allows the warde taking the charge over prisoners");
  347.     }
  348.    
  349.     //Exit warden
  350.     gc_sCustomCommandUnWarden.GetString(sCommands, sizeof(sCommands));
  351.     ReplaceString(sCommands, sizeof(sCommands), " ", "");
  352.     iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  353.    
  354.     for (int i = 0; i < iCount; i++)
  355.     {
  356.         Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  357.         if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS)  //if command not already exist
  358.             RegConsoleCmd(sCommand, Command_ExitWarden, "Allows the player to retire from the position");
  359.     }
  360.    
  361.     //Veto warden
  362.     gc_sCustomCommandVetoWarden.GetString(sCommands, sizeof(sCommands));
  363.     ReplaceString(sCommands, sizeof(sCommands), " ", "");
  364.     iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  365.    
  366.     for (int i = 0; i < iCount; i++)
  367.     {
  368.         Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  369.         if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS)  //if command not already exist
  370.             RegConsoleCmd(sCommand, Command_VoteWarden, "Allows the player to vote against Warden");
  371.     }
  372.    
  373.     //Set warden
  374.     gc_sCustomCommandSetWarden.GetString(sCommands, sizeof(sCommands));
  375.     ReplaceString(sCommands, sizeof(sCommands), " ", "");
  376.     iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  377.    
  378.     for (int i = 0; i < iCount; i++)
  379.     {
  380.         Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  381.         if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS)  //if command not already exist
  382.             RegAdminCmd(sCommand, AdminCommand_SetWarden, ADMFLAG_GENERIC, "Allows the admin to set a new Warden");
  383.     }
  384.    
  385.     //Remove warden
  386.     gc_sCustomCommandRemoveWarden.GetString(sCommands, sizeof(sCommands));
  387.     ReplaceString(sCommands, sizeof(sCommands), " ", "");
  388.     iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  389.    
  390.     for (int i = 0; i < iCount; i++)
  391.     {
  392.         Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  393.         if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS)  //if command not already exist
  394.             RegAdminCmd(sCommand, AdminCommand_RemoveWarden, ADMFLAG_GENERIC, "Allows the admin to remove the Warden");
  395.     }
  396. }
  397.  
  398.  
  399. public void OnAllPluginsLoaded()
  400. {
  401.     //FindConVar
  402.     g_bMenuClose = FindConVar("sm_menu_close");
  403.    
  404.     gp_bMyJailBreak = LibraryExists("myjailbreak");
  405.     gp_bHosties = LibraryExists("hosties");
  406.     gp_bLastRequest = LibraryExists("lastrequest");
  407.     gp_bSmartJailDoors = LibraryExists("smartjaildoors");
  408.     gp_bChatProcessor = LibraryExists("chat-processor");
  409. }
  410.  
  411.  
  412. public void OnLibraryRemoved(const char[] name)
  413. {
  414.     if (StrEqual(name, "myjailbreak"))
  415.         gp_bMyJailBreak = false;
  416.     if (StrEqual(name, "hosties"))
  417.         gp_bHosties = false;
  418.     if (StrEqual(name, "lastrequest"))
  419.         gp_bLastRequest = false;
  420.     if (StrEqual(name, "smartjaildoors"))
  421.         gp_bSmartJailDoors = false;
  422.     if (StrEqual(name, "chat-processor"))
  423.         gp_bChatProcessor = false;
  424. }
  425.  
  426.  
  427. public void OnLibraryAdded(const char[] name)
  428. {
  429.     if (StrEqual(name, "myjailbreak"))
  430.         gp_bMyJailBreak = true;
  431.     if (StrEqual(name, "hosties"))
  432.         gp_bHosties = true;
  433.     if (StrEqual(name, "lastrequest"))
  434.         gp_bLastRequest = true;
  435.     if (StrEqual(name, "smartjaildoors"))
  436.         gp_bSmartJailDoors = true;
  437.     if (StrEqual(name, "chat-processor"))
  438.         gp_bChatProcessor = true;
  439. }
  440.  
  441.  
  442. /******************************************************************************
  443.                    COMMANDS
  444. ******************************************************************************/
  445.  
  446.  
  447. //Become Warden
  448. public Action Command_BecomeWarden(int client, int args)
  449. {
  450.     if (gc_bPlugin.BoolValue)  //"sm_warden_enable" "1"
  451.     {
  452.         if (g_iWarden == -1)  //Is there already a warden
  453.         {
  454.             if (gc_bBecomeWarden.BoolValue)  //"sm_warden_become" "1"
  455.             {
  456.                 if (GetClientTeam(client) == CS_TEAM_CT)  //Is player a guard
  457.                 {
  458.                     if (IsPlayerAlive(client))  //Alive?
  459.                     {
  460.                         SetTheWarden(client);
  461.                        
  462.                         Forward_OnWardenCreatedByUser(client);
  463.                        
  464.                     }
  465.                     else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_playerdead");
  466.                 }
  467.                 else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_ctsonly");
  468.             }
  469.             else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_nobecome", g_iWarden);
  470.         }
  471.         else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_exist", g_iWarden);
  472.     }
  473.     else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_disabled");
  474.     return Plugin_Handled;
  475. }
  476.  
  477.  
  478. //Exit / Retire Warden
  479. public Action Command_ExitWarden(int client, int args)
  480. {
  481.     if (gc_bPlugin.BoolValue)  //"sm_warden_enable" "1"
  482.     {
  483.         if (IsClientWarden(client))  //Is client the warden
  484.         {
  485.             Forward_OnWardenRemovedBySelf(client);
  486.             RemoveTheWarden();
  487.            
  488.             CPrintToChatAll("%t %t", "warden_tag" , "warden_retire", client);
  489.             if (gc_bBetterNotes.BoolValue)
  490.             {
  491.                 PrintCenterTextAll("%t", "warden_retire_nc", client);
  492.             }
  493.         }
  494.         else CPrintToChat(client, "%t %t", "warden_tag" , "warden_notwarden");
  495.     }
  496.     else CPrintToChat(client, "%t %t", "warden_tag" , "warden_disabled");
  497.     return Plugin_Handled;
  498. }
  499.  
  500.  
  501. //Voting against Warden
  502. public Action Command_VoteWarden(int client, int args)
  503. {
  504.     if (gc_bPlugin.BoolValue)  //"sm_warden_enable" "1"
  505.     {
  506.         if (gc_bVote.BoolValue)  //"sm_warden_vote" "1"
  507.         {
  508.             char steamid[64];
  509.             GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));  //Get client steam ID
  510.             if (g_iWarden != -1)
  511.             {
  512.                 if (StrContains(g_sHasVoted, steamid, true) == -1)  //Check steam ID has already voted
  513.                 {
  514.                     int playercount = (GetClientCount(true) / 2);
  515.                     g_iVoteCount++;
  516.                     int Missing = playercount - g_iVoteCount + 1;
  517.                     Format(g_sHasVoted, sizeof(g_sHasVoted), "%s, %s", g_sHasVoted, steamid);
  518.                    
  519.                     if (g_iVoteCount > playercount)
  520.                     {
  521.                         RemoveTheWarden();
  522.                         CPrintToChatAll("%t %t", "warden_tag" , "warden_votesuccess");
  523.                         if(gp_bMyJailBreak) if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sMyJBLogFile, "Player %L was kick as warden by voting", g_iWarden);
  524.                     }
  525.                     else CPrintToChatAll("%t %t", "warden_tag" , "warden_need", Missing, client);
  526.                 }
  527.                 else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_voted");
  528.             }
  529.             else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_noexist");
  530.         }
  531.         else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_voting");
  532.     }
  533.     else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_disabled");
  534.     return Plugin_Handled;
  535. }
  536.  
  537.  
  538. //Remove Warden for Admins
  539. public Action AdminCommand_RemoveWarden(int client, int args)
  540. {
  541.     if (gc_bPlugin.BoolValue)  //"sm_warden_enable" "1"
  542.     {
  543.         if (g_iWarden != -1)  //Is there a warden to remove
  544.         {
  545.             CPrintToChatAll("%t %t", "warden_tag" , "warden_removed", client, g_iWarden);  // if client is console !=
  546.             if (gc_bBetterNotes.BoolValue) PrintCenterTextAll("%t", "warden_removed_nc", client, g_iWarden);
  547.             if(gp_bMyJailBreak) if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sMyJBLogFile, "Admin %L removed player %L as warden", client, g_iWarden);
  548.            
  549.             RemoveTheWarden();
  550.             Forward_OnWardenRemovedByAdmin(client);
  551.         }
  552.     }
  553.     return Plugin_Handled;
  554. }
  555.  
  556.  
  557. //Set new Warden for Admins
  558. public Action AdminCommand_SetWarden(int client, int args)
  559. {
  560.     if (gc_bPlugin.BoolValue)  //"sm_warden_enable" "1"
  561.     {
  562.         Menu_SetWarden(client);
  563.        
  564.     }
  565.     return Plugin_Handled;
  566. }
  567.  
  568.  
  569. /******************************************************************************
  570.                    EVENTS
  571. ******************************************************************************/
  572.  
  573.  
  574. //Warden Died
  575. public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  576. {
  577.     int client = GetClientOfUserId(event.GetInt("userid"));  
  578.  
  579.    
  580.     if (IsClientWarden(client))  //The Warden is dead
  581.     {
  582.         Forward_OnWardenDeath(client);
  583.         Forward_OnWardenRemoved(client);       
  584.        
  585.        
  586.         CPrintToChatAll("%t %t", "warden_tag" , "warden_dead", client);
  587.         if (gc_bBetterNotes.BoolValue)
  588.         {
  589.             PrintCenterTextAll("%t", "warden_dead_nc", client);
  590.         }
  591.        
  592.         if (gc_bSounds.BoolValue)
  593.         {
  594.             EmitSoundToAllAny(g_sUnWarden);
  595.         }
  596.        
  597.         if (RandomTimer != null)
  598.         KillTimer(RandomTimer);
  599.        
  600.         RandomTimer = null;
  601.         RandomTimer = CreateTimer(gc_fRandomTimer.FloatValue, Timer_ChooseRandom);
  602.    
  603.         g_iWarden = -1;
  604.         DebutQuartier();
  605.     }
  606. }
  607.  
  608.  
  609. //Warden change Team
  610. public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
  611. {
  612.  
  613.     int client = GetClientOfUserId(event.GetInt("userid"));
  614.     if (IsClientWarden(client))  //The Warden changed team
  615.     {
  616.         Forward_OnWardenDeath(client);
  617.         RemoveTheWarden();
  618.        
  619.        
  620.        
  621.         CPrintToChatAll("%t %t", "warden_tag" , "warden_retire", client);
  622.         if (gc_bBetterNotes.BoolValue)
  623.         {
  624.             PrintCenterTextAll("%t", "warden_retire_nc", client);
  625.         }
  626.         DebutQuartier();
  627.     }
  628. }
  629.  
  630.  
  631. //Round Start Post
  632. public void Event_PostRoundStart(Event event, const char[] name, bool dontBroadcast)
  633. {
  634.     if (gc_bPlugin.BoolValue)
  635.     {
  636.         if ((g_iWarden == -1) && gc_bBecomeWarden.BoolValue)
  637.         {
  638.             RandomTimer = CreateTimer(gc_fRandomTimer.FloatValue, Timer_ChooseRandom);
  639.            
  640.             LoopValidClients(i, false, false) if(GetClientTeam(i) == CS_TEAM_CT)
  641.             {
  642.                 CPrintToChat(i, "%t %t", "warden_tag" , "warden_nowarden");
  643.                 FakeClientCommand(i, "sm_unwarden");
  644.                
  645.                 if (gc_bBetterNotes.BoolValue) PrintCenterText(i, "%t", "warden_nowarden_nc");
  646.             }
  647.         }
  648.     }
  649. }
  650.  
  651.  
  652. //Round Start Post
  653. public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
  654. {
  655.     PrecacheSoundAny("involved/quartierlibres.mp3");
  656.     PrecacheSoundAny("involved/tictacs.mp3");
  657.     test = 12;
  658.     pouic = 120;
  659.     KillTimer (timerquartier);
  660.     KillTimer (timerql);
  661.    
  662.    
  663.     if (!gc_bPlugin.BoolValue)
  664.     {
  665.         if (g_iWarden != -1)
  666.         {
  667.             CreateTimer(0.1, Timer_RemoveColor, g_iWarden);
  668.             SetEntityModel(g_iWarden, g_sModelPathPrevious);
  669.             Forward_OnWardenRemoved(g_iWarden);
  670.        
  671.             g_iWarden = -1;
  672.         }
  673.     }
  674.     if (gp_bMyJailBreak)
  675.     {
  676.         char EventDay[64];
  677.         MyJailbreak_GetEventDayName(EventDay);
  678.        
  679.         if (!StrEqual(EventDay, "none", false) || !gc_bStayWarden.BoolValue)
  680.         {
  681.             if (g_iWarden != -1)
  682.             {
  683.                 CreateTimer( 0.1, Timer_RemoveColor, g_iWarden);
  684.                 SetEntityModel(g_iWarden, g_sModelPathPrevious);
  685.                 Forward_OnWardenRemoved(g_iWarden);
  686.                
  687.                 g_iWarden = -1;
  688.             }
  689.         }
  690.     }
  691.     if (g_iWarden != -1)
  692.     {
  693.         if (gc_bModel.BoolValue) SetEntityModel(g_iWarden, g_sModelPathWarden);
  694.     }
  695.     IsLR = false;
  696.    
  697.    
  698. }
  699.  
  700.  
  701. //Round End
  702. public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
  703. {
  704.     IsLR = false;
  705.     FinQuartier();
  706.    
  707. }
  708.  
  709.  
  710. /******************************************************************************
  711.                    FORWARDS LISTEN
  712. ******************************************************************************/
  713.  
  714.  
  715. //Prepare Plugin & modules
  716. public void OnMapStart()
  717. {
  718.     Deputy_OnMapStart();
  719.     Countdown_OnMapStart();
  720.     Math_OnMapStart();
  721.     //HandCuffs_OnMapStart();
  722.     Marker_OnMapStart();
  723.     Reminder_OnMapStart();
  724.     Laser_OnMapStart();
  725.     Painter_OnMapStart();
  726.     Orders_OnMapStart();
  727.     Freedays_OnMapStart();
  728.    
  729.     if (gc_bSounds.BoolValue)
  730.     {
  731.         PrecacheSoundAnyDownload(g_sWarden);
  732.         PrecacheSoundAnyDownload(g_sUnWarden);
  733.     }
  734.     AddFileToDownloadsTable("sound/involved/tictacs.mp3");
  735.     PrecacheSoundAny("involved/tictacs.mp3");
  736.     AddFileToDownloadsTable("sound/involved/quartierlibres.mp3");
  737.     PrecacheSoundAny("involved/quartierlibres.mp3");
  738.    
  739.     g_iVoteCount = 0;
  740.    
  741.     PrecacheModel(g_sModelPathWarden);
  742.     g_iSmokeSprite = PrecacheModel("materials/sprites/steam1.vmt");
  743.     g_iBeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt");
  744.     g_iHaloSprite = PrecacheModel("materials/sprites/glow01.vmt");
  745.     PrecacheSound(SOUND_THUNDER, true);
  746.     FinQuartier();
  747.    
  748. }
  749.  
  750.  
  751. //Prepare client for Plugin & modules
  752. public void OnClientPutInServer(int client)
  753. {
  754.     BulletSparks_OnClientPutInServer(client);
  755.     //HandCuffs_OnClientPutInServer(client);
  756.     BackStab_OnClientPutInServer(client);
  757.     Laser_OnClientPutInServer(client);
  758.     Painter_OnClientPutInServer(client);
  759. }
  760.  
  761.  
  762. //Warden disconnect
  763. public void OnClientDisconnect(int client)
  764. {
  765.  
  766.     if (IsClientWarden(client))
  767.     {
  768.         CPrintToChatAll("%t %t", "warden_tag" , "warden_disconnected", client);
  769.         if (gc_bBetterNotes.BoolValue)
  770.         {
  771.             PrintCenterTextAll("%t", "warden_disconnected_nc", client);
  772.         }
  773.        
  774.         Forward_OnWardenRemoved(client);
  775.         Forward_OnWardenDisconnected(client);
  776.        
  777.         if (gc_bSounds.BoolValue)
  778.         {
  779.             EmitSoundToAllAny(g_sUnWarden);
  780.         }
  781.  
  782.         g_iWarden = -1;
  783.         DebutQuartier();
  784.        
  785.     }
  786.    
  787.     Deputy_OnClientDisconnect(client);
  788.     Painter_OnClientDisconnect(client);
  789.     //HandCuffs_OnClientDisconnect(client);
  790.     Freedays_OnClientDisconnect(client);
  791.    
  792. }
  793.  
  794.  
  795. //Close open timer & reset warden/module
  796. public void OnMapEnd()
  797. {
  798.     if (g_iWarden != -1)
  799.     {
  800.         CreateTimer(0.1, Timer_RemoveColor, g_iWarden);
  801.         Forward_OnWardenRemoved(g_iWarden);
  802.         g_iWarden = -1;
  803.  
  804.     }
  805.    
  806.     Deputy_OnMapEnd();
  807.     Math_OnMapEnd();
  808.     Mute_OnMapEnd();
  809.     Countdown_OnMapEnd();
  810.     Reminder_OnMapEnd();
  811.     //HandCuffs_OnMapEnd();
  812.     Marker_OnMapEnd();
  813.     Painter_OnMapEnd();
  814.     FinQuartier();
  815. }
  816.  
  817.  
  818. //When a last request is available
  819. public int OnAvailableLR(int Announced)
  820. {
  821.     IsLR = true;
  822.    
  823.     GunDropPrevention_OnAvailableLR(Announced);
  824.     Mute_OnAvailableLR(Announced);
  825.     //HandCuffs_OnAvailableLR(Announced);
  826. }
  827.  
  828.  
  829. // Check Keyboard Input for modules
  830. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
  831. {
  832.     if ((IsClientWarden(client) || IsClientDeputy(client)) && gc_bPlugin.BoolValue)
  833.     {
  834.         Marker_OnPlayerRunCmd(client, buttons, impulse, vel, angles, weapon);
  835.         Laser_OnPlayerRunCmd(client, buttons, impulse, vel, angles, weapon);
  836.     }
  837.     Painter_OnPlayerRunCmd(client, buttons, impulse, vel, angles, weapon);
  838.     //HandCuffs_OnPlayerRunCmd(client, buttons, impulse, vel, angles, weapon);
  839.    
  840.     return Plugin_Continue;
  841. }
  842.  
  843.  
  844. /******************************************************************************
  845.                    FUNCTIONS
  846. ******************************************************************************/
  847.  
  848.  
  849. //Set a new warden
  850. void SetTheWarden(int client)
  851. {
  852.     if (gc_bPlugin.BoolValue)
  853.     {
  854.        
  855.         CPrintToChatAll("%t %t", "warden_tag" , "warden_new", client);
  856.         if (gc_bBetterNotes.BoolValue) PrintCenterTextAll("%t", "warden_new_nc", client);
  857.        
  858.         g_iWarden = client;
  859.        
  860.         GetEntPropString(client, Prop_Data, "m_ModelName", g_sModelPathPrevious, sizeof(g_sModelPathPrevious));
  861.         if (gc_bModel.BoolValue)
  862.         {
  863.             SetEntityModel(client, g_sModelPathWarden);
  864.         }
  865.         SetClientListeningFlags(client, VOICE_NORMAL);
  866.         Forward_OnWardenCreated(client);
  867.        
  868.         if (gc_bSounds.BoolValue)
  869.         {
  870.             EmitSoundToAllAny(g_sWarden);
  871.         }
  872.         if (RandomTimer != null)
  873.         KillTimer(RandomTimer);
  874.        
  875.        
  876.         RandomTimer = null;
  877.         FinQuartier();
  878.     }
  879.     else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_disabled");
  880. }
  881.  
  882.  
  883. //Remove the current warden
  884. void RemoveTheWarden()
  885. {
  886.  
  887.     SetEntityModel(g_iWarden, g_sModelPathPrevious);
  888.     if (RandomTimer != null)
  889.         KillTimer(RandomTimer);
  890.    
  891.     RandomTimer = null;
  892.     RandomTimer = CreateTimer(gc_fRandomTimer.FloatValue, Timer_ChooseRandom);
  893.    
  894.     Forward_OnWardenRemoved(g_iWarden);
  895.    
  896.     if (gc_bSounds.BoolValue)
  897.     {
  898.         EmitSoundToAllAny(g_sUnWarden);
  899.     }
  900.    
  901.     g_iVoteCount = 0;
  902.     Format(g_sHasVoted, sizeof(g_sHasVoted), "");
  903.     g_sHasVoted[0] = '\0';
  904.    
  905.  
  906.     g_iWarden = -1;
  907.    
  908.     CreateTimer( 0.1, Timer_RemoveColor, g_iWarden);
  909.     DebutQuartier();
  910. }
  911.  
  912.  
  913. /******************************************************************************
  914.                    MENUS
  915. ******************************************************************************/
  916.  
  917.  
  918. //Admin set (new) Warden menu
  919. void Menu_SetWarden(int client)
  920. {
  921.     char info1[255];
  922.     Menu menu = CreateMenu(Handler_SetWarden);
  923.     Format(info1, sizeof(info1), "%T", "warden_choose", client);
  924.     menu.SetTitle(info1);
  925.     LoopValidClients(i, true, false)
  926.     {
  927.         if (GetClientTeam(i) == CS_TEAM_CT && IsClientWarden(i) == false)
  928.         {
  929.             char userid[11];
  930.             char username[MAX_NAME_LENGTH];
  931.             IntToString(GetClientUserId(i), userid, sizeof(userid));
  932.             Format(username, sizeof(username), "%N", i);
  933.             menu.AddItem(userid, username);
  934.         }
  935.     }
  936.     menu.ExitBackButton = true;
  937.     menu.ExitButton = true;
  938.     menu.Display(client, MENU_TIME_FOREVER);
  939. }
  940.  
  941.  
  942. //Handler set (new) Warden menu with overwrite/remove query
  943. public int Handler_SetWarden(Menu menu, MenuAction action, int client, int Position)
  944. {
  945.     if (action == MenuAction_Select)
  946.     {
  947.         char Item[11];
  948.         menu.GetItem(Position, Item, sizeof(Item));
  949.        
  950.         LoopValidClients(i, true, false)
  951.         {
  952.             if (GetClientTeam(i) == CS_TEAM_CT && IsClientWarden(i) == false)
  953.             {
  954.                 char info4[255], info2[255], info3[255];
  955.                 int userid = GetClientUserId(i);
  956.                 if (userid == StringToInt(Item))
  957.                 {
  958.                     if (g_iWarden != -1)  // if (g_iWarden != -1)
  959.                     {
  960.                         g_iTempWarden[client] = userid;
  961.                         Menu menu1 = CreateMenu(Handler_SetWardenOverwrite);
  962.                         Format(info4, sizeof(info4), "%T", "warden_remove", client);
  963.                         menu1.SetTitle(info4);
  964.                         Format(info3, sizeof(info3), "%T", "warden_yes", client);
  965.                         Format(info2, sizeof(info2), "%T", "warden_no", client);
  966.                         menu1.AddItem("1", info3);
  967.                         menu1.AddItem("0", info2);
  968.                         menu1.ExitBackButton = true;
  969.                         menu1.ExitButton = true;
  970.                         menu1.Display(client, MENU_TIME_FOREVER);
  971.                     }
  972.                     else
  973.                     {
  974.                         SetTheWarden(i);
  975.                         Forward_OnWardenCreatedByAdmin(i);
  976.                     }
  977.                 }
  978.             }
  979.         }
  980.     }
  981.     else if (action == MenuAction_Cancel)
  982.     {
  983.         if (Position == MenuCancel_ExitBack)
  984.         {
  985.             FakeClientCommand(client, "sm_menu");
  986.         }
  987.     }
  988.     else if (action == MenuAction_End)
  989.     {
  990.         delete menu;
  991.     }
  992. }
  993.  
  994.  
  995. //Handler overwrite/remove query menu
  996. public int Handler_SetWardenOverwrite(Menu menu, MenuAction action, int client, int Position)
  997. {
  998.     if (action == MenuAction_Select)
  999.     {
  1000.         char Item[11];
  1001.         menu.GetItem(Position, Item, sizeof(Item));
  1002.         int choice = StringToInt(Item);
  1003.         if (choice == 1)
  1004.         {
  1005.             int newwarden = GetClientOfUserId(g_iTempWarden[client]);
  1006.             if (g_iWarden != -1)CPrintToChatAll("%t %t", "warden_tag" , "warden_removed", client, g_iWarden);
  1007.            
  1008.             RemoveTheWarden();
  1009.             SetTheWarden(newwarden);
  1010.             Forward_OnWardenCreatedByAdmin(newwarden);
  1011.             if(gp_bMyJailBreak) if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sMyJBLogFile, "Admin %L kick player %L warden and set %L as new", client, g_iWarden, newwarden);
  1012.         }
  1013.         if (g_bMenuClose != null)
  1014.         {
  1015.             if (!g_bMenuClose)
  1016.             {
  1017.                 FakeClientCommand(client, "sm_menu");
  1018.             }
  1019.         }
  1020.     }
  1021.     else if (action == MenuAction_Cancel)
  1022.     {
  1023.         if (Position == MenuCancel_ExitBack)
  1024.         {
  1025.             FakeClientCommand(client, "sm_menu");
  1026.         }
  1027.     }
  1028.     else if (action == MenuAction_End)
  1029.     {
  1030.         delete menu;
  1031.     }
  1032. }
  1033.  
  1034.  
  1035. /******************************************************************************
  1036.                    TIMER
  1037. ******************************************************************************/
  1038.  
  1039.  
  1040. //Choose a random Warden after a defined time
  1041. public Action Timer_ChooseRandom(Handle timer, Handle pack)
  1042. {
  1043.     if (gc_bPlugin.BoolValue)
  1044.     {
  1045.         if (g_iWarden == -1)
  1046.         {
  1047.             if (gc_bChooseRandom.BoolValue)
  1048.             {
  1049.                 int i = GetRandomPlayer(CS_TEAM_CT);
  1050.                 if (i > 0)
  1051.                 {
  1052.                     CPrintToChatAll("%t %t", "warden_tag", "warden_randomwarden");
  1053.                     SetTheWarden(i);
  1054.                 }
  1055.             }
  1056.         }
  1057.     }
  1058.     if (RandomTimer != null)
  1059.         KillTimer(RandomTimer);
  1060.            
  1061.     RandomTimer = null;
  1062. }
  1063.  
  1064. public Action quartier_libre(Handle Timer)
  1065. {
  1066.    
  1067.    
  1068.     PrintHintTextToAll("<font face='Arial' color='#d79756' style='italic' > Ce Sera Quartier Libre </color></style>dans </font> <font color='#4eee37'>                                                                       %d </color> <font color='#00614c'> Secondes </font></color>", test-2);
  1069.     pouic--;
  1070.    
  1071.     if (pouic == 120 || pouic == 110 || pouic == 100 || pouic == 90 || pouic == 80 || pouic == 70 || pouic == 60 || pouic == 50 || pouic == 40 || pouic == 30 || pouic == 20 || pouic == 10 )
  1072.     {
  1073.         test--;
  1074.         if (test == 2)
  1075.         {
  1076.             KillTimer (timerql);
  1077.             KillTimer (timerquartier);
  1078.             test=12;
  1079.            
  1080.         }
  1081.         if (test<0)
  1082.         {
  1083.             KillTimer (timerql);
  1084.             KillTimer (timerquartier);
  1085.             test=12;
  1086.             FinQuartier();
  1087.         }
  1088.        
  1089.     }
  1090.     if (pouic<0)
  1091.     {
  1092.         KillTimer (timerql);
  1093.         KillTimer (timerquartier);
  1094.         pouic=120;
  1095.         FinQuartier(); 
  1096.     }
  1097.    
  1098.    
  1099. }
  1100. public Action QL(Handle Timer)
  1101. {
  1102.     KillTimer (timerql);
  1103.     PrintCenterTextAll("Quartier Libre ! Vous pouvez reprendre les ordres à tout moments.");
  1104.     test = 12;
  1105.     pouic = 120;
  1106.     EmitSoundToAllAny("involved/quartierlibres.mp3");
  1107.     return Plugin_Continue;
  1108.    
  1109. }
  1110.  
  1111.  
  1112. /******************************************************************************
  1113.                    STOCKS
  1114. ******************************************************************************/
  1115.  
  1116.  
  1117. stock bool IsClientWarden(int client)
  1118. {
  1119.     if (client != g_iWarden)
  1120.     {
  1121.         return false;
  1122.     }
  1123.     return true;
  1124. }
  1125.  
  1126.  
  1127. /******************************************************************************
  1128.                    NATIVES
  1129. ******************************************************************************/
  1130.  
  1131.  
  1132. //Register Natives
  1133. public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max)
  1134. {
  1135.     CreateNative("warden_exist", Native_ExistWarden);
  1136.     CreateNative("warden_iswarden", Native_IsWarden);
  1137.     CreateNative("warden_set", Native_SetWarden);
  1138.     CreateNative("warden_removed", Native_RemoveWarden);
  1139.     CreateNative("warden_get", Native_GetWarden);
  1140.     //CreateNative("warden_getlast", Native_GetLastWarden);
  1141.    
  1142.     CreateNative("warden_deputy_exist", Native_ExistDeputy);
  1143.     CreateNative("warden_deputy_isdeputy", Native_IsDeputy);
  1144.     CreateNative("warden_deputy_set", Native_SetDeputy);
  1145.     CreateNative("warden_deputy_removed", Native_RemoveDeputy);
  1146.     CreateNative("warden_deputy_get", Native_GetDeputy);
  1147.     CreateNative("warden_deputy_getlast", Native_GetLastDeputy);
  1148.    
  1149.     CreateNative("warden_handcuffs_givepaperclip", Native_GivePaperClip);
  1150.     CreateNative("warden_handcuffs_iscuffed", Native_IsClientCuffed);
  1151.    
  1152.     CreateNative("warden_freeday_set", Native_GiveFreeday);
  1153.     CreateNative("warden_freeday_has", Native_HasClientFreeday);
  1154.    
  1155.     RegPluginLibrary("warden");
  1156.     return APLRes_Success;
  1157. }
  1158.  
  1159.  
  1160. //Booleans Exist Warden
  1161. public int Native_ExistWarden(Handle plugin, int argc)
  1162. {
  1163.     if (g_iWarden == -1)
  1164.     {
  1165.         return false;
  1166.     }
  1167.     return true;
  1168. }
  1169.  
  1170.  
  1171. //Booleans Is Client Warden
  1172. public int Native_IsWarden(Handle plugin, int argc)
  1173. {
  1174.     int client = GetNativeCell(1);
  1175.    
  1176.     if (!IsClientInGame(client) && !IsClientConnected(client))
  1177.         ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
  1178.    
  1179.     if (IsClientWarden(client))
  1180.         return true;
  1181.    
  1182.     return false;
  1183. }
  1184.  
  1185.  
  1186. //Set Client as Warden
  1187. public int Native_SetWarden(Handle plugin, int argc)
  1188. {
  1189.     int client = GetNativeCell(1);
  1190.    
  1191.     if (!IsClientInGame(client) && !IsClientConnected(client))
  1192.         ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
  1193.    
  1194.     if (g_iWarden == -1)
  1195.     {
  1196.         SetTheWarden(client);
  1197.         FinQuartier();
  1198.     }
  1199. }
  1200.  
  1201.  
  1202. //Remove current Warden
  1203. public int Native_RemoveWarden(Handle plugin, int argc)
  1204. {
  1205.     int client = GetNativeCell(1);
  1206.    
  1207.     if (!IsClientInGame(client) && !IsClientConnected(client))
  1208.         ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
  1209.    
  1210.     if (IsClientWarden(client))
  1211.     {  
  1212.         RemoveTheWarden();
  1213.         DebutQuartier();
  1214.     }
  1215. }
  1216.  
  1217.  
  1218. //Get Warden Client Index
  1219. public int Native_GetWarden(Handle plugin, int argc)
  1220. {
  1221.     return g_iWarden;
  1222. }
  1223.  
  1224.  
  1225. //Get last wardens Client Index
  1226. //public int Native_GetLastWarden(Handle plugin, int argc)
  1227. //{
  1228. // 
  1229. //}
  1230.  
  1231.  
  1232. /******************************************************************************
  1233.                    FORWARDS CALL
  1234. ******************************************************************************/
  1235.  
  1236.  
  1237. //New Warden was set (will fire all time - *ByUser *ByAdmin ...)
  1238. void Forward_OnWardenCreated(int client)
  1239. {
  1240.     Call_StartForward(gF_OnWardenCreated);
  1241.     Call_PushCell(client);
  1242.     Call_Finish();
  1243.    
  1244.     Deputy_OnWardenCreation(client);
  1245.     Color_OnWardenCreation(client);
  1246.     Laser_OnWardenCreation(client);
  1247.     //HandCuffs_OnWardenCreation(client);
  1248. }
  1249.  
  1250. void FinQuartier()
  1251. {
  1252.    
  1253.    
  1254.     test = 12;
  1255.     pouic = 120;
  1256.     KillTimer (timerql);
  1257.     KillTimer (timerquartier);
  1258.    
  1259.    
  1260.    
  1261.    
  1262. }
  1263.  
  1264. void DebutQuartier ()
  1265. {
  1266.    
  1267.    
  1268.     test = 12;
  1269.     pouic = 120;
  1270.     timerql = CreateTimer(0.1, quartier_libre, _, TIMER_REPEAT);
  1271.     timerquartier = CreateTimer(10.0, QL);
  1272.     EmitSoundToAllAny("involved/tictacs.mp3");
  1273.    
  1274.    
  1275.    
  1276.    
  1277. }
  1278.  
  1279. //New Warden was set (will only fire on set ByUser)
  1280. void Forward_OnWardenCreatedByUser(int client)
  1281. {
  1282.     Call_StartForward(gF_OnWardenCreatedByUser);
  1283.     Call_PushCell(client);
  1284.     Call_Finish();
  1285. }
  1286.  
  1287.  
  1288. //New Warden was set (will only fire on set ByAdmin)
  1289. void Forward_OnWardenCreatedByAdmin(int client)
  1290. {
  1291.     Call_StartForward(gF_OnWardenCreatedByAdmin);
  1292.     Call_PushCell(client);
  1293.     Call_Finish();
  1294. }
  1295.  
  1296.  
  1297. //Warden was removed (will fire all time - *BySelf *ByAdmin *Death ...)
  1298. void Forward_OnWardenRemoved(int client)
  1299. {
  1300.     Call_StartForward(gF_OnWardenRemoved);
  1301.     Call_PushCell(client);
  1302.     Call_Finish();
  1303.    
  1304.     Deputy_OnWardenRemoved(client);
  1305.     Marker_OnWardenRemoved();
  1306.     Color_OnWardenRemoved(client);
  1307.     Laser_OnWardenRemoved(client);
  1308.     Painter_OnWardenRemoved(client);
  1309.     //HandCuffs_OnWardenRemoved(client);
  1310. }
  1311.  
  1312.  
  1313. //Warden was removed (will only fire on ByAdmin)
  1314. void Forward_OnWardenRemovedByAdmin(int client)
  1315. {
  1316.     Call_StartForward(gF_OnWardenRemovedByAdmin);
  1317.     Call_PushCell(client);
  1318.     Call_Finish();
  1319. }
  1320.  
  1321.  
  1322. //Warden was removed (will only fire on BySelf)
  1323. void Forward_OnWardenRemovedBySelf(int client)
  1324. {
  1325.     Call_StartForward(gF_OnWardenRemovedBySelf);
  1326.     Call_PushCell(client);
  1327.     Call_Finish();
  1328.    
  1329.     Deputy_OnWardenRemovedBySelf(client);
  1330. }
  1331.  
  1332.  
  1333. //Warden was removed (will only fire on Disconnect)
  1334. void Forward_OnWardenDisconnected(int client)
  1335. {
  1336.     Call_StartForward(gF_OnWardenDisconnected);
  1337.     Call_PushCell(client);
  1338.     Call_Finish();
  1339. }
  1340.  
  1341.  
  1342. //Warden was removed (will only fire on Death)
  1343. void Forward_OnWardenDeath(int client)
  1344. {
  1345.     Call_StartForward(gF_OnWardenDeath);
  1346.     Call_PushCell(client);
  1347.     Call_Finish();
  1348. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement