Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- #include <tf2_stocks>
- #include <tf2items>
- #pragma semicolon 1
- int PlayerHit[MAXPLAYERS+1] = 0;
- const int laserrifle = 30665;
- bool LaserActivated;
- public OnPluginStart()
- {
- RegConsoleCmd("sm_test", CMD_Test);
- RegConsoleCmd("sm_testoff", CMD_TestOff);
- HookEvent("player_death", Ev_PlayerDeath);
- HookEvent("teamplay_win_panel", Ev_TeamplayWinPanel);
- }
- public void OnPlayerConnected(int client)
- {
- SDKHook(client, SDKHook_TraceAttack, TraceAttackHook);
- }
- public Action TraceAttackHook(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
- {
- damage = 0.0;
- int Replacement = PlayerHit[victim]+1;
- PlayerHit[victim] = Replacement;
- if (PlayerHit[victim] >= 3)
- {
- TF2_RemoveCondition(victim, TFCond_PreventDeath);
- SDKHooks_TakeDamage(victim, laserrifle, attacker, float(GetClientHealth(victim)), DMG_ENERGYBEAM, laserrifle, _, _);
- }
- }
- public void OnGameFrame()
- {
- if (LaserActivated == true)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i))
- {
- if (IsPlayerAlive(i))
- {
- if (TF2_GetPlayerClass(i) == TFClass_Sniper)
- {
- SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
- SetEntProp(i, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
- TF2_AddCondition(i, TFCond_PreventDeath);
- }
- else
- {
- ForcePlayerSuicide(i);
- TF2_SetPlayerClass(i, TFClass_Sniper);
- TF2_RespawnPlayer(i);
- if (TF2_GetPlayerClass(i) == TFClass_Sniper)
- {
- SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
- SetEntProp(i, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
- TF2_AddCondition(i, TFCond_PreventDeath);
- }
- }
- }
- }
- }
- }
- }
- public Action TF2Items_OnGiveNamedItem(int client, char[] classname, int iItemDefinitionIndex, Handle& hItem)
- {
- SetEntProp(client, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
- TF2_RemoveWeaponSlot(client, 1);
- TF2_RemoveWeaponSlot(client, 2);
- return Plugin_Handled;
- }
- public Action Ev_TeamplayWinPanel(Event event, const char[] name, bool dontBroadcast)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i))
- {
- if (IsPlayerAlive(i))
- {
- PlayerHit[i] = 0;
- LaserActivated = false;
- if (TF2_IsPlayerInCondition(i, TFCond_PreventDeath) == true)
- {
- TF2_RemoveCondition(i, TFCond_PreventDeath);
- }
- }
- }
- }
- }
- public Action Ev_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- int victim = GetClientOfUserId(GetEventInt(event, "victim", 0));
- PlayerHit[victim] = 0;
- if (TF2_IsPlayerInCondition(victim, TFCond_PreventDeath) == true)
- {
- TF2_RemoveCondition(victim, TFCond_PreventDeath);
- }
- }
- public Action CMD_Test(int client, int args)
- {
- LaserActivated = true;
- SetConVarInt(FindConVar("sv_gravity"), 600);
- Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ALL);
- TF2Items_SetClassname(sniperlaser, "tf_weapon_sniperrifle");
- TF2Items_SetItemIndex(sniperlaser, laserrifle);
- TF2Items_SetLevel(sniperlaser, 1);
- TF2Items_SetQuality(sniperlaser, 1);
- TF2Items_SetNumAttributes(sniperlaser, 2);
- TF2Items_SetAttribute(sniperlaser, 0, 47, 1.0);
- TF2Items_SetAttribute(sniperlaser, 0, 315, 1.0);
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i))
- {
- if (IsPlayerAlive(i))
- {
- TF2_AddCondition(i, TFCond_PreventDeath, TFCondDuration_Infinite, 0);
- SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
- int weapon = TF2Items_GiveNamedItem(i, sniperlaser);
- EquipPlayerWeapon(i, weapon);
- SetEntProp(weapon, Prop_Data, "m_iClip1", 1);
- }
- }
- }
- PrintToChatAll("Laser Activated");
- CloseHandle(sniperlaser);
- return Plugin_Handled;
- }
- public Action CMD_TestOff(int client, int args)
- {
- LaserActivated = false;
- return Plugin_Handled;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement