Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #pragma semicolon 1
- #define MAX_CLIENTS 52
- #define TEAM_PRISONERS 2
- new Handle:hRadius = INVALID_HANDLE;
- new Handle:hMagnitude = INVALID_HANDLE;
- new iExplosion = -1;
- new bool:bHasBomb[MAX_CLIENTS + 1];
- public OnPluginStart()
- {
- hRadius = CreateConVar("jjk_bomb_radius",
- "250", "Radius of bomb explosion");
- hMagnitude = CreateConVar("jjk_bomb_magnitude", "200",
- "Magnitude of the bomb explosion");
- HookEvent("round_start", round_start);
- HookEvent("player_death", player_death);
- HookEvent("item_pickup", item_pickup);
- AddFileToDownloadsTable("sound/crosshair/rebelyell.wav");
- PrecacheSound("crosshair/rebelyell.wav");
- AutoExecConfig(true, "bomb");
- }
- public OnMapStart()
- {
- PrecacheSound("crosshair/rebelyell.wav");
- }
- public Action:OnClientCommand(client, args)
- {
- decl String:command[8];
- decl String:weapon[10];
- GetClientWeapon(client, weapon, sizeof(weapon));
- GetCmdArg(0, command, sizeof(command));
- if (StrEqual("drop", command, false) && StrEqual("weapon_c4", weapon)) {
- explodePlayer(client);
- }
- }
- public round_start(Handle:event, const String:name[], bool:dontBroadcast)
- {
- CreateTimer(0.1, giveBomb);
- }
- public Action:giveBomb(Handle:timer)
- {
- new iClientCount;
- decl iClients[MAX_CLIENTS];
- for (new i = 1; i <= MAX_CLIENTS; i++) {
- bHasBomb[i] = false;
- if (IsClientInGame(i) && GetClientTeam(i) == TEAM_PRISONERS)
- iClients[iClientCount++] = i;
- }
- new client = iClients[GetRandomInt(0, iClientCount - 1)];
- GivePlayerItem(client, "weapon_c4");
- }
- public item_pickup(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:sWeapon[32];
- GetEventString(event, "item", sWeapon, sizeof(sWeapon));
- if (StrEqual(sWeapon, "c4"))
- bHasBomb[GetClientOfUserId(GetEventInt(event, "userid"))] = true;
- }
- public player_death(Handle:event, const String:name[], bool:dontBroascast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if (bHasBomb[client])
- explodePlayer(client);
- }
- stock explodePlayer(client)
- {
- new iMagnitude = GetConVarInt(hMagnitude);
- new iRadius = GetConVarInt(hRadius);
- new index = GetPlayerWeaponSlot(client, 4);
- if (index == -1) {
- while ((index = FindEntityByClassname(index, "weapon_c4")) != -1)
- if (GetEntProp(index, Prop_Send, "m_hOwnerEntity") == -1)
- break;
- }
- AcceptEntityInput(index, "kill");
- EmitSoundToAll("crosshair/rebelyell.wav");
- decl Float:loc[3];
- GetClientEyePosition(client, loc);
- for (new i = 1; i < MaxClients; i++) {
- if (!IsClientInGame(i))
- continue;
- //FakeClientCommandEx(i, "play crosshair/rebelyell.wav");
- FakeClientCommand(i, "play crosshair/rebelyell.wav");
- decl Float:tempLoc[3];
- GetClientAbsOrigin(i, tempLoc);
- /* The player is within the range of the bomb, slap them */
- if (Pow(Pow(loc[0] - tempLoc[0], 2.0) +
- Pow(loc[1] - tempLoc[1], 2.0) +
- Pow(loc[2] - tempLoc[2], 2.0), 0.5) < iRadius)
- SlapPlayer(i, 0, false);
- }
- decl String:magnitude[8];
- decl String:radius[8];
- IntToString(iMagnitude, magnitude, sizeof(magnitude));
- IntToString(iRadius, radius, sizeof(radius));
- iExplosion = CreateEntityByName("env_explosion");
- bHasBomb[client] = false;
- if (iExplosion > 0) {
- DispatchKeyValueVector(iExplosion, "Origin", loc);
- SetEntPropEnt(iExplosion, Prop_Send, "m_hOwnerEntity", client);
- DispatchKeyValue(iExplosion, "iMagnitude", magnitude);
- DispatchKeyValue(iExplosion, "iRadiusOverride", radius);
- AcceptEntityInput(iExplosion, "Explode");
- AcceptEntityInput(iExplosion, "Kill");
- }
- }
Add Comment
Please, Sign In to add comment