Green Gaben
Join Date: Mar 2006
Location: OH-IO!
|
02-24-2008
, 02:15
Source to a zombie mod...
|
#1
|
Edit: Just read the forums and it seems another zombie infection mod is causing problems haha. Sorry to bring up more zombie stuff ;)
I was working on a zombie mod of my own but now I'm playing WoW again and don't have the time to finish this project.
Here is the source if anyone wants to take a look at it. Keep in mind it is incomplete.
Note: There is a bug where players can change their model to whatever when they are a zombie. There is also the svc_bad error 'sometimes', I fixed it for the most part.
Note 2: Using the following cvars will lag some clients with poor computers but creates a very cool effect (could possibly strain some poor servers too).
sv_lightstyle = 0
sv_storm = 1
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #include <cstrike>
#define PLUGIN "Zombie Disease" #define VERSION "2.0" #define AUTHOR "hlstriker"
// Sound Variables #define ZOMBIE_THUNDER_1 "ambience/thunder_clap.wav" #define ZOMBIE_THUNDER_2 "de_torn/torn_thndrstrike.wav" #define ZOMBIE_RAIN "ambience/rain.wav" #define ZOMBIE_RAIN_INSIDE "zombie-disease/raininside.wav"
#define ZOMBIE_MISS_NUM 2 new g_zombieMiss[ZOMBIE_MISS_NUM][] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav" }; #define ZOMBIE_HIT_NUM 3 new g_zombieHit[ZOMBIE_HIT_NUM][] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav" }; #define ZOMBIE_PAIN_NUM 2 new g_zombiePain[ZOMBIE_PAIN_NUM][] = { "zombie-disease/zombie_pain1.wav", "zombie-disease/zombie_pain2.wav" }; #define ZOMBIE_DIE_NUM 5 new g_zombieDie[ZOMBIE_DIE_NUM][] = { "zombie-disease/zombie_die1.wav", "zombie-disease/zombie_die2.wav", "zombie-disease/zombie_die3.wav", "zombie-disease/zombie_die4.wav", "zombie-disease/zombie_die5.wav" }; #define HUMAN_PAIN_NUM 2 new g_humanPain[HUMAN_PAIN_NUM][] = { "zombie-disease/human_pain1.wav", "zombie-disease/human_pain2.wav" }; #define ZOMBIE_INFECT_NUM 3 new g_zombieInfect[ZOMBIE_INFECT_NUM][] = { "zombie-disease/zombie_infec1.wav", "zombie-disease/zombie_infec2.wav", "zombie-disease/zombie_infec3.wav" };
// Model Variables #define ZOMBIE_MODEL_CLAWS "models/zombie-disease/v_knife_zombie.mdl" #define ZOMBIE_MODEL_1 "models/player/zombie_b2/zombie_b2.mdl" #define ZOMBIE_MODEL_1_NICK "zombie_b2"
// Weather Variables #define RAIN_INSIDE_DIST 150 new Float:g_nextRainSound[33]; new bool:g_newLocation[33]; new bool:g_oldLocation[33]; //new g_skyColors[3] = { 0, 1, 2 }; new g_lightStyleChar[3][] = { "a", "b", "c" }; new g_lightStyleNum; new g_lightCounter; new g_flashNum; new bool:g_isFlashing;
// CT Win Variables controlling weather new g_shouldRain = true; new g_weatherOff; new g_lightningOff;
// Fake nightvision variables #define ZOMBIE_LIGHT_RADIUS 165 #define HUMAN_LIGHT_RADIUS 140
// Dead regular nightvision variables new Float:g_reUpdateDeadNV[33]; new bool:g_didDeadCheck[33];
// Count-down / Round time variables #define COUNTDOWN_TIME 25.0 new Float:g_startCountDownTimeZombie; new Float:g_startCountDownTimeRound; new bool:g_showZombieTimeHud; new bool:g_showRoundTimeHud; new Float:g_totalTime; new Float:g_roundTimeLeft; new Float:g_timeTillZombie; new Float:g_freezeTime;
// Round time variables new bool:g_roundStarted; new g_roundTime;
// Hud Text Variables #define HUD_LIGHT_UPDATE_TIME 0.08 #define HUD_MSG_LEN 2048 #define HUDMSG_TIME 1.2 new bool:g_flashHealth[33]; new g_flashHealthCount[33]; new Float:g_nextHudMsg[33]; new g_healthHudMsg; new g_countdownHudMsg; new g_playerCountHudMsg;
// Custom buy menu variables new bool:g_attackedZombie[33]; new Float:g_buyWaitTime[33]; new g_chooseMenu; new g_buyMenu; new g_handgunMenu; new g_shotgunMenu; new g_smgMenu; new g_rifleMenu; new g_machinegunMenu; new g_equipmentMenu;
#define TOTAL_CHOOSE 3 new g_chooseMenuText[TOTAL_CHOOSE][] = { "New Weapons", "Previous Setup", "2+Don't show menu again" };
#define TOTAL_BUY 6 new g_buyMenuText[TOTAL_BUY][] = { "Handgun", "Shotgun", "Sub-Machine Gun", "Rifle", "Machine Gun", "Equipment" };
#define TOTAL_HANDGUN 6 new g_handgunMenuText[TOTAL_HANDGUN][] = { "9X19mm Sidearm", "K&M .45 Tactical", "228 Compact", "Night Hawk .50C", "ES Five-Seven", ".40 Dual Elites" }
#define TOTAL_SHOTGUN 2 new g_shotgunMenuText[TOTAL_SHOTGUN][] = { "Leone 12 Gauge Super", "Leone YG1265 Auto Shotgun" }
#define TOTAL_SMG 5 new g_smgMenuText[TOTAL_SMG][] = { "Schmidt Machine Pistol", "K&M Sub-Machine Gun", "K&M UMP45", "ES C90", "Ingram MAC-10" }
#define TOTAL_RIFLE 10 new g_rifleMenuText[TOTAL_RIFLE][] = { "Clarion 5.56", "IDF Defender", "Maverick M4A1 Carbine", "CV-47", "Bullpup", "Krieg 552 Commando", "Schmidt Scout", "Magnum Sniper Rifle", "Krieg 550 Commando", "D3/AU-1 Semi-Auto Sniper Rifle" }
#define TOTAL_MACHINEGUN 1 new g_machinegunMenuText[TOTAL_MACHINEGUN][] = { "ES M249 Para" }
#define TOTAL_EQUIPMENT 3 new g_equipmentMenuText[TOTAL_EQUIPMENT][] = { "Flashbang", "HE Grenade", "Smoke Grenade" }
// Cvars variables new mp_freezetime; new sv_accelerate; new sv_stopspeed; new sv_lightstyle; new sv_storm;
// Bomb variables new g_hasBomb;
// Buy zone variables new bool:g_buyzoneMade;
// Message variables new g_msgHideWeapon; new g_msgDeathMsg; new g_msgScoreInfo; new g_msgScoreAttrib; new g_msgNVGToggle; new g_msgTeamInfo; //new g_msgFlashlight; //new g_msgSetFOV; //new g_msgTextMsg;
// Restart round variables new bool:g_canRestart = true;
// Think variables new bool:g_isThinking; new g_counterEnt; new g_rainEnt; new g_thunderEnt;
// Zombie Variables #define ZOMBIE_HEALTH_MAIN 2500.0 #define ZOMBIE_HEALTH_AFTER 1000.0 #define ZOMBIE_ARMOR_MAIN 1000 #define ZOMBIE_ARMOR_AFTER 500 #define ZOMBIE_SPEED 270.0 new bool:g_isZombie[33];
// Player status variables new bool:g_hasSpawned[33]; new g_humansLeft; new g_zombiesLeft;
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); // Create the thunder/lightning entity if weather is on if(get_pcvar_num(sv_storm) == 1) { g_thunderEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "ambient_generic")); if(g_thunderEnt) { dllfunc(DLLFunc_Think, g_thunderEnt); set_keyvalue(g_thunderEnt, "message", ZOMBIE_THUNDER_1); // WAV name set_keyvalue(g_thunderEnt, "targetname", "boom"); // Name set_keyvalue(g_thunderEnt, "pitchstart", "100"); // Start Pitch set_keyvalue(g_thunderEnt, "pitch", "100"); // Pitch (> 100 = higher) set_keyvalue(g_thunderEnt, "health", "10"); // Volume (10 = loudest) set_keyvalue(g_thunderEnt, "spawnflags", "49"); // Play Everywhere, Start Silent, Not Toggled dllfunc(DLLFunc_Spawn, g_thunderEnt); set_pev(g_thunderEnt, pev_nextthink, get_gametime() + 3.0); } } // Create the timer entity g_counterEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")); if(g_counterEnt) { dllfunc(DLLFunc_Think, g_counterEnt); dllfunc(DLLFunc_Spawn, g_counterEnt); set_pev(g_counterEnt, pev_nextthink, get_gametime() + 3.0); } if(get_pcvar_num(sv_lightstyle) == 0) server_cmd("sv_skyname black"); else server_cmd("sv_skyname space"); server_cmd("mp_autoteambalance 0;mp_limitteams 0"); g_healthHudMsg = CreateHudSyncObj(); g_countdownHudMsg = CreateHudSyncObj(); g_playerCountHudMsg = CreateHudSyncObj(); register_clcmd("jointeam", "blockTeam"); register_clcmd("joinclass", "blockTeam"); register_clcmd("chooseteam", "blockCommand"); register_clcmd("fullupdate", "blockCommand"); register_clcmd("drop", "blockCommand"); register_clcmd("say /buy", "openBuyMenu"); register_clcmd("say guns", "openBuyMenu"); if(!g_isThinking) register_forward(FM_Think, "fwd_Think", 1); register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink"); register_forward(FM_EmitSound, "fwd_EmitSound"); register_forward(FM_Touch, "fwd_Touch"); register_forward(FM_ClientKill, "fwd_ClientKill"); register_forward(FM_CVarSetFloat, "fwd_CVarSetFloat") register_forward(FM_AddToFullPack, "fwd_AddToFullPack", 1); RegisterHam(Ham_TakeDamage, "player", "hook_TakeDamage"); g_msgDeathMsg = get_user_msgid("DeathMsg"); g_msgHideWeapon = get_user_msgid("HideWeapon"); g_msgScoreInfo = get_user_msgid("ScoreInfo"); g_msgNVGToggle = get_user_msgid("NVGToggle"); g_msgScoreAttrib = get_user_msgid("ScoreAttrib"); g_msgTeamInfo = get_user_msgid("TeamInfo"); register_logevent("logevent_round_start", 2, "1=Round_Start"); register_message(get_user_msgid("RoundTime"), "msg_RoundTime"); register_message(g_msgDeathMsg, "msg_DeathMsg"); register_message(get_user_msgid("TextMsg"), "msg_TextMsg"); register_message(get_user_msgid("SendAudio"), "msg_SendAudio"); register_event("ResetHUD", "hook_ResetHUD", "be"); register_event("CurWeapon", "hook_CurWeapon", "be", "1=1"); register_event("HLTV", "hook_HLTV", "a", "1=0", "2=0"); register_event("WeapPickup", "hook_WeapPickup", "be", "1=6"); sv_accelerate = register_cvar("sv_accelerate", "8.0"); sv_stopspeed = register_cvar("sv_stopspeed", "90.0"); mp_freezetime = register_cvar("mp_freezetime", "3.0"); register_cvar("zombie_disease", VERSION); create_menus(); }
public plugin_precache() { sv_lightstyle = register_cvar("sv_lightstyle", "4"); sv_storm = register_cvar("sv_storm", "1"); register_forward(FM_KeyValue, "fwd_KeyValue", 1); // Create the rain entity if weather is on if(get_pcvar_num(sv_storm) == 1) { g_rainEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain")); if(g_rainEnt) { g_isThinking = true; register_forward(FM_Think, "fwd_Think", 1); set_pev(g_rainEnt, pev_nextthink, get_gametime() + 3.0); } } new i; for(i=0; i<ZOMBIE_MISS_NUM; i++) precache_sound(g_zombieMiss[i]); for(i=0; i<ZOMBIE_HIT_NUM; i++) precache_sound(g_zombieHit[i]); for(i=0; i<ZOMBIE_PAIN_NUM; i++) precache_sound(g_zombiePain[i]); for(i=0; i<HUMAN_PAIN_NUM; i++) precache_sound(g_humanPain[i]); for(i=0; i<ZOMBIE_INFECT_NUM; i++) precache_sound(g_zombieInfect[i]); for(i=0; i<ZOMBIE_DIE_NUM; i++) precache_sound(g_zombieDie[i]); precache_model(ZOMBIE_MODEL_1); precache_model(ZOMBIE_MODEL_CLAWS); precache_sound(ZOMBIE_RAIN); precache_sound(ZOMBIE_RAIN_INSIDE); precache_sound(ZOMBIE_THUNDER_1); precache_sound(ZOMBIE_THUNDER_2); }
public client_authorized(id) { g_hasSpawned[id] = false; g_isZombie[id] = false; }
public client_disconnect(id) { if(is_user_alive(id)) { if(g_isZombie[id]) { g_zombiesLeft -= 1; if(!g_zombiesLeft) { // No zombies are left, select a new one g_showRoundTimeHud = false; set_task(0.1, "task_chooseZombie"); } } else g_humansLeft -= 1; } set_task(0.2, "task_checkPlayerCount"); }
//////////////////////////////////////////////////////////// /* START Menus */ //////////////////////////////////////////////////////////// public chooseMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; switch(key) { case 0: { // Open the buy menu menu_display(id, g_buyMenu); } case 1: { // Use previous setup client_print(id, print_chat, "The mod is not complete, rebuying is not ready yet."); menu_display(id, g_buyMenu); } case 2: { // Use previous setup until "guns" is typed client_print(id, print_chat, "The mod is not complete, rebuying is not ready yet."); menu_display(id, g_buyMenu); } } return FMRES_HANDLED; }
public buyMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; static Float:gametime; gametime = get_gametime(); if(g_buyWaitTime[id] > gametime) { client_print(id, print_center, "You cannot buy so fast."); menu_display(id, g_buyMenu); return FMRES_HANDLED; } g_buyWaitTime[id] = gametime + 0.5; if(key == MENU_EXIT) return FMRES_HANDLED; switch(key) { case 0: { // Handgun menu_display(id, g_handgunMenu); } case 1: { // Shotgun menu_display(id, g_shotgunMenu); } case 2: { // Sub-Machine Gun menu_display(id, g_smgMenu); } case 3: { // Rifle //menu_display(id, rifleMenu); client_print(id, print_chat, "The mod is not complete, you cannot get a rifle."); menu_display(id, g_buyMenu); } case 4: { // Machine Gun //menu_display(id, machinegunMenu); client_print(id, print_chat, "The mod is not complete, you cannot get a machine gun."); menu_display(id, g_buyMenu); } case 5: { // Equipment //menu_display(id, equipmentMenu); client_print(id, print_chat, "The mod is not complete, you cannot get equipment."); menu_display(id, g_buyMenu); } } return FMRES_HANDLED; }
public handgunMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; menu_display(id, g_buyMenu); if(key == MENU_EXIT) return FMRES_HANDLED; remove_weapon(id, 2); remove_weapon(id, 2); switch(key) { case 0: { // 9X19mm Sidearm fm_give_item(id, "weapon_glock18"); } case 1: { // K&M .45 Tactical fm_give_item(id, "weapon_usp"); } case 2: { // 228 Compact fm_give_item(id, "weapon_p228"); } case 3: { // Night Hawk .50C fm_give_item(id, "weapon_deagle"); } case 4: { // ES Five-Seven fm_give_item(id, "weapon_fiveseven"); } case 5: { // .40 Dual Elites fm_give_item(id, "weapon_elite"); } } return FMRES_HANDLED; }
public shotgunMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; menu_display(id, g_buyMenu); if(key == MENU_EXIT) return FMRES_HANDLED; remove_weapon(id, 1); remove_weapon(id, 1); switch(key) { case 0: { // Leone 12 Gauge Super fm_give_item(id, "weapon_m3"); } case 1: { // Leone YG1265 Auto Shotgun fm_give_item(id, "weapon_xm1014"); } } return FMRES_HANDLED; }
public smgMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; menu_display(id, g_buyMenu); if(key == MENU_EXIT) return FMRES_HANDLED; remove_weapon(id, 1); remove_weapon(id, 1); switch(key) { case 0: { // Schmidt Machine Pistol fm_give_item(id, "weapon_tmp"); } case 1: { // K&M Sub-Machine Gun fm_give_item(id, "weapon_mp5navy"); } case 2: { // K&M UMP45 fm_give_item(id, "weapon_ump45"); } case 3: { // ES C90 fm_give_item(id, "weapon_p90"); } case 4: { // Ingram MAC-10 fm_give_item(id, "weapon_mac10"); } } return FMRES_HANDLED; }
public rifleMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; menu_display(id, g_buyMenu); if(key == MENU_EXIT) return FMRES_HANDLED; remove_weapon(id, 1); remove_weapon(id, 1); switch(key) { case 0: { // Clarion 5.56 fm_give_item(id, "weapon_famas"); } case 1: { // IDF Defender fm_give_item(id, "weapon_galil"); } case 2: { // Maverick M4A1 Carbine fm_give_item(id, "weapon_m4a1"); } case 3: { // CV-47 fm_give_item(id, "weapon_ak47"); } case 4: { // Bullpup fm_give_item(id, "weapon_aug"); } case 5: { // Krieg 552 Commando fm_give_item(id, "weapon_sg552"); } case 6: { // Schmidt Scout fm_give_item(id, "weapon_scout"); } case 7: { // Magnum Sniper Rifle fm_give_item(id, "weapon_awp"); } case 8: { // Krieg 550 Commando fm_give_item(id, "weapon_sg550"); } case 9: { // D3/AU-1 Semi-Auto Sniper Rifle fm_give_item(id, "weapon_g3sg1"); } } return FMRES_HANDLED; }
public machinegunMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; menu_display(id, g_buyMenu); if(key == MENU_EXIT) return FMRES_HANDLED; remove_weapon(id, 1); remove_weapon(id, 1); switch(key) { case 0: { // ES M249 Para fm_give_item(id, "weapon_m249"); } } return FMRES_HANDLED; }
public equipmentMenu_handle(id, menu, key) { //client_print(id, print_chat, "%i", key); if(buy_check(id)) return FMRES_HANDLED; if(key == MENU_EXIT) { menu_display(id, g_buyMenu); return FMRES_HANDLED; } else menu_display(id, g_equipmentMenu); switch(key) { case 0: { // Flashbang fm_give_item(id, "weapon_flashbang"); } case 1: { // HE Grenade fm_give_item(id, "weapon_hegrenade"); } case 2: { // Smoke Grenade fm_give_item(id, "weapon_smokegrenade"); } } return FMRES_HANDLED; }
stock buy_check(id) { if(!is_user_alive(id)) { client_print(id, print_chat, "You must be alive to buy."); return 1; } else if(g_isZombie[id]) { client_print(id, print_chat, "You cannot buy since you are a zombie."); return 1; } else if(g_attackedZombie[id]) { client_print(id, print_chat, "You cannot buy since you already attacked a zombie."); return 1; } return 0; }
public create_menus() { static i; // Choose Menu g_chooseMenu = menu_create("Weapon Select", "chooseMenu_handle"); for(i=0; i<TOTAL_CHOOSE; i++) menu_additem(g_chooseMenu, g_chooseMenuText[i]); menu_setprop(g_chooseMenu, MPROP_EXIT, MEXIT_NEVER); // Buy Menu g_buyMenu = menu_create("Weapon Select", "buyMenu_handle"); /* for(i=0; i<TOTAL_BUY; i++) { if(i == 5) menu_addblank(g_buyMenu, 0); menu_additem(g_buyMenu, buyMenuText[i]); } */ for(i=0; i<3; i++) { if(i == 5) menu_addblank(g_buyMenu, 0); menu_additem(g_buyMenu, g_buyMenuText[i]); } menu_setprop(g_buyMenu, MPROP_PERPAGE, 3); // Handgun Menu g_handgunMenu = menu_create("Choose Handgun", "handgunMenu_handle"); for(i=0; i<TOTAL_HANDGUN; i++) menu_additem(g_handgunMenu, g_handgunMenuText[i]); // Shotgun Menu g_shotgunMenu = menu_create("Choose Shotgun", "shotgunMenu_handle"); for(i=0; i<TOTAL_SHOTGUN; i++) menu_additem(g_shotgunMenu, g_shotgunMenuText[i]); // SMG Menu g_smgMenu = menu_create("Choose SMG", "smgMenu_handle"); for(i=0; i<TOTAL_SMG; i++) menu_additem(g_smgMenu, g_smgMenuText[i]); // Rifle Menu g_rifleMenu = menu_create("Choose Rifle", "rifleMenu_handle"); for(i=0; i<TOTAL_RIFLE; i++) menu_additem(g_rifleMenu, g_rifleMenuText[i]); // Machine Gun Menu g_machinegunMenu = menu_create("Choose Machine Gun", "machinegunMenu_handle"); for(i=0; i<TOTAL_MACHINEGUN; i++) menu_additem(g_machinegunMenu, g_machinegunMenuText[i]); // Equipment Menu g_equipmentMenu = menu_create("Choose Equipment", "equipmentMenu_handle"); for(i=0; i<TOTAL_EQUIPMENT; i++) menu_additem(g_equipmentMenu, g_equipmentMenuText[i]); } //////////////////////////////////////////////////////////// /* END Menus */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Client Command Hooks */ //////////////////////////////////////////////////////////// public openBuyMenu(id) { if(is_user_alive(id) && !g_isZombie[id]) menu_display(id, g_buyMenu); }
public blockTeam(id) { if(g_hasSpawned[id]) return FMRES_IGNORED; return PLUGIN_CONTINUE; }
public blockCommand(id) return FMRES_IGNORED; //////////////////////////////////////////////////////////// /* END Client Command Hooks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Message Hooks */ //////////////////////////////////////////////////////////// public msg_SendAudio() { static audio[65]; get_msg_arg_string(2, audio, 64); if(equali(audio, "%!MRAD_ctwin")) return FMRES_OVERRIDE; else if(equali(audio, "%!MRAD_terwin")) return FMRES_OVERRIDE; else if(equali(audio, "%!MRAD_rounddraw")) return FMRES_OVERRIDE; return FMRES_HANDLED; }
public msg_TextMsg(msgId, dest, ent) { static message[65]; get_msg_arg_string(2, message, 64); // Get end round messages if(equali(message, "#CTs_Win") || equali(message, "#Target_Saved")) { round_ended(); set_msg_arg_string(2, "Human Race Survives!"); return FMRES_HANDLED; } else if(equali(message, "#Terrorists_Win")) { round_ended(); set_msg_arg_string(2, "Zombis Take Over The World!"); return FMRES_HANDLED; } else if(equali(message, "#Round_Draw")) { round_ended(); set_msg_arg_string(2, "Need More Players!"); return FMRES_HANDLED; } else if(equali(message, "#Command_Not_Available")) return FMRES_IGNORED; return FMRES_HANDLED; }
public msg_DeathMsg(msgId, dest, ent) { static killer, victim; killer = get_msg_arg_int(1); victim = get_msg_arg_int(2); if(g_isZombie[victim]) { g_isZombie[victim] = false; cs_reset_user_model(victim); } set_task(0.2, "task_preCheckTeamsDeath"); if(killer == victim) return FMRES_IGNORED; if(g_isZombie[killer]) { g_humansLeft -= 1; message_begin(MSG_ALL, g_msgDeathMsg); write_byte(killer); write_byte(victim); write_byte(0); write_string("Zombie Disease"); message_end(); return FMRES_IGNORED; } else g_zombiesLeft -= 1; return PLUGIN_CONTINUE; }
public msg_RoundTime() { if(g_roundStarted) g_roundStarted = false; else return FMRES_IGNORED; g_roundTime = get_msg_arg_int(1); return FMRES_HANDLED; }
public logevent_round_start() g_roundStarted = true; //////////////////////////////////////////////////////////// /* START Message Hooks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Ham Hooks */ //////////////////////////////////////////////////////////// public hook_TakeDamage(id, idinflictor, idattacker, Float:damage, damagebits) { // Allow fall Damage if(damagebits == DMG_FALL) { if(g_isZombie[id]) return PLUGIN_CONTINUE; damage /= 5; SetHamParamFloat(4, damage) return HAM_HANDLED; } // Do player vs player damage if(is_user_connected(idattacker)) { // Zombie is attacking human if(g_isZombie[idattacker] && !g_isZombie[id]) { if(g_humansLeft <= 1) return PLUGIN_CONTINUE else { g_humansLeft -= 1; set_punchangle(id); set_zombie(id, 0, idattacker); fm_set_user_frags(idattacker, get_user_frags(idattacker)+1); } } // Human is attacking zombie else if(!g_isZombie[idattacker] && g_isZombie[id]) { g_flashHealth[id] = true; g_attackedZombie[idattacker] = true; engfunc(EngFunc_SetClientMaxspeed, id, ZOMBIE_SPEED); return PLUGIN_CONTINUE; } } return HAM_SUPERCEDE; } //////////////////////////////////////////////////////////// /* END Ham Hooks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Event Hooks */ //////////////////////////////////////////////////////////// public hook_WeapPickup(id) g_hasBomb = id;
public hook_HLTV() { // This identifies a new round g_startCountDownTimeZombie = get_gametime(); g_showRoundTimeHud = false; g_showZombieTimeHud = true; // Weather variables g_shouldRain = true; g_weatherOff = false; g_lightningOff = false; if(get_pcvar_num(sv_lightstyle) == 0) engfunc(EngFunc_LightStyle, 0, g_lightStyleChar[0]); g_humansLeft = 0; g_zombiesLeft = 0; }
public hook_CurWeapon(id) { if(!is_user_alive(id)) return FMRES_IGNORED; // Set unlimited backpack ammo static weapon, clip, wpnName[33]; weapon = read_data(2); clip = read_data(3); get_weaponname(weapon, wpnName, 32); if(clip < 2 && !equal(wpnName, "weapon_knife")) cs_set_user_bpammo(id, weapon, 200); return FMRES_HANDLED; }
public hook_ResetHUD(id) { if(!g_hasSpawned[id]) g_hasSpawned[id] = true; // If player joins terrorist when there is a zombie, set to CT if(g_zombiesLeft > 0 && fm_get_user_team(id) == 1) set_user_team(id, 2); set_lightstyle(get_pcvar_num(sv_lightstyle)); g_isZombie[id] = false; g_attackedZombie[id] = false; set_task(0.7, "task_afterSpawn", id); }
public task_afterSpawn(id) { if(!is_user_alive(id)) return FMRES_IGNORED; message_begin(MSG_ONE, g_msgNVGToggle, _, id); write_byte(0); message_end(); if(get_playersnum(1) == 1 && g_canRestart) { server_cmd("sv_restart 1"); g_canRestart = false; return FMRES_HANDLED; } if(g_hasBomb == id) { fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); } menu_cancel(id); menu_display(id, g_buyMenu); cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM); message_begin(MSG_ONE_UNRELIABLE, g_msgHideWeapon, _, id); write_byte((1<<3) | (1<<4) | (1<<5)); message_end(); g_humansLeft += 1; return FMRES_HANDLED; } //////////////////////////////////////////////////////////// /* END Event Hooks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Forward Hooks */ //////////////////////////////////////////////////////////// public fwd_AddToFullPack(es_handle, e, id, host, hostflags, player, pSet) { if(!player || !is_user_alive(id) || !is_user_alive(host) || g_isZombie[host] || id == host || g_weatherOff || get_pcvar_num(sv_lightstyle) > 0) return FMRES_IGNORED; static orgID[3], orgHost[3], distance, transparency; get_user_origin(id, orgID); get_user_origin(host, orgHost); distance = get_distance(orgID, orgHost); switch(distance) { case 0 .. 860: { transparency = floatround((289.0 - (float(distance) / 3.0))); set_es(es_handle, ES_RenderMode, kRenderTransTexture); set_es(es_handle, ES_RenderAmt, transparency); //client_print(0, print_chat, "[ID = %i] [Host = %i] [Dis = %i] - %i", id, host, distance, transparency); } default: { if(g_isFlashing) { // Make everyones transparency set amount if it's lightning set_es(es_handle, ES_RenderMode, kRenderTransTexture); set_es(es_handle, ES_RenderAmt, 25); return FMRES_IGNORED; } else { set_es(es_handle, ES_RenderMode, kRenderTransTexture); set_es(es_handle, ES_RenderAmt, 0); } //client_print(0, print_chat, "[ID = %i] [Host = %i] [Dis = %i] - 0", id, host, distance); } } return FMRES_IGNORED; }
public fwd_CVarSetFloat(const name[], Float:value) { if(equali(name, "sv_accelerate")) { static Float:accelerate; accelerate = get_pcvar_float(sv_accelerate); set_cvar_float("sv_accelerate", accelerate); return FMRES_SUPERCEDE; } else if(equali(name, "sv_stopspeed")) { static Float:stopspeed; stopspeed = get_pcvar_float(sv_stopspeed); set_cvar_float("sv_stopspeed", stopspeed); return FMRES_SUPERCEDE; } return FMRES_HANDLED; }
public fwd_ClientKill(id) return FMRES_SUPERCEDE;
public fwd_Touch(ent, id) { if(!is_user_alive(id)) return FMRES_IGNORED; static className[32]; pev(ent, pev_classname, className, 31); if(containi(className, "weaponbox") != -1 && g_isZombie[id]) return FMRES_SUPERCEDE; return FMRES_HANDLED; }
public fwd_EmitSound(id, channel, const sound[], Float:volume, Float:attenuation, flags, pitch) { if(!is_user_connected(id)) return FMRES_IGNORED; // client_print(id, print_chat, "[Chan=%d] [Sound=%s] [Vol=%f] [Att=%f] [Flags=%d] [Pitch=%d]", channel, sound, volume, attenuation, flags, pitch); // Play death sounds if(containi(sound, "die") != -1 || containi(sound, "death") != -1) { if(g_isZombie[id]) { engfunc(EngFunc_EmitSound, id, channel, g_zombieDie[random_num(0, ZOMBIE_DIE_NUM-1)], volume, attenuation, flags, pitch); return FMRES_SUPERCEDE; } } // Play pain sounds if(containi(sound, "bhit") != -1) { if(g_isZombie[id]) engfunc(EngFunc_EmitSound, id, channel, g_zombiePain[random_num(0, ZOMBIE_PAIN_NUM-1)], volume, attenuation, flags, pitch); else engfunc(EngFunc_EmitSound, id, channel, g_humanPain[random_num(0, HUMAN_PAIN_NUM-1)], volume, attenuation, flags, pitch); return FMRES_SUPERCEDE; } // Knife slash sounds to claw swipes if(containi(sound, "knife_slash") != -1) { if(g_isZombie[id]) { // Play claw swipe engfunc(EngFunc_EmitSound, id, channel, g_zombieMiss[random_num(0, ZOMBIE_MISS_NUM-1)], volume, attenuation, flags, pitch); return FMRES_SUPERCEDE; } } // Knife hit sounds to claw hit if(containi(sound, "knife_hit") != -1) { if(g_isZombie[id]) { // Play claw hit engfunc(EngFunc_EmitSound, id, channel, g_zombieHit[random_num(0, ZOMBIE_HIT_NUM-1)], volume, attenuation, flags, pitch); return FMRES_SUPERCEDE; } } if(containi(sound, "gunpickup2") != -1 || containi(sound, "knife_deploy") != -1) { if(g_isZombie[id]) return FMRES_SUPERCEDE; } return FMRES_IGNORED; }
public fwd_PlayerPreThink(id) { static Float:gametime; gametime = get_gametime(); if(!is_user_alive(id)) { // Update nightvision static lightStyle; lightStyle = get_pcvar_num(sv_lightstyle); if(lightStyle == 0 || lightStyle == 1) { if(g_reUpdateDeadNV[id] < gametime) { g_didDeadCheck[id] = false; g_reUpdateDeadNV[id] = gametime + 5.0; } if(is_user_connected(id) && !g_didDeadCheck[id]) { // Set nightvision g_didDeadCheck[id] = true; message_begin(MSG_ONE_UNRELIABLE, g_msgNVGToggle, _, id); write_byte(1); message_end(); } else if(is_user_connected(id) && g_didDeadCheck[id] && g_weatherOff) { message_begin(MSG_ONE_UNRELIABLE, g_msgNVGToggle, _, id); write_byte(0); message_end(); } } // Show round time to dead players if(g_nextHudMsg[id] < gametime) { // Show countdown after round start till zombie if(g_showZombieTimeHud) { set_hudmessage(255, 0, 0, -1.0, 0.20, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); if(g_timeTillZombie >= COUNTDOWN_TIME - g_freezeTime) ShowSyncHudMsg(id, g_countdownHudMsg, "Selecting Zombie: %i^nFreeze Time: %i", floatround(g_timeTillZombie), floatround(g_timeTillZombie - (COUNTDOWN_TIME - g_freezeTime))); else ShowSyncHudMsg(id, g_countdownHudMsg, "Selecting Zombie: %i", floatround(g_timeTillZombie)); } // Show round time count down else if(g_showRoundTimeHud) { set_hudmessage(255, 0, 0, -1.0, 0.20, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); ShowSyncHudMsg(id, g_countdownHudMsg, "Round Time Left: %i", floatround(g_roundTimeLeft)); } g_nextHudMsg[id] = gametime + HUDMSG_TIME - 0.1; } return FMRES_IGNORED; } // Show the hud messages for during round if(g_nextHudMsg[id] < gametime) { static text[HUD_MSG_LEN], ln; ln = 0; // Show health hud message static statustype[2][] = { "Zombie", "Human" }; static armortype[2][] = { "Skin", "Armor" }; static type; if(g_isZombie[id]) type = 0; else type = 1; ln += format(text[ln], HUD_MSG_LEN-1-ln, "Status: %s^n", statustype[type]); ln += format(text[ln], HUD_MSG_LEN-1-ln, "Health: %i^n", pev(id, pev_health)); ln += format(text[ln], HUD_MSG_LEN-1-ln, "%s: %i", armortype[type], get_user_armor(id)); if(g_flashHealth[id]) { if(g_isZombie[id] && get_pcvar_num(sv_lightstyle) != 0) set_hudmessage(255, 0, 0, 0.02, 0.88, 1, 0.0, HUDMSG_TIME, 0.0, 0.0); else set_hudmessage(0, 255, 0, 0.02, 0.88, 1, 0.0, HUDMSG_TIME, 0.0, 0.0); g_flashHealthCount[id] += 1; if(g_flashHealthCount[id] == 3) { g_flashHealth[id] = false; g_flashHealthCount[id] = 0; } } else { if(g_isZombie[id] && get_pcvar_num(sv_lightstyle) != 0) set_hudmessage(255, 0, 0, 0.02, 0.88, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); else set_hudmessage(0, 255, 0, 0.02, 0.88, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); } ShowSyncHudMsg(id, g_healthHudMsg, text); // Show player count hud message if(g_zombiesLeft || g_humansLeft) { if(g_isZombie[id] && get_pcvar_num(sv_lightstyle) != 0) set_hudmessage(255, 0, 0, 0.83, 0.50, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); else set_hudmessage(0, 255, 0, 0.83, 0.50, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); ShowSyncHudMsg(id, g_playerCountHudMsg, "Zombies Left: %i^nHumans Left: %i", g_zombiesLeft, g_humansLeft); } // Show countdown after round start till zombie if(g_showZombieTimeHud) { set_hudmessage(0, 255, 0, -1.0, 0.02, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); if(g_timeTillZombie >= COUNTDOWN_TIME - g_freezeTime) ShowSyncHudMsg(id, g_countdownHudMsg, "Selecting Zombie: %i^nFreeze Time: %i", floatround(g_timeTillZombie), floatround(g_timeTillZombie - (COUNTDOWN_TIME - g_freezeTime))); else ShowSyncHudMsg(id, g_countdownHudMsg, "Selecting Zombie: %i", floatround(g_timeTillZombie)); } // Show round time count down else if(g_showRoundTimeHud) { if(g_isZombie[id] && get_pcvar_num(sv_lightstyle) != 0) set_hudmessage(255, 0, 0, -1.0, 0.02, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); else set_hudmessage(0, 255, 0, -1.0, 0.02, 0, 0.0, HUDMSG_TIME, 0.0, 0.0); ShowSyncHudMsg(id, g_countdownHudMsg, "Round Time Left: %i", floatround(g_roundTimeLeft)); } g_nextHudMsg[id] = gametime + HUDMSG_TIME - 0.1; } return FMRES_HANDLED; }
public fwd_Think(entId) { if(!pev_valid(entId)) return FMRES_IGNORED; // Counter if(entId == g_counterEnt) { // Do the Huds if(g_showZombieTimeHud) { g_totalTime = get_gametime() - g_startCountDownTimeZombie; // Counts up, 1,2,3,4,5,etc g_timeTillZombie = COUNTDOWN_TIME - g_totalTime; // Counts down, 15,14,13,etc... g_freezeTime = get_pcvar_float(mp_freezetime); if(g_timeTillZombie >= COUNTDOWN_TIME - g_freezeTime) { if(g_timeTillZombie - (COUNTDOWN_TIME - g_freezeTime) < 0.1) g_startCountDownTimeRound = get_gametime(); } else { if(g_timeTillZombie < 0.1) { g_showZombieTimeHud = false; set_task(0.1, "task_chooseZombie"); } } } else if(g_showRoundTimeHud) { g_totalTime = get_gametime() - g_startCountDownTimeRound; g_roundTimeLeft = g_roundTime - (g_roundTime - (g_roundTime - g_totalTime)); if(g_roundTimeLeft < 8.5 && g_roundTimeLeft > 8.3 && get_pcvar_num(sv_storm) == 1) set_pev(g_thunderEnt, pev_nextthink, get_gametime() + 9999.0); else if(g_roundTimeLeft < 0.2) g_showRoundTimeHud = false; else if(g_roundTimeLeft < 1.0 && get_pcvar_num(sv_storm) == 1) { if(g_shouldRain) { g_shouldRain = false; set_pev(g_thunderEnt, pev_nextthink, get_gametime() + 0.4); } } } // Do the nightvision for players if lightlevel is 0 if(!get_pcvar_num(sv_lightstyle)) { static Players[32], playerCount, i, id, origin[3]; get_players(Players, playerCount, "ach"); for(i=0; i<playerCount; i++) { id = Players[i]; get_user_origin(id, origin); if(g_isZombie[id]) { // Zombie message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id); write_byte(TE_DLIGHT); // 27 write_coord(origin[0]); write_coord(origin[1]); write_coord(origin[2]); write_byte(ZOMBIE_LIGHT_RADIUS); // radius write_byte(255); // r write_byte(1); // g write_byte(1); // b write_byte(2); // life in 10's write_byte(1); // decay rate in 10's message_end(); } else { // Human message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id); write_byte(TE_DLIGHT); // 27 write_coord(origin[0]); write_coord(origin[1]); write_coord(origin[2]); write_byte(HUMAN_LIGHT_RADIUS); // radius write_byte(1); // r write_byte(1); // g write_byte(1); // b write_byte(2); // life in 10's write_byte(1); // decay rate in 10's message_end(); } } } set_pev(entId, pev_nextthink, get_gametime() + HUD_LIGHT_UPDATE_TIME); } // Thunder / Lightning else if(entId == g_thunderEnt) { if(g_shouldRain) { static thinkReturn; if(!g_isFlashing) { if(random_num(0, 1)) set_pev(entId, pev_message, ZOMBIE_THUNDER_1); else set_pev(entId, pev_message, ZOMBIE_THUNDER_2); g_isFlashing = true; g_flashNum = random_num(1, 3); dllfunc(DLLFunc_Use, entId, 0); } if(get_pcvar_num(sv_lightstyle) == 0) thinkReturn = lightning(); if(thinkReturn) set_pev(entId, pev_nextthink, get_gametime() + random_float(5.5, 15.5)); else set_pev(entId, pev_nextthink, get_gametime() + 0.1); } else { if(!g_lightningOff) { // Make it turn to daylight static thinkReturn; if(!g_isFlashing) { g_isFlashing = true; g_flashNum = 4; } if(get_pcvar_num(sv_lightstyle) == 0) thinkReturn = lightning(); if(thinkReturn) { g_lightningOff = true; set_pev(entId, pev_nextthink, get_gametime() + random_float(2.5, 12.5)); } else set_pev(entId, pev_nextthink, get_gametime() + 0.1); } else set_pev(entId, pev_nextthink, get_gametime() + random_float(2.5, 12.5)); } } // Rain else if(entId == g_rainEnt) { if(g_shouldRain) { static Players[32], playerCount, player, i, Float:gametime; gametime = get_gametime(); get_players(Players, playerCount, "ch"); for(i=0; i<playerCount; i++) { player = Players[i]; if(is_user_outside(player)) { g_newLocation[player] = true; if(g_nextRainSound[player] < gametime && g_oldLocation[player] == g_newLocation[player]) { g_oldLocation[player] = true; client_cmd(player, "speak %s;cl_weather 1", ZOMBIE_RAIN); g_nextRainSound[player] = gametime + 2.0; } else if(g_oldLocation[player] != g_newLocation[player]) { g_oldLocation[player] = true; client_cmd(player, "speak %s;cl_weather 1", ZOMBIE_RAIN); } } else { g_newLocation[player] = false; if(g_nextRainSound[player] < gametime && g_oldLocation[player] == g_newLocation[player]) { g_oldLocation[player] = false; client_cmd(player, "speak %s;cl_weather 1", ZOMBIE_RAIN_INSIDE); g_nextRainSound[player] = gametime + 2.0; } else if(g_oldLocation[player] != g_newLocation[player]) { g_oldLocation[player] = false; client_cmd(player, "speak %s;cl_weather 1", ZOMBIE_RAIN_INSIDE); } } } } else { if(!g_weatherOff) { g_weatherOff = true; static Players[32], playerCount, player, i; get_players(Players, playerCount, "ch"); for(i=0; i<playerCount; i++) { player = Players[i]; client_cmd(player, "speak NULL;cl_weather 0"); } } } set_pev(entId, pev_nextthink, get_gametime() + 0.3); } return FMRES_HANDLED; }
public fwd_KeyValue(entId, kvd_id) { if(!pev_valid(entId)) return FMRES_IGNORED; static className[64]; get_kvd(kvd_id, KV_ClassName, className, 63); if(!g_buyzoneMade) { g_buyzoneMade = true; // Make the buyzone new buy = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_buyzone")); engfunc(EngFunc_SetOrigin, buy, Float:{0.0,0.0,-55000.0}); engfunc(EngFunc_SetSize, buy, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0}); set_keyvalue(buy, "team", "0"); dllfunc(DLLFunc_Spawn, buy); // Make the bomb stuff new bomb = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_bomb_target")); engfunc(EngFunc_SetOrigin, bomb, Float:{0.0,0.0,-55100.0}); engfunc(EngFunc_SetSize, bomb, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0}); dllfunc(DLLFunc_Spawn, bomb); } if(containi(className, "func_bomb_target") != -1 || containi(className, "info_bomb_target") != -1 || containi(className, "hostage_entity") != -1 || containi(className, "monster_scientist") != -1 || containi(className, "func_hostage_rescue") != -1 || containi(className, "info_hostage_rescue") != -1 || containi(className, "info_vip_start") != -1 || containi(className, "func_vip_safetyzone") != -1 || containi(className, "func_escapezone") != -1 || containi(className, "func_buyzone") != -1) engfunc(EngFunc_RemoveEntity, entId); return FMRES_HANDLED; } //////////////////////////////////////////////////////////// /* END Forward Hooks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Tasks */ //////////////////////////////////////////////////////////// public task_preCheckTeamsDeath(id) check_teams(0);
public task_preCheckTeams(id) check_teams(13337);
public task_checkPlayerCount() { if(get_playersnum(0) == 0) g_canRestart = true; }
public task_chooseZombie() { static Players[32], playerCount, i, id, player, name[33]; g_humansLeft = 0; g_zombiesLeft = 0; get_players(Players, playerCount, "ah"); switch(playerCount) { case 0: return FMRES_HANDLED; case 1: { id = Players[0]; g_zombiesLeft = 1; } default: { // Choose Zombie and set zombie amount to 1 id = Players[random(playerCount)]; g_zombiesLeft = 1; // Set everyone else humans and get the human amount for(i=0; i<playerCount; i++) { player = Players[i]; if(player != id) { g_humansLeft += 1; set_human(player); } } } } get_user_name(id, name, 32); set_zombie(id, 1, 0); set_hudmessage(0, 255, 0, -1.0, 0.02, 2, 0.06, 6.0, 0.05, 0.03); ShowSyncHudMsg(0, g_countdownHudMsg, "Watch Out!^n%s is the zombie!", name); set_task(6.5, "task_setRoundTimeHud"); return FMRES_HANDLED; }
public task_setRoundTimeHud() g_showRoundTimeHud = true; //////////////////////////////////////////////////////////// /* END Tasks */ ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /* START Stocks */ //////////////////////////////////////////////////////////// stock fm_get_user_team(id) return get_pdata_int(id, 114);
stock round_ended() { static PlayersAll[32], playerCount, i, id; // Set the humans and zombies amount left for the hud g_humansLeft = 0; g_zombiesLeft = 0; get_players(PlayersAll, playerCount, "h"); // Remove players zombie status if they have it for(i=0; i<playerCount; i++) { id = PlayersAll[i]; if(g_isZombie[id]) { g_isZombie[id] = false; // Remove zombie arms static weapon, weaponName[33]; weapon = get_user_weapon(id); get_weaponname(weapon, weaponName, 32); if(equal(weaponName, "weapon_knife")) { set_pev(id, pev_viewmodel2, "models/v_knife.mdl"); set_pev(id, pev_weaponmodel2, "models/p_knife.mdl"); } cs_reset_user_model(id); } } set_task(0.2, "task_preCheckTeams"); }
stock check_teams(type) { // Type 0 = Regular check // Type 13337 = Last round check static PlayersAll[32], PlayersCT[32], PlayersT[32], playerCount, pCountCT, pCountT, i, id, uneven, unevenby; get_players(PlayersAll, playerCount, "h"); // Get Terrorists pCountT = 0; for(i=0; i<playerCount; i++) { id = PlayersAll[i]; if(fm_get_user_team(id) != 1) continue; PlayersT[i] = id; pCountT += 1; } // Get Counter-Terrorists pCountCT = 0; for(i=0; i<playerCount; i++) { id = PlayersAll[i]; if(fm_get_user_team(id) != 2) continue; PlayersCT[i] = id; pCountCT += 1; } // Balance the teams uneven = abs(pCountT - pCountCT) / 2; if(type > 0) { unevenby = 0; if(pCountT > pCountCT) unevenby = pCountT - pCountCT; else if(pCountCT > pCountT) unevenby = pCountCT - pCountT; if(uneven > 1) client_print(0, print_chat, "[ZD] The teams are uneven by %i [%i on T] [%i on CT]. Switching %i players.", unevenby, pCountT, pCountCT, uneven-1); else client_print(0, print_chat, "[ZD] The teams are uneven by %i [%i on T] [%i on CT]. Teams are fine.", unevenby, pCountT, pCountCT); } for(i=0; i<playerCount; i++) { id = PlayersAll[i]; if(uneven > 1) { if(pCountT > pCountCT) { // There are more T than CT if(!type) { if(fm_get_user_team(id) == 1 && !is_user_alive(id)) { // Move this player to CT set_user_team(id, 2); uneven -= 1; } } else { if(fm_get_user_team(id) == 1) { // Move this player to CT set_user_team(id, 2); uneven -= 1; } } } else { // There are more CT than T if(!type) { if(fm_get_user_team(id) == 2 && !is_user_alive(id)) { // Move this player to T set_user_team(id, 1); uneven -= 1; } } else { if(fm_get_user_team(id) == 2) { // Move this player to T set_user_team(id, 1); uneven -= 1; } } } } else break; } return FMRES_HANDLED; }
stock set_lightstyle(num) { switch(num) { case 1: engfunc(EngFunc_LightStyle, 0, "b"); case 2: engfunc(EngFunc_LightStyle, 0, "c"); case 3: engfunc(EngFunc_LightStyle, 0, "d"); case 4: engfunc(EngFunc_LightStyle, 0, "e"); case 5: engfunc(EngFunc_LightStyle, 0, "f"); case 6: engfunc(EngFunc_LightStyle, 0, "g"); case 7: engfunc(EngFunc_LightStyle, 0, "h"); case 8: engfunc(EngFunc_LightStyle, 0, "i"); case 9: engfunc(EngFunc_LightStyle, 0, "j"); case 10: engfunc(EngFunc_LightStyle, 0, "k"); case 11: engfunc(EngFunc_LightStyle, 0, "l"); case 12: engfunc(EngFunc_LightStyle, 0, "m"); case 13: engfunc(EngFunc_LightStyle, 0, "n"); case 14: engfunc(EngFunc_LightStyle, 0, "o"); case 15: engfunc(EngFunc_LightStyle, 0, "p"); case 16: engfunc(EngFunc_LightStyle, 0, "q"); case 17: engfunc(EngFunc_LightStyle, 0, "r"); case 18: engfunc(EngFunc_LightStyle, 0, "s"); case 19: engfunc(EngFunc_LightStyle, 0, "t"); case 20: engfunc(EngFunc_LightStyle, 0, "u"); case 21: engfunc(EngFunc_LightStyle, 0, "v"); case 22: engfunc(EngFunc_LightStyle, 0, "w"); case 23: engfunc(EngFunc_LightStyle, 0, "x"); case 24: engfunc(EngFunc_LightStyle, 0, "y"); case 25: engfunc(EngFunc_LightStyle, 0, "z"); default: engfunc(EngFunc_LightStyle, 0, "a"); } }
stock set_zombie(id, type, attacker) { g_isZombie[id] = true; if(type) { set_pev(id, pev_health, ZOMBIE_HEALTH_MAIN); cs_set_user_armor(id, ZOMBIE_ARMOR_MAIN, CS_ARMOR_VESTHELM); } else { set_pev(id, pev_health, ZOMBIE_HEALTH_AFTER); cs_set_user_armor(id, ZOMBIE_ARMOR_AFTER, CS_ARMOR_VESTHELM); message_begin(MSG_ALL, g_msgDeathMsg); write_byte(attacker); write_byte(id); write_byte(0); write_string("Zombie Disease"); message_end(); g_zombiesLeft += 1; } if(fm_get_user_team(id) == 2) set_user_team(id, 1); cs_set_user_model(id, ZOMBIE_MODEL_1_NICK); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); if(get_pcvar_num(sv_lightstyle) != 0) { message_begin(MSG_ONE, g_msgNVGToggle, _, id); write_byte(1); message_end(); } message_begin(MSG_ALL, g_msgScoreAttrib); write_byte(id); write_byte(0); message_end(); set_pev(id, pev_viewmodel2, ZOMBIE_MODEL_CLAWS); // Set to 1st person claws set_pev(id, pev_weaponmodel2, ""); // Set to nothing engfunc(EngFunc_SetClientMaxspeed, id, ZOMBIE_SPEED); engfunc(EngFunc_EmitSound, id, CHAN_AUTO, g_zombieInfect[random_num(0, ZOMBIE_INFECT_NUM-1)], 1.0, 0.8, 0, 100); g_flashHealth[id] = true; }
stock set_human(id) { if(fm_get_user_team(id) == 1) set_user_team(id, 2); }
stock set_user_team(id, team) { switch(team) { case 1: { // Terrorist set_pdata_int(id, 114, 1); message_begin(MSG_ALL, g_msgTeamInfo); write_byte(id); write_string("TERRORIST"); message_end(); } case 2: { // CT set_pdata_int(id, 114, 2); message_begin(MSG_ALL, g_msgTeamInfo); write_byte(id); write_string("CT"); message_end(); } } }
stock set_punchangle(id) { static Float:punchangle[3]; punchangle[0] = random_float(-50.0, 50.0); punchangle[1] = random_float(-50.0, 50.0); punchangle[2] = random_float(-50.0, 50.0); set_pev(id, pev_punchangle, punchangle); return FMRES_HANDLED; }
stock lightning() { switch(g_flashNum) { // Flash 1 time case 1: { g_lightCounter += 1; switch(g_lightCounter) { case 1: g_lightStyleNum = 1; case 2: g_lightStyleNum = 2; case 3: g_lightStyleNum = 1; case 4: g_lightStyleNum = 0; } engfunc(EngFunc_LightStyle, 0, g_lightStyleChar[g_lightStyleNum]); // Set sky color to lightning brightness /* switch(g_lightStyleNum) { case 0: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[0], g_skyColors[0], g_skyColors[0]); case 1: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[1], g_skyColors[1], g_skyColors[1]); case 2: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[2], g_skyColors[2], g_skyColors[2]); } */ if(g_lightCounter == 4) { g_lightCounter = 0; g_isFlashing = false; return 1; } else return 0; } // Flash 2 times case 2: { g_lightCounter += 1; switch(g_lightCounter) { case 1: g_lightStyleNum = 1; case 2: g_lightStyleNum = 2; case 3: g_lightStyleNum = 1; case 4: g_lightStyleNum = 2; case 5: g_lightStyleNum = 1; case 6: g_lightStyleNum = 0; } engfunc(EngFunc_LightStyle, 0, g_lightStyleChar[g_lightStyleNum]); // Set sky color to lightning brightness /* switch(g_lightStyleNum) { case 0: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[0], g_skyColors[0], g_skyColors[0]); case 1: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[1], g_skyColors[1], g_skyColors[1]); case 2: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[2], g_skyColors[2], g_skyColors[2]); } */ if(g_lightCounter == 6) { g_lightCounter = 0; g_isFlashing = false; return 1; } else return 0; } // Flash 3 times case 3: { g_lightCounter += 1; switch(g_lightCounter) { case 1: g_lightStyleNum = 1; case 2: g_lightStyleNum = 2; case 3: g_lightStyleNum = 1; case 4: g_lightStyleNum = 2; case 5: g_lightStyleNum = 1; case 6: g_lightStyleNum = 2; case 7: g_lightStyleNum = 1; case 8: g_lightStyleNum = 0; } engfunc(EngFunc_LightStyle, 0, g_lightStyleChar[g_lightStyleNum]); // Set sky color to lightning brightness /* switch(g_lightStyleNum) { case 0: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[0], g_skyColors[0], g_skyColors[0]); case 1: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[1], g_skyColors[1], g_skyColors[1]); case 2: server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", g_skyColors[2], g_skyColors[2], g_skyColors[2]); } */ if(g_lightCounter == 8) { g_lightCounter = 0; g_isFlashing = false; return 1; } else return 0; } // Turn to daylight case 4: { g_lightCounter += 1; switch(g_lightCounter) { case 1: { engfunc(EngFunc_LightStyle, 0, "b"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 20, 20, 20); } case 2: { engfunc(EngFunc_LightStyle, 0, "c"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 30, 30, 30); } case 3: { engfunc(EngFunc_LightStyle, 0, "d"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 40, 40, 40); } case 4: { engfunc(EngFunc_LightStyle, 0, "e"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 50, 50, 50); } case 5: { engfunc(EngFunc_LightStyle, 0, "f"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 60, 60, 60); } case 6: { engfunc(EngFunc_LightStyle, 0, "g"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 75, 75, 75); } case 7: { engfunc(EngFunc_LightStyle, 0, "h"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 90, 90, 90); } case 8: { engfunc(EngFunc_LightStyle, 0, "i"); server_cmd("sv_skycolor_r %i;sv_skycolor_g %i;sv_skycolor_b %i", 105, 105, 105); } } if(g_lightCounter == 8) { g_lightCounter = 0; g_isFlashing = false; return 1; } else return 0; } } return 1; }
stock bool:is_user_outside(id) { static Float:origin[3], Float:savedOrg; pev(id, pev_origin, origin); savedOrg = origin[2]; // Get org 1 origin[0] += RAIN_INSIDE_DIST / 2; while(engfunc(EngFunc_PointContents, origin) == -1) origin[2] += 5.0; if(engfunc(EngFunc_PointContents, origin) == -6) return true; // Get org 2 origin[0] -= RAIN_INSIDE_DIST; origin[2] = savedOrg; while(engfunc(EngFunc_PointContents, origin) == -1) origin[2] += 5.0; if(engfunc(EngFunc_PointContents, origin) == -6) return true; // Get org 3 origin[0] += RAIN_INSIDE_DIST / 2; origin[1] += RAIN_INSIDE_DIST / 2; origin[2] = savedOrg; while(engfunc(EngFunc_PointContents, origin) == -1) origin[2] += 5.0; if(engfunc(EngFunc_PointContents, origin) == -6) return true; // Get org 4 origin[1] -= RAIN_INSIDE_DIST; origin[2] = savedOrg; while(engfunc(EngFunc_PointContents, origin) == -1) origin[2] += 5.0; if(engfunc(EngFunc_PointContents, origin) == -6) return true; return false; }
stock set_keyvalue(ent, key[], value[]) { static classname[32]; pev(ent, pev_classname, classname, 31); set_kvd(0, KV_ClassName, classname); set_kvd(0, KV_KeyName, key); set_kvd(0, KV_Value, value); set_kvd(0, KV_fHandled, 0); dllfunc(DLLFunc_KeyValue, ent, 0); }
stock fm_set_user_frags(index, frags) { set_pev(index, pev_frags, float(frags)); message_begin(MSG_ALL, g_msgScoreInfo); write_byte(index); write_short(frags); write_short(cs_get_user_deaths(index)); write_short(0); write_short(fm_get_user_team(index)); message_end(); return 1; }
stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") { new ent_class[32]; if(!wid && wname[0]) copy(ent_class, sizeof ent_class - 1, wname); else { new weapon = wid, clip, ammo; if(!weapon && !(weapon = get_user_weapon(index, clip, ammo))) return false; get_weaponname(weapon, ent_class, sizeof ent_class - 1); } new ent_weap = fm_find_ent_by_owner(-1, ent_class, index) if(!ent_weap) return false; engclient_cmd(index, "drop", ent_class); new ent_box = pev(ent_weap, pev_owner); if(!ent_box || ent_box == index) return false; dllfunc(DLLFunc_Think, ent_box); return true; }
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) { new strtype[11] = "classname", ent = index; switch (jghgtype) { case 1: strtype = "target"; case 2: strtype = "targetname"; } while((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {} return ent; }
stock fm_give_item(index, const item[]) { if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10)) return 0 new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item)); if (!pev_valid(ent)) return 0 new Float:origin[3] pev(index, pev_origin, origin) set_pev(ent, pev_origin, origin) set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN) dllfunc(DLLFunc_Spawn, ent) new save = pev(ent, pev_solid) dllfunc(DLLFunc_Touch, ent, index) if (pev(ent, pev_solid) != save) return ent engfunc(EngFunc_RemoveEntity, ent) return -1 }
stock remove_weapon(id, type) { static Weapons[32], numWeapons, i, weapon, weaponName[33]; get_user_weapons(id, Weapons, numWeapons); for(i=0; i<numWeapons; i++) { weapon = Weapons[i]; if(!weapon) continue; get_weaponname(weapon, weaponName, 32); switch(type) { case 1: { if(equal(weaponName, "weapon_m3") || equal(weaponName, "weapon_xm1014") || equal(weaponName, "weapon_tmp") || equal(weaponName, "weapon_mp5navy") || equal(weaponName, "weapon_ump45") || equal(weaponName, "weapon_p90") || equal(weaponName, "weapon_mac10") || equal(weaponName, "weapon_famas") || equal(weaponName, "weapon_galil") || equal(weaponName, "weapon_m4a1") || equal(weaponName, "weapon_ak47") || equal(weaponName, "weapon_aug") || equal(weaponName, "weapon_sg552") || equal(weaponName, "weapon_scout") || equal(weaponName, "weapon_awp") || equal(weaponName, "weapon_sg550") || equal(weaponName, "weapon_g3sg1") || equal(weaponName, "weapon_m249")) { fm_strip_user_gun(id, weapon); //break; } } case 2: { if(equal(weaponName, "weapon_glock18") || equal(weaponName, "weapon_usp") || equal(weaponName, "weapon_p228") || equal(weaponName, "weapon_deagle") || equal(weaponName, "weapon_fiveseven") || equal(weaponName, "weapon_elite")) { fm_strip_user_gun(id, weapon); //break; } } case 3: { if(equal(weaponName, "weapon_knife")) { fm_strip_user_gun(id, weapon); //break; } } case 4: { if(equal(weaponName, "weapon_flashbang") || equal(weaponName, "weapon_hegrenade") || equal(weaponName, "weapon_smokegrenade")) { fm_strip_user_gun(id, weapon); //break; } } case 5: { if(equal(weaponName, "weapon_c4")) { fm_strip_user_gun(id, weapon); //break; } } } } }
stock fm_strip_user_weapons(index) { new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip")); if (!pev_valid(ent)) return 0 dllfunc(DLLFunc_Spawn, ent) dllfunc(DLLFunc_Use, ent, index) engfunc(EngFunc_RemoveEntity, ent) return 1 } //////////////////////////////////////////////////////////// /* END Stocks */ ////////////////////////////////////////////////////////////
Sounds and models included (some sounds taken from other mods)...
Last edited by hlstriker; 02-25-2008 at 09:29.
|
|