Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #define L4D2_WEPUPGFLAG_LASER (1 << 2)
- static int bHasLaser[MAXPLAYERS+1] = 0;
- public void OnMapStart()
- {
- decl String:map[128];
- GetCurrentMap(map, 128);
- if (StrContains(map, "m1", false) != -1)
- {
- for(int i = 1; i <= MaxClients; ++i)
- {
- bHasLaser[i] = 0;
- }
- }
- }
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_l", CmdLaserToggle);
- HookEvent("player_death", PlayerLoseLaser);
- }
- public Action PlayerLoseLaser(Event event, const char[] name, bool dontBroadcast)
- {
- int death = GetClientOfUserId(event.GetInt("userid"));
- bHasLaser[death] = 0;
- }
- public Action:CmdLaserToggle(client, args)
- {
- new priWeapon = GetPlayerWeaponSlot(client, 0);
- if (priWeapon <= 0 || !IsValidEntity(priWeapon))
- return;
- new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
- if (upgrades & L4D2_WEPUPGFLAG_LASER)
- {
- if (bHasLaser[client])
- {
- PrintHintText(client, "Зачем тебе ещё 1 лазер?");
- }
- CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
- bHasLaser[client]++;
- PrintHintText(client, "Лазер снят.");
- }
- if (upgrades != L4D2_WEPUPGFLAG_LASER)
- {
- if (bHasLaser[client] == 1)
- {
- CheatCommand(client, "upgrade_add", "LASER_SIGHT");
- bHasLaser[client] = 0;
- PrintHintText(client, "Лазер установлен.");
- }
- if(bHasLaser[client] == 1)
- {
- PrintHintText(client, "У тебя нету лазера.");
- }
- }
- }
- stock L4D2_GetWeaponUpgrades(weapon)
- {
- return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
- }
- stock CheatCommand(client, const String:command[], const String:arguments[])
- {
- if (!client) return;
- new admindata = GetUserFlagBits(client);
- SetUserFlagBits(client, ADMFLAG_ROOT);
- new flags = GetCommandFlags(command);
- SetCommandFlags(command, flags & ~FCVAR_CHEAT);
- FakeClientCommand(client, "%s %s", command, arguments);
- SetCommandFlags(command, flags);
- SetUserFlagBits(client, admindata);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement