Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.98 KB | None | 0 0
  1. /*
  2. * MyJailbreak - Zombie Event Day 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 <colors>
  34. #include <autoexecconfig>
  35. #include <hosties>
  36. #include <lastrequest>
  37. #include <warden>
  38. #include <smartjaildoors>
  39. #include <mystocks>
  40. #include <myjailbreak>
  41. #include <store>
  42.  
  43. #include <CustomPlayerSkins>
  44.  
  45.  
  46. //Compiler Options
  47. #pragma semicolon 1
  48. #pragma newdecls required
  49.  
  50.  
  51. //Booleans
  52. bool IsZombie;
  53. bool StartZombie;
  54.  
  55. //Console Variables
  56. ConVar gc_bPlugin;
  57. ConVar gc_bSetW;
  58. ConVar gc_bSetA;
  59. ConVar gc_bSetABypassCooldown;
  60. ConVar gc_iCooldownStart;
  61. ConVar gc_bVote;
  62. ConVar gc_iRoundTime;
  63. ConVar gc_fBeaconTime;
  64. ConVar gc_iCooldownDay;
  65. ConVar gc_iFreezeTime;
  66. ConVar gc_bSpawnCell;
  67. ConVar gc_bAmmo;
  68. ConVar gc_iZombieHP;
  69. ConVar gc_iZombieHPincrease;
  70. ConVar gc_iHumanHP;
  71. ConVar gc_bDark;
  72. ConVar gc_bVision;
  73. ConVar gc_bGlow;
  74. ConVar gc_iGlowMode;
  75. ConVar gc_sModelPathZombie;
  76. ConVar gc_bSounds;
  77. ConVar gc_sSoundStartPath;
  78. ConVar gc_bOverlays;
  79. ConVar gc_sOverlayStartPath;
  80. ConVar g_iMPRoundTime;
  81. ConVar g_sOldSkyName;
  82. ConVar gc_iRounds;
  83. ConVar gc_sCustomCommandVote;
  84. ConVar gc_sCustomCommandSet;
  85. ConVar gc_sAdminFlag;
  86. ConVar gc_bAllowLR;
  87. ConVar gc_fKnockbackAmount;
  88.  
  89.  
  90. //Extern Convars
  91. ConVar g_iTerrorForLR;
  92.  
  93.  
  94. //Integers
  95. int g_iOldRoundTime;
  96. int g_iFreezeTime;
  97. int g_iCoolDown;
  98. int g_iVoteCount;
  99. int g_iRound;
  100. int g_iMaxRound;
  101. int g_iTsLR;
  102.  
  103.  
  104. //Handles
  105. Handle FreezeTimer;
  106. Handle BeaconTimer;
  107. Handle ZombieMenu;
  108.  
  109.  
  110. //floats
  111. float g_fPos[3];
  112.  
  113.  
  114. //Strings
  115. char g_sModelPathZombie[256];
  116. char g_sHasVoted[1500];
  117. char g_sSoundStartPath[256];
  118. char g_sSkyName[256];
  119. char g_sEventsLogFile[PLATFORM_MAX_PATH];
  120. char g_sAdminFlag[32];
  121. char g_sModelPathPrevious[MAXPLAYERS+1][256];
  122. char g_sOverlayStartPath[256];
  123.  
  124.  
  125. //Info
  126. public Plugin myinfo = {
  127. name = "MyJailbreak - Zombie",
  128. author = "shanapu",
  129. description = "Event Day for Jailbreak Server",
  130. version = MYJB_VERSION,
  131. url = MYJB_URL_LINK
  132. };
  133.  
  134.  
  135. //Start
  136. public void OnPluginStart()
  137. {
  138. // Translation
  139. LoadTranslations("MyJailbreak.Warden.phrases");
  140. LoadTranslations("MyJailbreak.Zombie.phrases");
  141.  
  142.  
  143. //Client Commands
  144. RegConsoleCmd("sm_setzombie", Command_SetZombie, "Allows the Admin or Warden to set Zombie as next round");
  145. RegConsoleCmd("sm_zombie", Command_VoteZombie, "Allows players to vote for a Zombie");
  146.  
  147.  
  148. //AutoExecConfig
  149. AutoExecConfig_SetFile("Zombie", "MyJailbreak/EventDays");
  150. AutoExecConfig_SetCreateFile(true);
  151.  
  152. AutoExecConfig_CreateConVar("sm_zombie_version", MYJB_VERSION, "The version of this MyJailbreak SourceMod plugin", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  153. gc_bPlugin = AutoExecConfig_CreateConVar("sm_zombie_enable", "1", "0 - disabled, 1 - enable this MyJailbreak SourceMod plugin", _, true, 0.0, true, 1.0);
  154. gc_sCustomCommandVote = AutoExecConfig_CreateConVar("sm_zombie_cmds_vote", "zd, zomb, z", "Set your custom chat command for Event voting(!zombie (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  155. gc_sCustomCommandSet = AutoExecConfig_CreateConVar("sm_zombie_cmds_set", "sz, szd, szombie", "Set your custom chat command for set Event(!setzombie (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  156. gc_bSetW = AutoExecConfig_CreateConVar("sm_zombie_warden", "1", "0 - disabled, 1 - allow warden to set zombie round", _, true, 0.0, true, 1.0);
  157. gc_bSetA = AutoExecConfig_CreateConVar("sm_zombie_admin", "1", "0 - disabled, 1 - allow admin/vip to set zombie round", _, true, 0.0, true, 1.0);
  158. gc_sAdminFlag = AutoExecConfig_CreateConVar("sm_zombie_flag", "g", "Set flag for admin/vip to set this Event Day.");
  159. gc_bVote = AutoExecConfig_CreateConVar("sm_zombie_vote", "1", "0 - disabled, 1 - allow player to vote for zombie", _, true, 0.0, true, 1.0);
  160. gc_bSpawnCell = AutoExecConfig_CreateConVar("sm_zombie_spawn", "0", "0 - T teleport to CT spawn, 1 - cell doors auto open", _, true, 0.0, true, 1.0);
  161. gc_bAmmo = AutoExecConfig_CreateConVar("sm_zombie_ammo", "0", "0 - disabled, 1 - enable infinty ammo (with reload) for humans", _, true, 0.0, true, 1.0);
  162. gc_iRounds = AutoExecConfig_CreateConVar("sm_zombie_rounds", "1", "Rounds to play in a row", _, true, 1.0);
  163. gc_iRoundTime = AutoExecConfig_CreateConVar("sm_zombie_roundtime", "5", "Round time in minutes for a single zombie round", _, true, 1.0);
  164. gc_fBeaconTime = AutoExecConfig_CreateConVar("sm_zombie_beacon_time", "240", "Time in seconds until the beacon turned on (set to 0 to disable)", _, true, 0.0);
  165. gc_iFreezeTime = AutoExecConfig_CreateConVar("sm_zombie_freezetime", "35", "Time in seconds the zombies freezed", _, true, 0.0);
  166. gc_iZombieHP = AutoExecConfig_CreateConVar("sm_zombie_zombie_hp", "4000", "HP the Zombies got on Spawn", _, true, 1.0);
  167. gc_iZombieHPincrease = AutoExecConfig_CreateConVar("sm_zombie_zombie_hp_extra", "1000", "HP the Zombies get additional per extra Human", _, true, 1.0);
  168. gc_iHumanHP = AutoExecConfig_CreateConVar("sm_zombie_human_hp", "65", "HP the Humans got on Spawn", _, true, 1.0);
  169. gc_bDark = AutoExecConfig_CreateConVar("sm_zombie_dark", "1", "0 - disabled, 1 - enable Map Darkness", _, true, 0.0, true, 1.0);
  170. gc_bGlow = AutoExecConfig_CreateConVar("sm_zombie_glow", "1", "0 - disabled, 1 - enable Glow effect for humans", _, true, 0.0, true, 1.0);
  171. gc_iGlowMode = AutoExecConfig_CreateConVar("sm_zombie_glow_mode", "1", "1 - human contours with wallhack for zombies, 2 - human glow effect without wallhack for zombies", _, true, 1.0, true, 2.0);
  172. gc_bVision = AutoExecConfig_CreateConVar("sm_zombie_vision", "1", "0 - disabled, 1 - enable NightVision View for Zombies", _, true, 0.0, true, 1.0);
  173. gc_fKnockbackAmount = AutoExecConfig_CreateConVar("sm_zombie_knockback", "20.0", "Force of the knockback when shot at. Zombies only", _, true, 1.0, true, 100.0);
  174. gc_iCooldownDay = AutoExecConfig_CreateConVar("sm_zombie_cooldown_day", "3", "Rounds cooldown after a event until event can be start again", _, true, 0.0);
  175. gc_iCooldownStart = AutoExecConfig_CreateConVar("sm_zombie_cooldown_start", "3", "Rounds until event can be start after mapchange.", _, true, 0.0);
  176. gc_bSetABypassCooldown = AutoExecConfig_CreateConVar("sm_zombie_cooldown_admin", "1", "0 - disabled, 1 - ignore the cooldown when admin/vip set zombie round", _, true, 0.0, true, 1.0);
  177. gc_bSounds = AutoExecConfig_CreateConVar("sm_zombie_sounds_enable", "1", "0 - disabled, 1 - enable sounds", _, true, 0.0, true, 1.0);
  178. gc_sSoundStartPath = AutoExecConfig_CreateConVar("sm_zombie_sounds_start", "music/MyJailbreak/zombie.mp3", "Path to the soundfile which should be played for a start.");
  179. gc_bOverlays = AutoExecConfig_CreateConVar("sm_zombie_overlays_enable", "1", "0 - disabled, 1 - enable overlays", _, true, 0.0, true, 1.0);
  180. gc_sOverlayStartPath = AutoExecConfig_CreateConVar("sm_zombie_overlays_start", "overlays/MyJailbreak/zombie" , "Path to the start Overlay DONT TYPE .vmt or .vft");
  181. gc_sModelPathZombie = AutoExecConfig_CreateConVar("sm_zombie_model", "models/player/custom_player/zombie/revenant/revenant_v2.mdl", "Path to the model for zombies.");
  182. gc_bAllowLR = AutoExecConfig_CreateConVar("sm_zombie_allow_lr", "0" , "0 - disabled, 1 - enable LR for last round and end eventday", _, true, 0.0, true, 1.0);
  183.  
  184. AutoExecConfig_ExecuteFile();
  185. AutoExecConfig_CleanFile();
  186.  
  187.  
  188.  
  189.  
  190. //Hooks
  191. HookEvent("round_start", Event_RoundStart);
  192. HookEvent("round_end", Event_RoundEnd);
  193. HookEvent("player_hurt", Event_PlayerHurt);
  194. HookConVarChange(gc_sOverlayStartPath, OnSettingChanged);
  195. HookConVarChange(gc_sModelPathZombie, OnSettingChanged);
  196. HookConVarChange(gc_sSoundStartPath, OnSettingChanged);
  197. HookConVarChange(gc_sAdminFlag, OnSettingChanged);
  198.  
  199.  
  200. //FindConVar
  201. g_iMPRoundTime = FindConVar("mp_roundtime");
  202. gc_sOverlayStartPath.GetString(g_sOverlayStartPath , sizeof(g_sOverlayStartPath));
  203. gc_sModelPathZombie.GetString(g_sModelPathZombie, sizeof(g_sModelPathZombie));
  204. gc_sSoundStartPath.GetString(g_sSoundStartPath, sizeof(g_sSoundStartPath));
  205. gc_sAdminFlag.GetString(g_sAdminFlag , sizeof(g_sAdminFlag));
  206.  
  207. SetLogFile(g_sEventsLogFile, "Events", "MyJailbreak");
  208.  
  209. CreateTimer(3.0, GiveHealth, _, TIMER_REPEAT);
  210. }
  211.  
  212. public Action GiveHealth(Handle timer, int client)
  213. {
  214.  
  215.  
  216.  
  217. for(int i = 1; i <= MaxClients; i++)
  218. {
  219. if (IsPlayerAlive(i) && (GetClientTeam(i) == 3))
  220. {
  221.  
  222. int oldHP = GetClientHealth(i);
  223. int newHP = oldHP + (0);
  224. SetEntityHealth(i, newHP);
  225. }
  226. }
  227. return Plugin_Continue;
  228.  
  229.  
  230. }
  231.  
  232.  
  233. //ConVarChange for Strings
  234. public int OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
  235. {
  236. if (convar == gc_sModelPathZombie)
  237. {
  238. strcopy(g_sModelPathZombie, sizeof(g_sModelPathZombie), newValue);
  239. PrecacheModel(g_sModelPathZombie);
  240. }
  241. else if (convar == gc_sAdminFlag)
  242. {
  243. strcopy(g_sAdminFlag, sizeof(g_sAdminFlag), newValue);
  244. }
  245. else if (convar == gc_sOverlayStartPath)
  246. {
  247. strcopy(g_sOverlayStartPath, sizeof(g_sOverlayStartPath), newValue);
  248. if (gc_bOverlays.BoolValue) PrecacheDecalAnyDownload(g_sOverlayStartPath);
  249. }
  250. else if (convar == gc_sSoundStartPath)
  251. {
  252. strcopy(g_sSoundStartPath, sizeof(g_sSoundStartPath), newValue);
  253. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundStartPath);
  254. }
  255. }
  256.  
  257.  
  258. //Initialize Plugin
  259. public void OnConfigsExecuted()
  260. {
  261. g_iFreezeTime = gc_iFreezeTime.IntValue;
  262. g_iCoolDown = gc_iCooldownStart.IntValue + 1;
  263. g_iMaxRound = gc_iRounds.IntValue;
  264.  
  265. //FindConVar
  266. g_iTerrorForLR = FindConVar("sm_hosties_lr_ts_max");
  267.  
  268. //Set custom Commands
  269. int iCount = 0;
  270. char sCommands[128], sCommandsL[12][32], sCommand[32];
  271.  
  272. //Vote
  273. gc_sCustomCommandVote.GetString(sCommands, sizeof(sCommands));
  274. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  275. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  276.  
  277. for (int i = 0; i < iCount; i++)
  278. {
  279. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  280. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  281. RegConsoleCmd(sCommand, Command_VoteZombie, "Allows players to vote for a Zombie");
  282. }
  283.  
  284. //Set
  285. gc_sCustomCommandSet.GetString(sCommands, sizeof(sCommands));
  286. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  287. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  288.  
  289. for (int i = 0; i < iCount; i++)
  290. {
  291. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  292. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  293. RegConsoleCmd(sCommand, Command_SetZombie, "Allows the Admin or Warden to set Zombie as next round");
  294. }
  295. }
  296.  
  297.  
  298. /******************************************************************************
  299. COMMANDS
  300. ******************************************************************************/
  301.  
  302.  
  303. //Admin & Warden set Event
  304. public Action Command_SetZombie(int client, int args)
  305. {
  306. if (gc_bPlugin.BoolValue)
  307. {
  308. if (client == 0)
  309. {
  310. StartNextRound();
  311. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event zombie was started by groupvoting");
  312. }
  313. else if (warden_iswarden(client))
  314. {
  315. if (gc_bSetW.BoolValue)
  316. {
  317. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  318. {
  319. char EventDay[64];
  320. MyJailbreak_GetEventDayName(EventDay);
  321.  
  322. if (StrEqual(EventDay, "none", false))
  323. {
  324. if (g_iCoolDown == 0)
  325. {
  326. StartNextRound();
  327. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by warden %L", client);
  328. }
  329. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  330. }
  331. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  332. }
  333. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  334. }
  335. else CReplyToCommand(client, "%t %t", "warden_tag" , "zombie_setbywarden");
  336. }
  337. else if (CheckVipFlag(client, g_sAdminFlag))
  338. {
  339. if (gc_bSetA.BoolValue)
  340. {
  341. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  342. {
  343. char EventDay[64];
  344. MyJailbreak_GetEventDayName(EventDay);
  345.  
  346. if (StrEqual(EventDay, "none", false))
  347. {
  348. if ((g_iCoolDown == 0) || gc_bSetABypassCooldown.BoolValue)
  349. {
  350. StartNextRound();
  351. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by admin %L", client);
  352. }
  353. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  354. }
  355. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  356. }
  357. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  358. }
  359. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_setbyadmin");
  360. }
  361. else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_notwarden");
  362. }
  363. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_disabled");
  364. return Plugin_Handled;
  365. }
  366.  
  367.  
  368. //Voting for Event
  369. public Action Command_VoteZombie(int client, int args)
  370. {
  371. char steamid[64];
  372. GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
  373.  
  374. if (gc_bPlugin.BoolValue)
  375. {
  376. if (gc_bVote.BoolValue)
  377. {
  378. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  379. {
  380. char EventDay[64];
  381. MyJailbreak_GetEventDayName(EventDay);
  382.  
  383. if (StrEqual(EventDay, "none", false))
  384. {
  385. if (g_iCoolDown == 0)
  386. {
  387. if (StrContains(g_sHasVoted, steamid, true) == -1)
  388. {
  389. int playercount = (GetClientCount(true) / 2);
  390. g_iVoteCount++;
  391. int Missing = playercount - g_iVoteCount + 1;
  392. Format(g_sHasVoted, sizeof(g_sHasVoted), "%s, %s", g_sHasVoted, steamid);
  393.  
  394. if (g_iVoteCount > playercount)
  395. {
  396. StartNextRound();
  397. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by voting");
  398. }
  399. else CPrintToChatAll("%t %t", "zombie_tag" , "zombie_need", Missing, client);
  400. }
  401. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_voted");
  402. }
  403. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  404. }
  405. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  406. }
  407. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  408. }
  409. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_voting");
  410. }
  411. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_disabled");
  412. return Plugin_Handled;
  413. }
  414.  
  415.  
  416. /******************************************************************************
  417. EVENTS
  418. ******************************************************************************/
  419.  
  420.  
  421. //Round start
  422. public void Event_RoundStart(Event event, char[] name, bool dontBroadcast)
  423. {
  424. if (StartZombie || IsZombie)
  425. {
  426. SetCvar("sm_hosties_lr", 0);
  427. SetCvar("sm_warden_enable", 0);
  428. SetCvarString("sv_skyname", "cs_baggage_skybox_");
  429. SetCvar("sm_weapons_t", 1);
  430. SetCvar("sm_weapons_ct", 0);
  431. if (gc_bAmmo.BoolValue) SetCvar("sv_infinite_ammo", 2);
  432. SetCvar("sm_menu_enable", 0);
  433. MyJailbreak_SetEventDayPlanned(false);
  434. MyJailbreak_SetEventDayRunning(true);
  435. IsZombie = true;
  436. g_iRound++;
  437. StartZombie = false;
  438. SJD_OpenDoors();
  439.  
  440. if (gc_fBeaconTime.FloatValue > 0.0) BeaconTimer = CreateTimer(gc_fBeaconTime.FloatValue, Timer_BeaconOn, TIMER_FLAG_NO_MAPCHANGE);
  441.  
  442. int RandomCT = 0;
  443.  
  444. LoopClients(client)
  445. {
  446. if (GetClientTeam(client) == CS_TEAM_CT)
  447. {
  448. RandomCT = client;
  449. break;
  450. }
  451. }
  452. if (RandomCT)
  453. {
  454. GetClientAbsOrigin(RandomCT, g_fPos);
  455.  
  456. g_fPos[2] = g_fPos[2] + 6;
  457.  
  458. if (g_iRound > 0)
  459. {
  460. LoopClients(client)
  461. {
  462. CreateInfoPanel(client);
  463. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 2, 4, true);
  464. SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
  465.  
  466. if (GetClientTeam(client) == CS_TEAM_CT)
  467. {
  468. SetEntityMoveType(client, MOVETYPE_NONE);
  469. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 0.0);
  470.  
  471. int zombieHP = gc_iZombieHP.IntValue;
  472. int difference = (GetAliveTeamCount(CS_TEAM_T) - GetAliveTeamCount(CS_TEAM_CT));
  473.  
  474. if (difference > 0) zombieHP = zombieHP + (gc_iZombieHPincrease.IntValue * difference);
  475.  
  476. SetEntityHealth(client, zombieHP);
  477.  
  478. StripAllPlayerWeapons(client);
  479. GivePlayerItem(client, "weapon_knife");
  480. }
  481. if (GetClientTeam(client) == CS_TEAM_T)
  482. {
  483. SetEntityHealth(client, gc_iHumanHP.IntValue);
  484. }
  485. if (!gc_bSpawnCell.BoolValue || (gc_bSpawnCell.BoolValue && (SJD_IsCurrentMapConfigured() != true))) //spawn Terrors to CT Spawn
  486. {
  487. TeleportEntity(client, g_fPos, NULL_VECTOR, NULL_VECTOR);
  488. }
  489. }
  490.  
  491. CreateTimer (1.1, Timer_SetModel);
  492.  
  493. //enable lr on last round
  494. g_iTsLR = GetAliveTeamCount(CS_TEAM_T);
  495.  
  496. if (gc_bAllowLR.BoolValue)
  497. {
  498. if ((g_iRound == g_iMaxRound) && (g_iTsLR > g_iTerrorForLR.IntValue))
  499. {
  500. SetCvar("sm_hosties_lr", 1);
  501. }
  502. }
  503. }
  504. g_iFreezeTime--;
  505. FreezeTimer = CreateTimer(1.0, Timer_StartEvent, _, TIMER_REPEAT);
  506.  
  507. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_rounds", g_iRound, g_iMaxRound);
  508. }
  509. }
  510. else
  511. {
  512. char EventDay[64];
  513. MyJailbreak_GetEventDayName(EventDay);
  514.  
  515. if (!StrEqual(EventDay, "none", false))
  516. {
  517. g_iCoolDown = gc_iCooldownDay.IntValue + 1;
  518. }
  519. else if (g_iCoolDown > 0) g_iCoolDown--;
  520. }
  521. }
  522.  
  523.  
  524. //Round End
  525. public void Event_RoundEnd(Event event, char[] name, bool dontBroadcast)
  526. {
  527. int winner = event.GetInt("winner");
  528.  
  529. if (IsZombie)
  530. {
  531. LoopValidClients(client, false, true)
  532. {
  533. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 0, 4, true);
  534. if (gc_bGlow.BoolValue) UnhookGlow(client);
  535. SetEntProp(client, Prop_Send, "m_bNightVisionOn", 0);
  536. }
  537.  
  538. delete FreezeTimer;
  539. delete BeaconTimer;
  540.  
  541.  
  542. if (winner == 2)
  543. {
  544. PrintCenterTextAll("%t", "zombie_twin_nc");
  545. LoopValidClients(i, false, true) // (i, false, true) only surviver get credits - (i, false, true) Dead player get credits too
  546. {
  547. if (GetClientTeam(i) == CS_TEAM_T)
  548. {
  549. Store_SetClientCredits(i, Store_GetClientCredits(i) + 10);
  550. }
  551. }
  552. }
  553. if (winner == 3)
  554. {
  555. PrintCenterTextAll("%t", "zombie_ctwin_nc");
  556. LoopValidClients(i, false, true) // (i, false, true) only surviver get credits - (i, false, true) Dead player get credits too
  557. {
  558. if (GetClientTeam(i) == CS_TEAM_CT)
  559. {
  560. Store_SetClientCredits(i, Store_GetClientCredits(i) + 10);
  561. }
  562. }
  563. }
  564. if (g_iRound == g_iMaxRound)
  565. {
  566. IsZombie = false;
  567. StartZombie = false;
  568. g_iRound = 0;
  569. Format(g_sHasVoted, sizeof(g_sHasVoted), "");
  570. SetCvar("sm_hosties_lr", 1);
  571. SetCvar("sm_weapons_t", 0);
  572. SetCvar("sm_weapons_ct", 1);
  573. SetCvarString("sv_skyname", g_sSkyName);
  574. SetCvar("sv_infinite_ammo", 0);
  575. SetCvar("sm_warden_enable", 1);
  576. SetCvar("sm_menu_enable", 1);
  577. g_iMPRoundTime.IntValue = g_iOldRoundTime;
  578. MyJailbreak_SetEventDayName("none");
  579. MyJailbreak_SetEventDayRunning(false);
  580. MyJailbreak_FogOff();
  581. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_end");
  582. }
  583. }
  584. if (StartZombie)
  585. {
  586. LoopClients(i) CreateInfoPanel(i);
  587.  
  588. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_next");
  589. PrintCenterTextAll("%t", "zombie_next_nc");
  590. }
  591. }
  592.  
  593.  
  594. public Action Event_PlayerHurt(Handle event, char [] name, bool dontBroadcast)
  595. {
  596. int victim = GetClientOfUserId(GetEventInt(event, "userid"));
  597. int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  598.  
  599. if (!IsZombie || !IsValidClient(attacker) || GetClientTeam(victim) == CS_TEAM_T)
  600. return;
  601.  
  602. int damage = GetEventInt(event, "dmg_health");
  603.  
  604. float knockback = gc_fKnockbackAmount.FloatValue; // knockback amount
  605. float clientloc[3];
  606. float attackerloc[3];
  607.  
  608. GetClientAbsOrigin(victim, clientloc);
  609.  
  610. // Get attackers eye position.
  611. GetClientEyePosition(attacker, attackerloc);
  612.  
  613. // Get attackers eye angles.
  614. float attackerang[3];
  615. GetClientEyeAngles(attacker, attackerang);
  616.  
  617. // Calculate knockback end-vector.
  618. TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, KnockbackTRFilter);
  619. TR_GetEndPosition(clientloc);
  620.  
  621. // Apply damage knockback multiplier.
  622. knockback *= damage;
  623.  
  624. if(GetEntPropEnt(victim, Prop_Send, "m_hGroundEntity") == -1) knockback *= 0.5;
  625.  
  626. // Apply knockback.
  627. KnockbackSetVelocity(victim, attackerloc, clientloc, knockback);
  628. }
  629.  
  630.  
  631. /******************************************************************************
  632. FORWARDS LISTEN
  633. ******************************************************************************/
  634.  
  635.  
  636. //Initialize Event
  637. public void OnMapStart()
  638. {
  639. g_iVoteCount = 0;
  640. g_iRound = 0;
  641. IsZombie = false;
  642. StartZombie = false;
  643.  
  644. g_iCoolDown = gc_iCooldownStart.IntValue + 1;
  645. g_iFreezeTime = gc_iFreezeTime.IntValue;
  646. g_sOldSkyName = FindConVar("sv_skyname");
  647. g_sOldSkyName.GetString(g_sSkyName, sizeof(g_sSkyName));
  648.  
  649. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundStartPath);
  650. if (gc_bOverlays.BoolValue) PrecacheDecalAnyDownload(g_sOverlayStartPath);
  651. PrecacheModel(g_sModelPathZombie);
  652. }
  653.  
  654.  
  655. //Map End
  656. public void OnMapEnd()
  657. {
  658. IsZombie = false;
  659. StartZombie = false;
  660. delete FreezeTimer;
  661. delete BeaconTimer;
  662. g_iVoteCount = 0;
  663. g_iRound = 0;
  664. g_sHasVoted[0] = '\0';
  665. }
  666.  
  667.  
  668. //Listen for Last Lequest
  669. public int OnAvailableLR(int Announced)
  670. {
  671. if (IsZombie && gc_bAllowLR.BoolValue && (g_iTsLR > g_iTerrorForLR.IntValue))
  672. {
  673. LoopValidClients(client, false, true)
  674. {
  675. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 0, 4, true);
  676.  
  677. if (gc_bGlow.BoolValue) UnhookGlow(client);
  678.  
  679. SetEntProp(client, Prop_Send, "m_bNightVisionOn", 0);
  680.  
  681. SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
  682.  
  683. StripAllPlayerWeapons(client);
  684. if (GetClientTeam(client) == CS_TEAM_CT)
  685. {
  686. FakeClientCommand(client, "sm_weapons");
  687. SetEntityModel(client, g_sModelPathPrevious[client]);
  688. SetEntityHealth(client, 100);
  689. }
  690. GivePlayerItem(client, "weapon_knife");
  691. }
  692.  
  693. delete FreezeTimer;
  694. delete BeaconTimer;
  695. if (g_iRound == g_iMaxRound)
  696. {
  697. IsZombie = false;
  698. StartZombie = false;
  699. g_iRound = 0;
  700. Format(g_sHasVoted, sizeof(g_sHasVoted), "");
  701. SetCvar("sm_hosties_lr", 1);
  702. SetCvar("sm_weapons_t", 0);
  703. SetCvar("sm_weapons_ct", 1);
  704. SetCvarString("sv_skyname", g_sSkyName);
  705. SetCvar("sv_infinite_ammo", 0);
  706. SetCvar("sm_warden_enable", 1);
  707. SetCvar("sm_menu_enable", 1);
  708. g_iMPRoundTime.IntValue = g_iOldRoundTime;
  709. MyJailbreak_SetEventDayName("none");
  710. MyJailbreak_SetEventDayRunning(false);
  711. MyJailbreak_FogOff();
  712. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_end");
  713. }
  714. }
  715. }
  716.  
  717.  
  718. public void OnClientPutInServer(int client)
  719. {
  720. SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
  721. }
  722.  
  723.  
  724. //Knife only for Zombies
  725. public Action OnWeaponCanUse(int client, int weapon)
  726. {
  727. char sWeapon[32];
  728. GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
  729.  
  730. if (!StrEqual(sWeapon, "weapon_knife"))
  731. {
  732. if (GetClientTeam(client) == CS_TEAM_CT )
  733. {
  734. if (IsClientInGame(client) && IsPlayerAlive(client))
  735. {
  736. if (IsZombie == true)
  737. {
  738. return Plugin_Handled;
  739. }
  740. }
  741. }
  742. }
  743. return Plugin_Continue;
  744. }
  745.  
  746.  
  747. /******************************************************************************
  748. FUNCTIONS
  749. ******************************************************************************/
  750.  
  751.  
  752. //Prepare Event for next round
  753. void StartNextRound()
  754. {
  755. StartZombie = true;
  756. g_iCoolDown = gc_iCooldownDay.IntValue + 1;
  757. g_iVoteCount = 0;
  758. char buffer[32];
  759. Format(buffer, sizeof(buffer), "%T", "zombie_name", LANG_SERVER);
  760. MyJailbreak_SetEventDayName(buffer);
  761. MyJailbreak_SetEventDayPlanned(true);
  762.  
  763. g_iOldRoundTime = g_iMPRoundTime.IntValue; //save original round time
  764. g_iMPRoundTime.IntValue = gc_iRoundTime.IntValue;//set event round time
  765.  
  766. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_next");
  767. PrintCenterTextAll("%t", "zombie_next_nc");
  768. }
  769.  
  770.  
  771. //Perpare client for glow
  772. void SetupGlowSkin(int client)
  773. {
  774. char sModel[PLATFORM_MAX_PATH];
  775. GetClientModel(client, sModel, sizeof(sModel));
  776. int iSkin = CPS_SetSkin(client, sModel, CPS_RENDER);
  777.  
  778. if (iSkin == -1)
  779. return;
  780.  
  781. if (SDKHookEx(iSkin, SDKHook_SetTransmit, OnSetTransmit_GlowSkin))
  782. SetupGlow(iSkin);
  783. }
  784.  
  785.  
  786. //set client glow
  787. void SetupGlow(int iSkin)
  788. {
  789. int iOffset;
  790.  
  791. if (!iOffset && (iOffset = GetEntSendPropOffs(iSkin, "m_clrGlow")) == -1)
  792. return;
  793.  
  794. SetEntProp(iSkin, Prop_Send, "m_bShouldGlow", true, true);
  795. if (gc_iGlowMode.IntValue == 1) SetEntProp(iSkin, Prop_Send, "m_nGlowStyle", 0);
  796. if (gc_iGlowMode.IntValue == 2) SetEntProp(iSkin, Prop_Send, "m_nGlowStyle", 1);
  797. SetEntPropFloat(iSkin, Prop_Send, "m_flGlowMaxDist", 10000000.0);
  798.  
  799. int iRed = 155;
  800. int iGreen = 0;
  801. int iBlue = 10;
  802.  
  803. SetEntData(iSkin, iOffset, iRed, _, true);
  804. SetEntData(iSkin, iOffset + 1, iGreen, _, true);
  805. SetEntData(iSkin, iOffset + 2, iBlue, _, true);
  806. SetEntData(iSkin, iOffset + 3, 255, _, true);
  807. }
  808.  
  809.  
  810. //Who can see the glow if vaild
  811. public Action OnSetTransmit_GlowSkin(int iSkin, int client)
  812. {
  813. if (!IsPlayerAlive(client))
  814. return Plugin_Handled;
  815.  
  816. LoopClients(target)
  817. {
  818. if (!CPS_HasSkin(target))
  819. continue;
  820.  
  821. if (EntRefToEntIndex(CPS_GetSkin(target)) != iSkin)
  822. continue;
  823.  
  824. if (GetClientTeam(client) == CS_TEAM_CT)
  825.  
  826. return Plugin_Continue;
  827. }
  828.  
  829. return Plugin_Handled;
  830. }
  831.  
  832.  
  833. //remove glow
  834. void UnhookGlow(int client)
  835. {
  836. if (IsValidClient(client, false, true))
  837. {
  838. // char sModel[PLATFORM_MAX_PATH];
  839. // GetClientModel(client, sModel, sizeof(sModel));
  840. SDKUnhook(client, SDKHook_SetTransmit, OnSetTransmit_GlowSkin);
  841. }
  842. }
  843.  
  844.  
  845. void KnockbackSetVelocity(int client, const float startpoint[3], const float endpoint[3], float magnitude)
  846. {
  847. // Create vector from the given starting and ending points.
  848. float vector[3];
  849. MakeVectorFromPoints(startpoint, endpoint, vector);
  850.  
  851. // Normalize the vector (equal magnitude at varying distances).
  852. NormalizeVector(vector, vector);
  853.  
  854. // Apply the magnitude by scaling the vector (multiplying each of its components).
  855. ScaleVector(vector, magnitude);
  856.  
  857.  
  858. TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vector);
  859. }
  860.  
  861.  
  862. public bool KnockbackTRFilter(int entity, int contentsMask)
  863. {
  864. // If entity is a player, continue tracing.
  865. if (entity > 0 && entity < MAXPLAYERS)
  866. {
  867. return false;
  868. }
  869.  
  870. // Allow hit.
  871. return true;
  872. }
  873.  
  874.  
  875. /******************************************************************************
  876. MENUS
  877. ******************************************************************************/
  878.  
  879.  
  880. stock void CreateInfoPanel(int client)
  881. {
  882. //Create info Panel
  883. char info[255];
  884.  
  885. ZombieMenu = CreatePanel();
  886. Format(info, sizeof(info), "%T", "zombie_info_title", client);
  887. SetPanelTitle(ZombieMenu, info);
  888. DrawPanelText(ZombieMenu, " ");
  889. Format(info, sizeof(info), "%T", "zombie_info_line1", client);
  890. DrawPanelText(ZombieMenu, info);
  891. DrawPanelText(ZombieMenu, "-----------------------------------");
  892. Format(info, sizeof(info), "%T", "zombie_info_line2", client);
  893. DrawPanelText(ZombieMenu, info);
  894. Format(info, sizeof(info), "%T", "zombie_info_line3", client);
  895. DrawPanelText(ZombieMenu, info);
  896. Format(info, sizeof(info), "%T", "zombie_info_line4", client);
  897. DrawPanelText(ZombieMenu, info);
  898. Format(info, sizeof(info), "%T", "zombie_info_line5", client);
  899. DrawPanelText(ZombieMenu, info);
  900. Format(info, sizeof(info), "%T", "zombie_info_line6", client);
  901. DrawPanelText(ZombieMenu, info);
  902. Format(info, sizeof(info), "%T", "zombie_info_line7", client);
  903. DrawPanelText(ZombieMenu, info);
  904. DrawPanelText(ZombieMenu, "-----------------------------------");
  905. Format(info, sizeof(info), "%T", "warden_close", client);
  906. DrawPanelItem(ZombieMenu, info);
  907. SendPanelToClient(ZombieMenu, client, Handler_NullCancel, 20);
  908. }
  909.  
  910.  
  911. /******************************************************************************
  912. TIMER
  913. ******************************************************************************/
  914.  
  915.  
  916. //Start Timer
  917. public Action Timer_StartEvent(Handle timer)
  918. {
  919. if (g_iFreezeTime > 1)
  920. {
  921. g_iFreezeTime--;
  922. LoopClients(client) if (IsPlayerAlive(client))
  923. {
  924. if (GetClientTeam(client) == CS_TEAM_CT)
  925. {
  926. PrintCenterText(client, "%t", "zombie_timetounfreeze_nc", g_iFreezeTime);
  927. }
  928. else if (GetClientTeam(client) == CS_TEAM_T)
  929. {
  930. PrintCenterText(client, "%t", "zombie_timeuntilzombie_nc", g_iFreezeTime);
  931. }
  932. }
  933. return Plugin_Continue;
  934. }
  935.  
  936. g_iFreezeTime = gc_iFreezeTime.IntValue;
  937.  
  938. if (g_iRound > 0)
  939. {
  940. LoopClients(client) if (IsPlayerAlive(client))
  941. {
  942. if (GetClientTeam(client) == CS_TEAM_CT)
  943. {
  944. SetEntityMoveType(client, MOVETYPE_WALK);
  945. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.4);
  946. if (gc_bVision.BoolValue) SetEntProp(client, Prop_Send, "m_bNightVisionOn", 1);
  947. }
  948.  
  949. if (gc_bGlow.BoolValue && (IsValidClient(client, true, true)) && (GetClientTeam(client) == CS_TEAM_T)) SetupGlowSkin(client);
  950.  
  951. SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
  952. PrintCenterText(client, "%t", "zombie_start_nc");
  953. if (gc_bOverlays.BoolValue) ShowOverlay(client, g_sOverlayStartPath, 2.0);
  954. if (gc_bSounds.BoolValue)
  955. {
  956. EmitSoundToAllAny(g_sSoundStartPath);
  957. }
  958. }
  959. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_start");
  960. }
  961. FreezeTimer = null;
  962. if (gc_bDark.BoolValue && (g_iRound = 1)) MyJailbreak_FogOn();
  963.  
  964. return Plugin_Stop;
  965. }
  966.  
  967.  
  968. //Delay Set model for sm_skinchooser
  969. public Action Timer_SetModel(Handle timer)
  970. {
  971. LoopValidClients(client, true, false)
  972. {
  973. if (GetClientTeam(client) == CS_TEAM_CT)
  974. {
  975. GetEntPropString(client, Prop_Data, "m_ModelName", g_sModelPathPrevious[client], sizeof(g_sModelPathPrevious[]));
  976. SetEntityModel(client, g_sModelPathZombie);
  977. }
  978. }
  979. }
  980.  
  981.  
  982. //Beacon Timer
  983. public Action Timer_BeaconOn(Handle timer)
  984. {
  985. LoopValidClients(i, true, false) MyJailbreak_BeaconOn(i, 2.0);
  986. BeaconTimer = null;
  987. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement