Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- #define MAXLIST 12
- char Inflicted[MAXLIST][] =
- {
- "models/weapons/melee/v_fireaxe.mdl",
- "models/weapons/melee/v_frying_pan.mdl",
- "models/weapons/melee/v_machete.mdl",
- "models/weapons/melee/v_bat.mdl",
- "models/weapons/melee/v_crowbar.mdl",
- "models/weapons/melee/v_cricket_bat.mdl",
- "models/weapons/melee/v_tonfa.mdl",
- "models/weapons/melee/v_katana.mdl",
- "models/weapons/melee/v_electric_guitar.mdl",
- "models/weapons/melee/v_golfclub.mdl",
- "models/weapons/melee/v_riotshield.mdl",
- "models/v_models/v_knife_t.mdl"
- };
- int g_PlayerSecondaryWeapons[MAXPLAYERS + 1];
- public void OnPluginStart()
- {
- HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
- HookEvent("player_use", OnPlayerUse, EventHookMode_Post);
- HookEvent("player_bot_replace", player_bot_replace);
- HookEvent("bot_player_replace", bot_player_replace);
- HookEvent("player_death", OnPlayerDeath, EventHookMode_Pre);
- }
- public void OnMapStart()
- {
- for (int i = 0; i <= MAXLIST - 1; i++)
- {
- if(!IsModelPrecached(Inflicted[i])) PrecacheModel(Inflicted[i], true);
- }
- }
- public void OnRoundStart(Handle event, const char[] name, bool dontBroadcast)
- {
- for (int i = 0; i <= MAXPLAYERS; i++)
- {
- g_PlayerSecondaryWeapons[i] = -1;
- }
- }
- public Action OnPlayerUse(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(client == 0 || !IsClientInGame(client))
- {
- return;
- }
- int weapon = GetPlayerWeaponSlot(client, 1);
- g_PlayerSecondaryWeapons[client] = (weapon == -1 ? weapon : EntIndexToEntRef(weapon));
- }
- public Action bot_player_replace(Handle event, const char[] name, bool dontBroadcast)
- {
- int bot = GetClientOfUserId(GetEventInt(event, "bot"));
- int client = GetClientOfUserId(GetEventInt(event, "player"));
- g_PlayerSecondaryWeapons[client] = g_PlayerSecondaryWeapons[bot];
- g_PlayerSecondaryWeapons[bot] = -1;
- }
- public Action player_bot_replace(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "player"));
- int bot = GetClientOfUserId(GetEventInt(event, "bot"));
- g_PlayerSecondaryWeapons[bot] = g_PlayerSecondaryWeapons[client];
- g_PlayerSecondaryWeapons[client] = -1;
- }
- public Action OnPlayerDeath(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(client == 0 || !IsClientInGame(client)) return;
- int weapon = EntRefToEntIndex(g_PlayerSecondaryWeapons[client]);
- if (weapon > 0)
- {
- char sWeapon[32];
- int clip;
- GetEdictClassname(weapon, sWeapon, 32);
- int index = CreateEntityByName(sWeapon);
- float origin[3];
- float ang[3];
- if (strcmp(sWeapon, "weapon_melee") == 0)
- {
- char melee[156];
- GetEntPropString(weapon , Prop_Data, "m_ModelName", melee, sizeof(melee));
- for (int i = 0; i <= MAXLIST - 1; i++)
- {
- if(strcmp(melee, Inflicted[i]) == 0)
- {
- ReplaceString(sWeapon, sizeof(sWeapon), "weapon_", "", false);
- DispatchKeyValue(index, "melee_script_name", sWeapon);
- break;
- }
- }
- }
- else if (strcmp(sWeapon, "weapon_chainsaw") == 0)
- {
- clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
- }
- else if (strcmp(sWeapon, "weapon_pistol") == 0 && (GetEntProp(weapon, Prop_Send, "m_isDualWielding") > 0))
- {
- int indexC = CreateEntityByName(sWeapon);
- GetClientEyePosition(client,origin);
- GetClientEyeAngles(client, ang);
- GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
- NormalizeVector(ang,ang);
- ScaleVector(ang, 90.0);
- DispatchSpawn(indexC);
- TeleportEntity(indexC, origin, NULL_VECTOR, ang);
- ActivateEntity(indexC);
- }
- else if (strcmp(sWeapon, "weapon_pistol_magnum") == 0)
- {
- clip = GetEntProp(weapon, Prop_Send, "m_iClip1");
- }
- RemovePlayerItem(client, weapon);
- AcceptEntityInput(weapon, "kill");
- GetClientEyePosition(client,origin);
- GetClientEyeAngles(client, ang);
- GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
- NormalizeVector(ang,ang);
- ScaleVector(ang, 90.0);
- DispatchSpawn(index);
- TeleportEntity(index, origin, NULL_VECTOR, ang);
- ActivateEntity(index);
- if (strcmp(sWeapon, "weapon_chainsaw") == 0 || strcmp(sWeapon, "weapon_pistol") == 0 || strcmp(sWeapon, "weapon_pistol_magnum") == 0)
- {
- SetEntProp(index, Prop_Send, "m_iClip1", clip);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement