Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.03 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. if (StartZombie || IsZombie)
  217. {
  218. for(int i = 1; i <= MaxClients; i++)
  219. {
  220. if (IsPlayerAlive(i) && (GetClientTeam(i) == 3))
  221. {
  222.  
  223. int oldHP = GetClientHealth(i);
  224. int newHP = oldHP + (10);
  225. SetEntityHealth(i, newHP);
  226. }
  227. }
  228. }
  229. return Plugin_Continue;
  230.  
  231.  
  232. }
  233.  
  234.  
  235. //ConVarChange for Strings
  236. public int OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
  237. {
  238. if (convar == gc_sModelPathZombie)
  239. {
  240. strcopy(g_sModelPathZombie, sizeof(g_sModelPathZombie), newValue);
  241. PrecacheModel(g_sModelPathZombie);
  242. }
  243. else if (convar == gc_sAdminFlag)
  244. {
  245. strcopy(g_sAdminFlag, sizeof(g_sAdminFlag), newValue);
  246. }
  247. else if (convar == gc_sOverlayStartPath)
  248. {
  249. strcopy(g_sOverlayStartPath, sizeof(g_sOverlayStartPath), newValue);
  250. if (gc_bOverlays.BoolValue) PrecacheDecalAnyDownload(g_sOverlayStartPath);
  251. }
  252. else if (convar == gc_sSoundStartPath)
  253. {
  254. strcopy(g_sSoundStartPath, sizeof(g_sSoundStartPath), newValue);
  255. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundStartPath);
  256. }
  257. }
  258.  
  259.  
  260. //Initialize Plugin
  261. public void OnConfigsExecuted()
  262. {
  263. g_iFreezeTime = gc_iFreezeTime.IntValue;
  264. g_iCoolDown = gc_iCooldownStart.IntValue + 1;
  265. g_iMaxRound = gc_iRounds.IntValue;
  266.  
  267. //FindConVar
  268. g_iTerrorForLR = FindConVar("sm_hosties_lr_ts_max");
  269.  
  270. //Set custom Commands
  271. int iCount = 0;
  272. char sCommands[128], sCommandsL[12][32], sCommand[32];
  273.  
  274. //Vote
  275. gc_sCustomCommandVote.GetString(sCommands, sizeof(sCommands));
  276. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  277. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  278.  
  279. for (int i = 0; i < iCount; i++)
  280. {
  281. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  282. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  283. RegConsoleCmd(sCommand, Command_VoteZombie, "Allows players to vote for a Zombie");
  284. }
  285.  
  286. //Set
  287. gc_sCustomCommandSet.GetString(sCommands, sizeof(sCommands));
  288. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  289. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  290.  
  291. for (int i = 0; i < iCount; i++)
  292. {
  293. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  294. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  295. RegConsoleCmd(sCommand, Command_SetZombie, "Allows the Admin or Warden to set Zombie as next round");
  296. }
  297. }
  298.  
  299.  
  300. /******************************************************************************
  301. COMMANDS
  302. ******************************************************************************/
  303.  
  304.  
  305. //Admin & Warden set Event
  306. public Action Command_SetZombie(int client, int args)
  307. {
  308. if (gc_bPlugin.BoolValue)
  309. {
  310. if (client == 0)
  311. {
  312. StartNextRound();
  313. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event zombie was started by groupvoting");
  314. }
  315. else if (warden_iswarden(client))
  316. {
  317. if (gc_bSetW.BoolValue)
  318. {
  319. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  320. {
  321. char EventDay[64];
  322. MyJailbreak_GetEventDayName(EventDay);
  323.  
  324. if (StrEqual(EventDay, "none", false))
  325. {
  326. if (g_iCoolDown == 0)
  327. {
  328. StartNextRound();
  329. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by warden %L", client);
  330. }
  331. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  332. }
  333. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  334. }
  335. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  336. }
  337. else CReplyToCommand(client, "%t %t", "warden_tag" , "zombie_setbywarden");
  338. }
  339. else if (CheckVipFlag(client, g_sAdminFlag))
  340. {
  341. if (gc_bSetA.BoolValue)
  342. {
  343. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  344. {
  345. char EventDay[64];
  346. MyJailbreak_GetEventDayName(EventDay);
  347.  
  348. if (StrEqual(EventDay, "none", false))
  349. {
  350. if ((g_iCoolDown == 0) || gc_bSetABypassCooldown.BoolValue)
  351. {
  352. StartNextRound();
  353. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by admin %L", client);
  354. }
  355. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  356. }
  357. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  358. }
  359. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  360. }
  361. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_setbyadmin");
  362. }
  363. else CReplyToCommand(client, "%t %t", "warden_tag" , "warden_notwarden");
  364. }
  365. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_disabled");
  366. return Plugin_Handled;
  367. }
  368.  
  369.  
  370. //Voting for Event
  371. public Action Command_VoteZombie(int client, int args)
  372. {
  373. char steamid[64];
  374. GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
  375.  
  376. if (gc_bPlugin.BoolValue)
  377. {
  378. if (gc_bVote.BoolValue)
  379. {
  380. if ((GetTeamClientCount(CS_TEAM_CT) > 0) && (GetTeamClientCount(CS_TEAM_T) > 0 ))
  381. {
  382. char EventDay[64];
  383. MyJailbreak_GetEventDayName(EventDay);
  384.  
  385. if (StrEqual(EventDay, "none", false))
  386. {
  387. if (g_iCoolDown == 0)
  388. {
  389. if (StrContains(g_sHasVoted, steamid, true) == -1)
  390. {
  391. int playercount = (GetClientCount(true) / 2);
  392. g_iVoteCount++;
  393. int Missing = playercount - g_iVoteCount + 1;
  394. Format(g_sHasVoted, sizeof(g_sHasVoted), "%s, %s", g_sHasVoted, steamid);
  395.  
  396. if (g_iVoteCount > playercount)
  397. {
  398. StartNextRound();
  399. if (MyJailbreak_ActiveLogging()) LogToFileEx(g_sEventsLogFile, "Event Zombie was started by voting");
  400. }
  401. else CPrintToChatAll("%t %t", "zombie_tag" , "zombie_need", Missing, client);
  402. }
  403. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_voted");
  404. }
  405. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_wait", g_iCoolDown);
  406. }
  407. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_progress" , EventDay);
  408. }
  409. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_minplayer");
  410. }
  411. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_voting");
  412. }
  413. else CReplyToCommand(client, "%t %t", "zombie_tag" , "zombie_disabled");
  414. return Plugin_Handled;
  415. }
  416.  
  417.  
  418. /******************************************************************************
  419. EVENTS
  420. ******************************************************************************/
  421.  
  422.  
  423. //Round start
  424. public void Event_RoundStart(Event event, char[] name, bool dontBroadcast)
  425. {
  426. if (StartZombie || IsZombie)
  427. {
  428. SetCvar("sm_hosties_lr", 0);
  429. SetCvar("sm_warden_enable", 0);
  430. SetCvarString("sv_skyname", "cs_baggage_skybox_");
  431. SetCvar("sm_weapons_t", 1);
  432. SetCvar("sm_weapons_ct", 0);
  433. if (gc_bAmmo.BoolValue) SetCvar("sv_infinite_ammo", 2);
  434. SetCvar("sm_menu_enable", 0);
  435. MyJailbreak_SetEventDayPlanned(false);
  436. MyJailbreak_SetEventDayRunning(true);
  437. IsZombie = true;
  438. g_iRound++;
  439. StartZombie = false;
  440. SJD_OpenDoors();
  441.  
  442. if (gc_fBeaconTime.FloatValue > 0.0) BeaconTimer = CreateTimer(gc_fBeaconTime.FloatValue, Timer_BeaconOn, TIMER_FLAG_NO_MAPCHANGE);
  443.  
  444. int RandomCT = 0;
  445.  
  446. LoopClients(client)
  447. {
  448. if (GetClientTeam(client) == CS_TEAM_CT)
  449. {
  450. RandomCT = client;
  451. break;
  452. }
  453. }
  454. if (RandomCT)
  455. {
  456. GetClientAbsOrigin(RandomCT, g_fPos);
  457.  
  458. g_fPos[2] = g_fPos[2] + 6;
  459.  
  460. if (g_iRound > 0)
  461. {
  462. LoopClients(client)
  463. {
  464. CreateInfoPanel(client);
  465. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 2, 4, true);
  466. SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
  467.  
  468. if (GetClientTeam(client) == CS_TEAM_CT)
  469. {
  470. SetEntityMoveType(client, MOVETYPE_NONE);
  471. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 0.0);
  472.  
  473. int zombieHP = gc_iZombieHP.IntValue;
  474. int difference = (GetAliveTeamCount(CS_TEAM_T) - GetAliveTeamCount(CS_TEAM_CT));
  475.  
  476. if (difference > 0) zombieHP = zombieHP + (gc_iZombieHPincrease.IntValue * difference);
  477.  
  478. SetEntityHealth(client, zombieHP);
  479.  
  480. StripAllPlayerWeapons(client);
  481. GivePlayerItem(client, "weapon_knife");
  482. }
  483. if (GetClientTeam(client) == CS_TEAM_T)
  484. {
  485. SetEntityHealth(client, gc_iHumanHP.IntValue);
  486. }
  487. if (!gc_bSpawnCell.BoolValue || (gc_bSpawnCell.BoolValue && (SJD_IsCurrentMapConfigured() != true))) //spawn Terrors to CT Spawn
  488. {
  489. TeleportEntity(client, g_fPos, NULL_VECTOR, NULL_VECTOR);
  490. }
  491. }
  492.  
  493. CreateTimer (1.1, Timer_SetModel);
  494.  
  495. //enable lr on last round
  496. g_iTsLR = GetAliveTeamCount(CS_TEAM_T);
  497.  
  498. if (gc_bAllowLR.BoolValue)
  499. {
  500. if ((g_iRound == g_iMaxRound) && (g_iTsLR > g_iTerrorForLR.IntValue))
  501. {
  502. SetCvar("sm_hosties_lr", 1);
  503. }
  504. }
  505. }
  506. g_iFreezeTime--;
  507. FreezeTimer = CreateTimer(1.0, Timer_StartEvent, _, TIMER_REPEAT);
  508.  
  509. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_rounds", g_iRound, g_iMaxRound);
  510. }
  511. }
  512. else
  513. {
  514. char EventDay[64];
  515. MyJailbreak_GetEventDayName(EventDay);
  516.  
  517. if (!StrEqual(EventDay, "none", false))
  518. {
  519. g_iCoolDown = gc_iCooldownDay.IntValue + 1;
  520. }
  521. else if (g_iCoolDown > 0) g_iCoolDown--;
  522. }
  523. }
  524.  
  525.  
  526. //Round End
  527. public void Event_RoundEnd(Event event, char[] name, bool dontBroadcast)
  528. {
  529. int winner = event.GetInt("winner");
  530.  
  531. if (IsZombie)
  532. {
  533. LoopValidClients(client, false, true)
  534. {
  535. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 0, 4, true);
  536. if (gc_bGlow.BoolValue) UnhookGlow(client);
  537. SetEntProp(client, Prop_Send, "m_bNightVisionOn", 0);
  538. }
  539.  
  540. delete FreezeTimer;
  541. delete BeaconTimer;
  542.  
  543.  
  544. if (winner == 2)
  545. {
  546. PrintCenterTextAll("%t", "zombie_twin_nc");
  547. LoopValidClients(i, false, true) // (i, false, true) only surviver get credits - (i, false, true) Dead player get credits too
  548. {
  549. if (GetClientTeam(i) == CS_TEAM_T)
  550. {
  551. Store_SetClientCredits(i, Store_GetClientCredits(i) + 10);
  552. }
  553. }
  554. }
  555. if (winner == 3)
  556. {
  557. PrintCenterTextAll("%t", "zombie_ctwin_nc");
  558. LoopValidClients(i, false, true) // (i, false, true) only surviver get credits - (i, false, true) Dead player get credits too
  559. {
  560. if (GetClientTeam(i) == CS_TEAM_CT)
  561. {
  562. Store_SetClientCredits(i, Store_GetClientCredits(i) + 10);
  563. }
  564. }
  565. }
  566. if (g_iRound == g_iMaxRound)
  567. {
  568. IsZombie = false;
  569. StartZombie = false;
  570. g_iRound = 0;
  571. Format(g_sHasVoted, sizeof(g_sHasVoted), "");
  572. SetCvar("sm_hosties_lr", 1);
  573. SetCvar("sm_weapons_t", 0);
  574. SetCvar("sm_weapons_ct", 1);
  575. SetCvarString("sv_skyname", g_sSkyName);
  576. SetCvar("sv_infinite_ammo", 0);
  577. SetCvar("sm_warden_enable", 1);
  578. SetCvar("sm_menu_enable", 1);
  579. g_iMPRoundTime.IntValue = g_iOldRoundTime;
  580. MyJailbreak_SetEventDayName("none");
  581. MyJailbreak_SetEventDayRunning(false);
  582. MyJailbreak_FogOff();
  583. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_end");
  584. }
  585. }
  586. if (StartZombie)
  587. {
  588. LoopClients(i) CreateInfoPanel(i);
  589.  
  590. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_next");
  591. PrintCenterTextAll("%t", "zombie_next_nc");
  592. }
  593. }
  594.  
  595.  
  596. public Action Event_PlayerHurt(Handle event, char [] name, bool dontBroadcast)
  597. {
  598. int victim = GetClientOfUserId(GetEventInt(event, "userid"));
  599. int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  600.  
  601. if (!IsZombie || !IsValidClient(attacker) || GetClientTeam(victim) == CS_TEAM_T)
  602. return;
  603.  
  604. int damage = GetEventInt(event, "dmg_health");
  605.  
  606. float knockback = gc_fKnockbackAmount.FloatValue; // knockback amount
  607. float clientloc[3];
  608. float attackerloc[3];
  609.  
  610. GetClientAbsOrigin(victim, clientloc);
  611.  
  612. // Get attackers eye position.
  613. GetClientEyePosition(attacker, attackerloc);
  614.  
  615. // Get attackers eye angles.
  616. float attackerang[3];
  617. GetClientEyeAngles(attacker, attackerang);
  618.  
  619. // Calculate knockback end-vector.
  620. TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, KnockbackTRFilter);
  621. TR_GetEndPosition(clientloc);
  622.  
  623. // Apply damage knockback multiplier.
  624. knockback *= damage;
  625.  
  626. if(GetEntPropEnt(victim, Prop_Send, "m_hGroundEntity") == -1) knockback *= 0.5;
  627.  
  628. // Apply knockback.
  629. KnockbackSetVelocity(victim, attackerloc, clientloc, knockback);
  630. }
  631.  
  632.  
  633. /******************************************************************************
  634. FORWARDS LISTEN
  635. ******************************************************************************/
  636.  
  637.  
  638. //Initialize Event
  639. public void OnMapStart()
  640. {
  641. g_iVoteCount = 0;
  642. g_iRound = 0;
  643. IsZombie = false;
  644. StartZombie = false;
  645.  
  646. g_iCoolDown = gc_iCooldownStart.IntValue + 1;
  647. g_iFreezeTime = gc_iFreezeTime.IntValue;
  648. g_sOldSkyName = FindConVar("sv_skyname");
  649. g_sOldSkyName.GetString(g_sSkyName, sizeof(g_sSkyName));
  650.  
  651. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundStartPath);
  652. if (gc_bOverlays.BoolValue) PrecacheDecalAnyDownload(g_sOverlayStartPath);
  653. PrecacheModel(g_sModelPathZombie);
  654. }
  655.  
  656.  
  657. //Map End
  658. public void OnMapEnd()
  659. {
  660. IsZombie = false;
  661. StartZombie = false;
  662. delete FreezeTimer;
  663. delete BeaconTimer;
  664. g_iVoteCount = 0;
  665. g_iRound = 0;
  666. g_sHasVoted[0] = '\0';
  667. }
  668.  
  669.  
  670. //Listen for Last Lequest
  671. public int OnAvailableLR(int Announced)
  672. {
  673. if (IsZombie && gc_bAllowLR.BoolValue && (g_iTsLR > g_iTerrorForLR.IntValue))
  674. {
  675. LoopValidClients(client, false, true)
  676. {
  677. SetEntData(client, FindSendPropInfo("CBaseEntity", "m_CollisionGroup"), 0, 4, true);
  678.  
  679. if (gc_bGlow.BoolValue) UnhookGlow(client);
  680.  
  681. SetEntProp(client, Prop_Send, "m_bNightVisionOn", 0);
  682.  
  683. SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
  684.  
  685. StripAllPlayerWeapons(client);
  686. if (GetClientTeam(client) == CS_TEAM_CT)
  687. {
  688. FakeClientCommand(client, "sm_weapons");
  689. SetEntityModel(client, g_sModelPathPrevious[client]);
  690. SetEntityHealth(client, 100);
  691. }
  692. GivePlayerItem(client, "weapon_knife");
  693. }
  694.  
  695. delete FreezeTimer;
  696. delete BeaconTimer;
  697. if (g_iRound == g_iMaxRound)
  698. {
  699. IsZombie = false;
  700. StartZombie = false;
  701. g_iRound = 0;
  702. Format(g_sHasVoted, sizeof(g_sHasVoted), "");
  703. SetCvar("sm_hosties_lr", 1);
  704. SetCvar("sm_weapons_t", 0);
  705. SetCvar("sm_weapons_ct", 1);
  706. SetCvarString("sv_skyname", g_sSkyName);
  707. SetCvar("sv_infinite_ammo", 0);
  708. SetCvar("sm_warden_enable", 1);
  709. SetCvar("sm_menu_enable", 1);
  710. g_iMPRoundTime.IntValue = g_iOldRoundTime;
  711. MyJailbreak_SetEventDayName("none");
  712. MyJailbreak_SetEventDayRunning(false);
  713. MyJailbreak_FogOff();
  714. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_end");
  715. }
  716. }
  717. }
  718.  
  719.  
  720. public void OnClientPutInServer(int client)
  721. {
  722. SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
  723. }
  724.  
  725.  
  726. //Knife only for Zombies
  727. public Action OnWeaponCanUse(int client, int weapon)
  728. {
  729. char sWeapon[32];
  730. GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
  731.  
  732. if (!StrEqual(sWeapon, "weapon_knife"))
  733. {
  734. if (GetClientTeam(client) == CS_TEAM_CT )
  735. {
  736. if (IsClientInGame(client) && IsPlayerAlive(client))
  737. {
  738. if (IsZombie == true)
  739. {
  740. return Plugin_Handled;
  741. }
  742. }
  743. }
  744. }
  745. return Plugin_Continue;
  746. }
  747.  
  748.  
  749. /******************************************************************************
  750. FUNCTIONS
  751. ******************************************************************************/
  752.  
  753.  
  754. //Prepare Event for next round
  755. void StartNextRound()
  756. {
  757. StartZombie = true;
  758. g_iCoolDown = gc_iCooldownDay.IntValue + 1;
  759. g_iVoteCount = 0;
  760. char buffer[32];
  761. Format(buffer, sizeof(buffer), "%T", "zombie_name", LANG_SERVER);
  762. MyJailbreak_SetEventDayName(buffer);
  763. MyJailbreak_SetEventDayPlanned(true);
  764.  
  765. g_iOldRoundTime = g_iMPRoundTime.IntValue; //save original round time
  766. g_iMPRoundTime.IntValue = gc_iRoundTime.IntValue;//set event round time
  767.  
  768. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_next");
  769. PrintCenterTextAll("%t", "zombie_next_nc");
  770. }
  771.  
  772.  
  773. //Perpare client for glow
  774. void SetupGlowSkin(int client)
  775. {
  776. char sModel[PLATFORM_MAX_PATH];
  777. GetClientModel(client, sModel, sizeof(sModel));
  778. int iSkin = CPS_SetSkin(client, sModel, CPS_RENDER);
  779.  
  780. if (iSkin == -1)
  781. return;
  782.  
  783. if (SDKHookEx(iSkin, SDKHook_SetTransmit, OnSetTransmit_GlowSkin))
  784. SetupGlow(iSkin);
  785. }
  786.  
  787.  
  788. //set client glow
  789. void SetupGlow(int iSkin)
  790. {
  791. int iOffset;
  792.  
  793. if (!iOffset && (iOffset = GetEntSendPropOffs(iSkin, "m_clrGlow")) == -1)
  794. return;
  795.  
  796. SetEntProp(iSkin, Prop_Send, "m_bShouldGlow", true, true);
  797. if (gc_iGlowMode.IntValue == 1) SetEntProp(iSkin, Prop_Send, "m_nGlowStyle", 0);
  798. if (gc_iGlowMode.IntValue == 2) SetEntProp(iSkin, Prop_Send, "m_nGlowStyle", 1);
  799. SetEntPropFloat(iSkin, Prop_Send, "m_flGlowMaxDist", 10000000.0);
  800.  
  801. int iRed = 155;
  802. int iGreen = 0;
  803. int iBlue = 10;
  804.  
  805. SetEntData(iSkin, iOffset, iRed, _, true);
  806. SetEntData(iSkin, iOffset + 1, iGreen, _, true);
  807. SetEntData(iSkin, iOffset + 2, iBlue, _, true);
  808. SetEntData(iSkin, iOffset + 3, 255, _, true);
  809. }
  810.  
  811.  
  812. //Who can see the glow if vaild
  813. public Action OnSetTransmit_GlowSkin(int iSkin, int client)
  814. {
  815. if (!IsPlayerAlive(client))
  816. return Plugin_Handled;
  817.  
  818. LoopClients(target)
  819. {
  820. if (!CPS_HasSkin(target))
  821. continue;
  822.  
  823. if (EntRefToEntIndex(CPS_GetSkin(target)) != iSkin)
  824. continue;
  825.  
  826. if (GetClientTeam(client) == CS_TEAM_CT)
  827.  
  828. return Plugin_Continue;
  829. }
  830.  
  831. return Plugin_Handled;
  832. }
  833.  
  834.  
  835. //remove glow
  836. void UnhookGlow(int client)
  837. {
  838. if (IsValidClient(client, false, true))
  839. {
  840. // char sModel[PLATFORM_MAX_PATH];
  841. // GetClientModel(client, sModel, sizeof(sModel));
  842. SDKUnhook(client, SDKHook_SetTransmit, OnSetTransmit_GlowSkin);
  843. }
  844. }
  845.  
  846.  
  847. void KnockbackSetVelocity(int client, const float startpoint[3], const float endpoint[3], float magnitude)
  848. {
  849. // Create vector from the given starting and ending points.
  850. float vector[3];
  851. MakeVectorFromPoints(startpoint, endpoint, vector);
  852.  
  853. // Normalize the vector (equal magnitude at varying distances).
  854. NormalizeVector(vector, vector);
  855.  
  856. // Apply the magnitude by scaling the vector (multiplying each of its components).
  857. ScaleVector(vector, magnitude);
  858.  
  859.  
  860. TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vector);
  861. }
  862.  
  863.  
  864. public bool KnockbackTRFilter(int entity, int contentsMask)
  865. {
  866. // If entity is a player, continue tracing.
  867. if (entity > 0 && entity < MAXPLAYERS)
  868. {
  869. return false;
  870. }
  871.  
  872. // Allow hit.
  873. return true;
  874. }
  875.  
  876.  
  877. /******************************************************************************
  878. MENUS
  879. ******************************************************************************/
  880.  
  881.  
  882. stock void CreateInfoPanel(int client)
  883. {
  884. //Create info Panel
  885. char info[255];
  886.  
  887. ZombieMenu = CreatePanel();
  888. Format(info, sizeof(info), "%T", "zombie_info_title", client);
  889. SetPanelTitle(ZombieMenu, info);
  890. DrawPanelText(ZombieMenu, " ");
  891. Format(info, sizeof(info), "%T", "zombie_info_line1", client);
  892. DrawPanelText(ZombieMenu, info);
  893. DrawPanelText(ZombieMenu, "-----------------------------------");
  894. Format(info, sizeof(info), "%T", "zombie_info_line2", client);
  895. DrawPanelText(ZombieMenu, info);
  896. Format(info, sizeof(info), "%T", "zombie_info_line3", client);
  897. DrawPanelText(ZombieMenu, info);
  898. Format(info, sizeof(info), "%T", "zombie_info_line4", client);
  899. DrawPanelText(ZombieMenu, info);
  900. Format(info, sizeof(info), "%T", "zombie_info_line5", client);
  901. DrawPanelText(ZombieMenu, info);
  902. Format(info, sizeof(info), "%T", "zombie_info_line6", client);
  903. DrawPanelText(ZombieMenu, info);
  904. Format(info, sizeof(info), "%T", "zombie_info_line7", client);
  905. DrawPanelText(ZombieMenu, info);
  906. DrawPanelText(ZombieMenu, "-----------------------------------");
  907. Format(info, sizeof(info), "%T", "warden_close", client);
  908. DrawPanelItem(ZombieMenu, info);
  909. SendPanelToClient(ZombieMenu, client, Handler_NullCancel, 20);
  910. }
  911.  
  912.  
  913. /******************************************************************************
  914. TIMER
  915. ******************************************************************************/
  916.  
  917.  
  918. //Start Timer
  919. public Action Timer_StartEvent(Handle timer)
  920. {
  921. if (g_iFreezeTime > 1)
  922. {
  923. g_iFreezeTime--;
  924. LoopClients(client) if (IsPlayerAlive(client))
  925. {
  926. if (GetClientTeam(client) == CS_TEAM_CT)
  927. {
  928. PrintCenterText(client, "%t", "zombie_timetounfreeze_nc", g_iFreezeTime);
  929. }
  930. else if (GetClientTeam(client) == CS_TEAM_T)
  931. {
  932. PrintCenterText(client, "%t", "zombie_timeuntilzombie_nc", g_iFreezeTime);
  933. }
  934. }
  935. return Plugin_Continue;
  936. }
  937.  
  938. g_iFreezeTime = gc_iFreezeTime.IntValue;
  939.  
  940. if (g_iRound > 0)
  941. {
  942. LoopClients(client) if (IsPlayerAlive(client))
  943. {
  944. if (GetClientTeam(client) == CS_TEAM_CT)
  945. {
  946. SetEntityMoveType(client, MOVETYPE_WALK);
  947. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.4);
  948. if (gc_bVision.BoolValue) SetEntProp(client, Prop_Send, "m_bNightVisionOn", 1);
  949. }
  950.  
  951. if (gc_bGlow.BoolValue && (IsValidClient(client, true, true)) && (GetClientTeam(client) == CS_TEAM_T)) SetupGlowSkin(client);
  952.  
  953. SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
  954. PrintCenterText(client, "%t", "zombie_start_nc");
  955. if (gc_bOverlays.BoolValue) ShowOverlay(client, g_sOverlayStartPath, 2.0);
  956. if (gc_bSounds.BoolValue)
  957. {
  958. EmitSoundToAllAny(g_sSoundStartPath);
  959. }
  960. }
  961. CPrintToChatAll("%t %t", "zombie_tag" , "zombie_start");
  962. }
  963. FreezeTimer = null;
  964. if (gc_bDark.BoolValue && (g_iRound = 1)) MyJailbreak_FogOn();
  965.  
  966. return Plugin_Stop;
  967. }
  968.  
  969.  
  970. //Delay Set model for sm_skinchooser
  971. public Action Timer_SetModel(Handle timer)
  972. {
  973. LoopValidClients(client, true, false)
  974. {
  975. if (GetClientTeam(client) == CS_TEAM_CT)
  976. {
  977. GetEntPropString(client, Prop_Data, "m_ModelName", g_sModelPathPrevious[client], sizeof(g_sModelPathPrevious[]));
  978. SetEntityModel(client, g_sModelPathZombie);
  979. }
  980. }
  981. }
  982.  
  983.  
  984. //Beacon Timer
  985. public Action Timer_BeaconOn(Handle timer)
  986. {
  987. LoopValidClients(i, true, false) MyJailbreak_BeaconOn(i, 2.0);
  988. BeaconTimer = null;
  989. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement