Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- bool g_bHave[MAXPLAYERS + 1], g_bState[MAXPLAYERS + 1];
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_l", cLaser);
- HookEvent("player_death", eDeath);
- HookEvent("round_start", eStart, EventHookMode_PostNoCopy);
- }
- public void OnMapStart()
- {
- char szMap[56];
- GetCurrentMap(szMap, sizeof szMap);
- if (StrContains(szMap, "m1") != -1)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- g_bHave[i] = false;
- g_bState[i] = false;
- }
- }
- }
- public Action eStart(Event event, const char[] name, bool dontbroadcast)
- {
- for (int i = 1; i <= MaxClients; i++)
- if (g_bState[i])
- g_bHave[i] = true;
- }
- public Action eDeath(Event event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(g_bHave[client])
- g_bState[client] = true;
- g_bHave[client] = false;
- }
- public Action cLaser (int client, int args)
- {
- if (!client)
- return Plugin_Handled;
- int iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if (!IsValidEntity(iWeapon) || iWeapon != GetPlayerWeaponSlot(client, 0))
- return Plugin_Handled;
- char szBuffer[36];
- GetEntityNetClass(iWeapon, szBuffer, sizeof szBuffer);
- if (FindSendPropInfo(szBuffer, "m_upgradeBitVec") < 1)
- return Plugin_Handled;
- if (GetEntProp(iWeapon, Prop_Send, "m_upgradeBitVec") == (1 << 2))
- {
- if (!g_bHave[client])
- {
- UpgradeSwitchBits(client, false);
- g_bHave[client] = true;
- }
- }
- else
- {
- if (g_bHave[client])
- {
- UpgradeSwitchBits(client, true);
- g_bHave[client] = false;
- }
- }
- return Plugin_Handled;
- }
- stock void UpgradeSwitchBits (int client, bool switchl)
- {
- char szBuffer[36];
- Format(szBuffer, sizeof szBuffer, "%s", switchl ? "upgrade_add" : "upgrade_remove");
- int iFlags = GetCommandFlags(szBuffer);
- SetCommandFlags(szBuffer, iFlags & ~FCVAR_CHEAT);
- FakeClientCommand(client, "%s LASER_SIGHT", szBuffer);
- SetCommandFlags(szBuffer, iFlags);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement