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; int weaponPlayer[MAXPLAYERS+1];
- int laserrifle = 30665;
- bool LaserActivated = false;
- public OnPluginStart()
- {
- RegConsoleCmd("sm_test", CMD_Test);
- RegConsoleCmd("sm_testoff", CMD_TestOff);
- HookEvent("player_death", Ev_PlayerDeath);
- }
- public void OnClientPostAdminCheck(int client)
- {
- SDKHook(client, SDKHook_TraceAttack, TraceAttackHook);
- }
- public OnClientDisconnect(int client)
- {
- SDKUnhook(client, SDKHook_TraceAttack, TraceAttackHook);
- }
- public Action TF2_CalcIsAttackCritical(int client, int weapon, char[] weaponname, bool &result)
- {
- if (LaserActivated == true)
- {
- if (GetEntProp(weapon, Prop_Send, "m_iClip1") == 1)
- {
- TF2_RemoveAllWeapons(client);
- Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ATTRIBUTES|PRESERVE_ATTRIBUTES);
- 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, 2, 100.0);
- TF2Items_SetAttribute(sniperlaser, 0, 297, 0.0);
- weaponPlayer[client] = TF2Items_GiveNamedItem(client, sniperlaser);
- EquipPlayerWeapon(client, weaponPlayer[client]);
- SetEntProp(weaponPlayer[client], Prop_Data, "m_iClip1", 9);
- CloseHandle(sniperlaser);
- SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
- }
- }
- }
- public Action TraceAttackHook(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
- {
- if (LaserActivated == true)
- {
- int Replacement = PlayerHit[victim]+1;
- PlayerHit[victim] = Replacement;
- if (PlayerHit[victim] >= 3)
- {
- return Plugin_Continue;
- }
- else
- {
- damage = 0.0;
- }
- return Plugin_Changed;
- }
- else
- {
- return Plugin_Continue;
- }
- }
- public Action Ev_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- int victim = GetClientOfUserId(GetEventInt(event, "userid", 0));
- PlayerHit[victim] = 0;
- return Plugin_Handled;
- }
- public Action CMD_Test(int client, int args)
- {
- LaserActivated = true;
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i))
- {
- TF2_SetPlayerClass(i, TFClass_Sniper);
- TF2_RespawnPlayer(i);
- if (IsPlayerAlive(i))
- {
- TF2_RemoveAllWeapons(i);
- Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ATTRIBUTES|PRESERVE_ATTRIBUTES);
- 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, 2, 100.0);
- TF2Items_SetAttribute(sniperlaser, 0, 297, 0.0);
- weaponPlayer[i] = TF2Items_GiveNamedItem(i, sniperlaser);
- EquipPlayerWeapon(i, weaponPlayer[i]);
- SetEntProp(weaponPlayer[i], Prop_Data, "m_iClip1", 3);
- CloseHandle(sniperlaser);
- SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
- }
- }
- }
- SetConVarInt(FindConVar("sv_gravity"), 600);
- PrintToChatAll("Laser Activated");
- return Plugin_Handled;
- }
- public Action CMD_TestOff(int client, int args)
- {
- LaserActivated = false;
- SetConVarInt(FindConVar("sv_gravity"), 800);
- return Plugin_Handled;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement