Advertisement
Guest User

Untitled

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