Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- static const String:MODEL_NICK[] = "models/survivors/survivor_gambler.mdl";
- static const String:MODEL_ROCHELLE[] = "models/survivors/survivor_producer.mdl";
- static const String:MODEL_COACH[] = "models/survivors/survivor_coach.mdl";
- static const String:MODEL_ELLIS[] = "models/survivors/survivor_mechanic.mdl";
- #define MODEL_BILL "models/survivors/survivor_namvet.mdl"
- #define MODEL_ZOEY "models/survivors/survivor_teenangst.mdl"
- #define MODEL_FRANCIS "models/survivors/survivor_biker.mdl"
- #define MODEL_LOUIS "models/survivors/survivor_manager.mdl"
- #define MODEL_KIT "models/w_models/weapons/w_eq_medkit.mdl"
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #define PLUGIN_VERSION "1.0"
- static bool:CoachExists = false;
- static bool:EllisExists = false;
- static bool:RochelleExists = false;
- static bool:NickExists = false;
- static bool:BillExists = false;
- static bool:FrancisExists = false;
- static bool:LouisExists = false;
- static bool:ZoeyExists = false;
- /* Plugin Information */
- public Plugin:myinfo = {
- name = "[L4D2] Missing Survivor Fix",
- author = "DeathChaos25",
- description = "",
- url = ""
- }
- public OnMapStart()
- {
- ServerCommand("exec server");
- }
- public void OnPluginStart()
- {
- HookEvent("item_pickup", FIXBOTS);
- HookEvent("round_start", Event_RoundStart, EventHookMode_Post);
- }
- public FIXBOTS(Handle:event, const String:name[], bool:dontBroadcast)
- {
- CreateTimer(0.2, FixBots);
- CreateTimer(0.3, CheckMaxPlayers);
- }
- public Action:Event_RoundStart(Handle:event, String:name[], bool:dontBroadcast)
- {
- CreateTimer(10.0, GiveItems);
- }
- public Action:GiveItems(Handle:Timer)
- {
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsSurvivor(i))
- {
- new item = GetPlayerWeaponSlot(i, 3);
- new defib;
- if (!IsValidEdict(item))
- {
- new rng = GetRandomInt(1, 2);
- switch (rng)
- {
- case 1:defib = CreateEntityByName("weapon_defibrillator");
- case 2:defib = CreateEntityByName("weapon_first_aid_kit");
- }
- DispatchSpawn(defib);
- EquipPlayerWeapon(i, defib);
- }
- item = GetPlayerWeaponSlot(i, 4);
- if (!IsValidEdict(item))
- {
- new rng = GetRandomInt(1, 2);
- switch (rng)
- {
- case 1:defib = CreateEntityByName("weapon_pain_pills");
- case 2:defib = CreateEntityByName("weapon_adrenaline");
- }
- DispatchSpawn(defib);
- EquipPlayerWeapon(i, defib);
- }
- }
- }
- }
- public Action:CheckMaxPlayers(Handle:Timer)
- {
- new Survivors = 0;
- new LastBot = 0;
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsSurvivor(i))
- {
- Survivors++;
- }
- if (IsSurvivor(i) && IsFakeClient(i))
- {
- LastBot = i;
- }
- }
- if (Survivors < 8)
- {
- CreateBot();
- }
- else if (Survivors > 8 && IsSurvivor(LastBot) && IsFakeClient(LastBot))
- {
- KickClient(LastBot);
- }
- }
- public Action:FixBots(Handle:Timer)
- {
- CoachExists = false;
- EllisExists = false;
- RochelleExists = false;
- NickExists = false;
- BillExists = false;
- FrancisExists = false;
- LouisExists = false;
- ZoeyExists = false;
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsSurvivor(i))
- {
- new String:model[128];
- GetClientModel(i, model, sizeof(model));
- if (StrEqual(model, MODEL_COACH))
- {
- CoachExists = true;
- }
- if (StrEqual(model, MODEL_ELLIS))
- {
- EllisExists = true;
- }
- if (StrEqual(model, MODEL_ROCHELLE))
- {
- RochelleExists = true;
- }
- if (StrEqual(model, MODEL_NICK))
- {
- NickExists = true;
- }
- if (StrEqual(model, MODEL_BILL))
- {
- BillExists = true;
- }
- if (StrEqual(model, MODEL_LOUIS))
- {
- LouisExists = true;
- }
- if (StrEqual(model, MODEL_FRANCIS))
- {
- FrancisExists = true;
- }
- if (StrEqual(model, MODEL_ZOEY))
- {
- ZoeyExists = true;
- }
- }
- }
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsSurvivor(i))
- {
- new String:model[128], String:model2[128];
- GetClientModel(i, model, 128);
- if (!CoachExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /c");
- CoachExists = true;
- }
- }
- }
- }
- if (!EllisExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /e");
- EllisExists = true;
- }
- }
- }
- }
- if (!RochelleExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /r");
- RochelleExists = true;
- }
- }
- }
- }
- if (!NickExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /n");
- NickExists = true;
- }
- }
- }
- }
- if (!BillExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /b");
- BillExists = true;
- }
- }
- }
- }
- if (!LouisExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /l");
- LouisExists = true;
- }
- }
- }
- }
- if (!FrancisExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /f");
- FrancisExists = true;
- }
- }
- }
- }
- if (!ZoeyExists)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsSurvivor(client) && client != i && IsFakeClient(client))
- {
- GetClientModel(client, model2, 128);
- if (StrEqual(model, model2))
- {
- FakeClientCommand(client, "say /z");
- ZoeyExists = true;
- }
- }
- }
- }
- }
- }
- }
- stock bool:IsSurvivor(client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2;
- }
- stock CreateBot()
- {
- // Spawn bot survivor.
- new Bot = CreateFakeClient("SurvivorBot");
- if (Bot == 0)
- return;
- ChangeClientTeam(Bot, 2);
- if (DispatchKeyValue(Bot, "classname", "SurvivorBot") == false)
- {
- return;
- }
- DispatchSpawn(Bot);
- if (DispatchSpawn(Bot) == false)
- {
- return;
- }
- if (!IsPlayerAlive(Bot))
- {
- Respawn(Bot);
- }
- if (IsSurvivor(Bot) && IsFakeClient(Bot))
- KickClient(Bot, "Kicking Fake Client.");
- }
- stock Respawn(client)
- {
- static Handle:hRoundRespawn = INVALID_HANDLE;
- if (hRoundRespawn == INVALID_HANDLE)
- {
- new Handle:hGameConf = LoadGameConfigFile("l4d_superversus");
- StartPrepSDKCall(SDKCall_Player);
- PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "RoundRespawn");
- hRoundRespawn = EndPrepSDKCall();
- if (hRoundRespawn == INVALID_HANDLE)
- {
- PrintToChatAll("L4D_SM_Respawn: RoundRespawn Signature broken");
- }
- }
- SDKCall(hRoundRespawn, client);
- }
Advertisement
Add Comment
Please, Sign In to add comment