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 OnMapStart()
- {
- decl String:map[128];
- GetCurrentMap(map, 128);
- if (StrContains(map, "m1", false))
- {
- for(int i = 1; i <= MaxClients; ++i)
- {
- bHasLaser[i] = 0;
- }
- }
- }
- public OnPluginStart()
- {
- RegConsoleCmd("sm_l", CmdLaserToggle);
- HookEvent("player_death", playerdeath);
- }
- public Action:playerdeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new userid = GetClientOfUserId(GetEventInt(event, "userid"));
- bHasLaser[userid] = 0;
- PrintHintText(userid, "Ты потерял лазер.");
- }
- 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] == 0)
- {
- CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
- bHasLaser[client]++;
- PrintHintText(client,"Лазер снят");
- }
- else
- {
- PrintHintText(client,"Зачем тебе ещё 1 лазер?");
- }
- }
- if (upgrades != L4D2_WEPUPGFLAG_LASER)
- {
- if (bHasLaser[client] == 1)
- {
- CheatCommand(client, "upgrade_add", "LASER_SIGHT");
- bHasLaser[client] = false;
- PrintHintText(client,"Лазер установлен");
- }
- if (bHasLaser[client] == 0)
- {
- 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