Who's the bomber?

SNC

Recognized Member
I'm the bomber.
Ok, so I'm preparing a code that does some special stuff, and unlike my previous code I really think this will work since I'm putting a lot of time into actually thinking about thevery logistics of it.
What will happen, though, is that when enough people type sm_wtb or !wtb or /wtb, similarly to the vote system with fire warden but does nothing similar to it. It gives a random red access to the itb (I'm the bomber) command, which allows a red to be put on a timebomb, run up to the reds, and explode. If the Red is killed before that, you will have "caught the bomber".
Just a little fun idea I had, I'm still working on the code but at this point I'm pretty far into the code and as far as I know, it works.
 

One Up

Recognized Member
Sounds like a good idea. It's good to see that you're learning how to code. Is it sourcepawn that you are using?
 

SNC

Recognized Member
Sounds like a good idea. It's good to see that you're learning how to code. Is it sourcepawn that you are using?
Yes.
 

Buns

Recognized Member
Do you need a place to test the code? I have an old SM server that I can make private and host your codes before you submit them.

EDIT: I think you mean "run up to the blues," it sounds like reds are killing reds in your post
 

SNC

Recognized Member
Do you need a place to test the code? I have an old SM server that I can make private and host your codes before you submit them.

EDIT: I think you mean "run up to the blues," it sounds like reds are killing reds in your post
That's what I meant, and yes that would be awesome. Also, the code is not done.
 

SNC

Recognized Member
Coming up really close on finishing, lots of shit I had to do and I still need to test the main ability it has. @Buns I'd love to take you up on that offer.
 

Buns

Recognized Member
Coming up really close on finishing, lots of shit I had to do and I still need to test the main ability it has. @Buns I'd love to take you up on that offer.
Your friends list is full but thats fine. I have the server hosted right now, PM me the code and I'll give you the IP
 

SNC

Recognized Member
Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_gamerules>
#include <sdkhooks>
#pragma semicolon 1

float pos1[3];
float pos2[3];
int currentplayercount = 0;
int bomber = 0;
int votes = 0;
int voters = 0;
int votesneeded = 0;
bool bomberdead = false;
bool bomberexists = false;
bool voted[MAXPLAYERS + 1] = {false, ...};
public OnPluginStart()
{
    CreateConVar("bomberratio", "0.6", "voteratio for bomber", 0, true, 0.1, true, 1.0);
    RegAdminCmd("sm_wtb", whosthebomber, 0);
    RegAdminCmd("sm_iamtb", iamthebomber, 0);
    CreateConVar("bombradius", "600", "Explosion radius.", 0, true, 50.0, true, 3000.0);
    CreateConVar("damagebomb", "220", "Damage when bomb explodes.");
    HookEvent("arena_round_start", roundstart);
    HookEvent("arena_win_panel", arenawin);
}
public Action whosthebomber(int client, int args)
{
    if (GameRules_GetRoundState() == RoundState_Preround || GameRules_GetRoundState() == RoundState_Stalemate || GameRules_GetRoundState() == RoundState_BetweenRounds || GameRules_GetRoundState() == RoundState_Bonus || GameRules_GetRoundState() == RoundState_TeamWin || GameRules_GetRoundState() == RoundState_StartGame || GameRules_GetRoundState() == RoundState_Init || GameRules_GetRoundState() == RoundState_Pregame || GameRules_GetRoundState() == RoundState_GameOver || GameRules_GetRoundState() == RoundState_Restart)
    {
        PrintToChat(client, "You cannot vote at this time.");
        return Plugin_Handled;
    }
   
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    votesneeded = RoundToFloor(float(votes) * cv_votesneeded);
    if (voted[client] == true)
    {
        PrintToChat(client, "[SM] You have already voted!");
    }
    if (voted[client] == false)
    {
        if (votes == 0)
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
        else
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
    }
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public void OnClientDisconnect(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    if (voted[client] == true)
    {
        votes--;
    }
    voters--;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    voted[client] = false;
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public void OnClientConnected(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    voted[client] = false;
    voters = 0;
    votesneeded = 0;
    voters++;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public Action iamthebomber(int client, int args)
{
    if (bomberexists == false)
    {
        PrintToChat(client, "Bomber does not exist yet!");
        return Plugin_Handled;
    }
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    if (bomberexists == true && bomber != client)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    else
    {
        ServerCommand("sm_beacon %N", client);
        GetClientAbsOrigin(client, pos1);
        CreateTimer(5.0, bombexplode, _);
        return Plugin_Handled;
    }
}
public Action bombexplode(Handle timer)
{
    if (bomberdead == true)
    {
        return Plugin_Handled;
    }
    else
    {
        if (IsPlayerAlive(bomber) == false)
        {
            PrintToChatAll("The bomber, %N, is dead!", bomber);
            bomberdead = true;
        }
        ConVar bombrad = FindConVar("bombradius");
        ConVar dbomb = FindConVar("damagebomb");
        int cteam = GetClientTeam(bomber);
        for (int i = 1; i <= MaxClients; i++)
        {
            if (i != bomber && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) != cteam)
            {
                if(!TF2_IsPlayerInCondition(i, TFCond_Ubercharged))
                {   
                    GetClientAbsOrigin(i, pos2);
                    if(GetVectorDistance(pos1, pos2) <= GetConVarFloat(bombrad))
                    {
                        int damage = GetConVarInt(dbomb);
                        if(GetClientHealth(i) - damage <= 0)
                        {
                            PrintToChatAll("%N has died from the explosion!", i);
                        }
                        SDKHooks_TakeDamage(i, 0, bomber, GetConVarFloat(dbomb), DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB);
                    }
                }
                ForcePlayerSuicide(bomber);
            }
        }
    }
    return Plugin_Handled;
}
public Action roundstart(Event event, const char[] name, bool dontBroadcast)
{
    bomber = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
public Action arenawin(Event event, const char[] name, bool dontBroadcast)
{
    bomber = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
Long code intensifies, this is the prototype which I am currently ironing out and testing on Buns's server (TY so much Buns btw).
Very happy with what it does so far.
 

Deathstroke2312

Recognized Member
DAMNIY SNC, HUNTER X HUNTER IS GETYING TO YOUR HEAD. I ONLY WATCHED IT 3 times. You are obsessed now
 
  • Like
Reactions: SNC

SNC

Recognized Member
DAMNIY SNC, HUNTER X HUNTER IS GETYING TO YOUR HEAD. I ONLY WATCHED IT 3 times. You are obsessed now
DUDE YOU REALIZED WHAT THIS WAS FROM? I love that song so much!
Genthru :D
But the plugin is real, and has a purpose but it was inspired by Hunter x Hunter.
 

dontbanmepls

Well-Known Member
which allows a red to be put on a timebomb, run up to the reds, and explode. If the Red is killed before that, you will have "caught the bomber".
Just a little fun idea I had, I'm still working on the code but at this point I'm pretty far into the code and as far as I know, it works.
Allows a red to run up to other reds? Did you mean to blues? :)
 

Deathstroke2312

Recognized Member
I'm the bomber.
Ok, so I'm preparing a code that does some special stuff, and unlike my previous code I really think this will work since I'm putting a lot of time into actually thinking about thevery logistics of it.
What will happen, though, is that when enough people type sm_wtb or !wtb or /wtb, similarly to the vote system with fire warden but does nothing similar to it. It gives a random red access to the itb (I'm the bomber) command, which allows a red to be put on a timebomb, run up to the reds, and explode. If the Red is killed before that, you will have "caught the bomber".
Just a little fun idea I had, I'm still working on the code but at this point I'm pretty far into the code and as far as I know, it works.
This could actually be a game mode of itself SNC. Kinda like a game of psychotic tag. Just like in Hunter X Hunter, although I don't think they could red pawn after having their stomachs explode
 

Shrooms

Recognized Member
I'm the bomber.
Ok, so I'm preparing a code that does some special stuff, and unlike my previous code I really think this will work since I'm putting a lot of time into actually thinking about thevery logistics of it.
What will happen, though, is that when enough people type sm_wtb or !wtb or /wtb, similarly to the vote system with fire warden but does nothing similar to it. It gives a random red access to the itb (I'm the bomber) command, which allows a red to be put on a timebomb, run up to the reds, and explode. If the Red is killed before that, you will have "caught the bomber".
Just a little fun idea I had, I'm still working on the code but at this point I'm pretty far into the code and as far as I know, it works.
So someone is the suicide bomber and blues have to kill him before he gets to them or nearby blues explode or nothing really happens? What happens if the bomber gets there? Someone else is the bomber? And does it keep going on till the red or blue team is dead?
Edit: I told my friend about this and he said:
"Sounds Muslim"<----Wtf is wrong with him?
 

Deathstroke2312

Recognized Member
So someone is the suicide bomber and blues have to kill him before he gets to them or nearby blues explode or nothing really happens? What happens if the bomber gets there? Someone else is the bomber? And does it keep going on till the red or blue team is dead?
Edit: I told my friend about this and he said:
"Sounds Muslim"<----Wtf is wrong with him?
*siiiiiiiiiigh
 

Shrooms

Recognized Member
*siiiiiiiiiigh
just explain it to me. Please Do blues die if the Red Aka bomber explodes near them? Plz im confused.
Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_gamerules>
#include <sdkhooks>
#pragma semicolon 1

float pos1[3];
float pos2[3];
int currentplayercount = 0;
int bomber = 0;
int votes = 0;
int voters = 0;
int votesneeded = 0;
bool bomberdead = false;
bool bomberexists = false;
bool voted[MAXPLAYERS + 1] = {false, ...};
public OnPluginStart()
{
    CreateConVar("bomberratio", "0.6", "voteratio for bomber", 0, true, 0.1, true, 1.0);
    RegAdminCmd("sm_wtb", whosthebomber, 0);
    RegAdminCmd("sm_iamtb", iamthebomber, 0);
    CreateConVar("bombradius", "600", "Explosion radius.", 0, true, 50.0, true, 3000.0);
    CreateConVar("damagebomb", "220", "Damage when bomb explodes.");
    HookEvent("arena_round_start", roundstart);
    HookEvent("arena_win_panel", arenawin);
}
public Action whosthebomber(int client, int args)
{
    if (GameRules_GetRoundState() == RoundState_Preround || GameRules_GetRoundState() == RoundState_Stalemate || GameRules_GetRoundState() == RoundState_BetweenRounds || GameRules_GetRoundState() == RoundState_Bonus || GameRules_GetRoundState() == RoundState_TeamWin || GameRules_GetRoundState() == RoundState_StartGame || GameRules_GetRoundState() == RoundState_Init || GameRules_GetRoundState() == RoundState_Pregame || GameRules_GetRoundState() == RoundState_GameOver || GameRules_GetRoundState() == RoundState_Restart)
    {
        PrintToChat(client, "You cannot vote at this time.");
        return Plugin_Handled;
    }
  
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    votesneeded = RoundToFloor(float(votes) * cv_votesneeded);
    if (voted[client] == true)
    {
        PrintToChat(client, "[SM] You have already voted!");
    }
    if (voted[client] == false)
    {
        if (votes == 0)
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
        else
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
    }
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public void OnClientDisconnect(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    if (voted[client] == true)
    {
        votes--;
    }
    voters--;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    voted[client] = false;
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public void OnClientConnected(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    voted[client] = false;
    voters = 0;
    votesneeded = 0;
    voters++;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    if (votes >= votesneeded && bomber == 0 && bomber == false)
    {
        currentplayercount = GetClientCount(true);
        bomber = GetRandomInt(1, currentplayercount);
        for (bomber = GetRandomInt(1, currentplayercount); GetClientTeam(bomber) != TFTeam_Red || bomber <= MaxClients; bomber++)
        {
            bomber = GetRandomInt(1, currentplayercount);
            return Plugin_Continue;
        }
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
    }
    return Plugin_Handled;
}
public Action iamthebomber(int client, int args)
{
    if (bomberexists == false)
    {
        PrintToChat(client, "Bomber does not exist yet!");
        return Plugin_Handled;
    }
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    if (bomberexists == true && bomber != client)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    else
    {
        ServerCommand("sm_beacon %N", client);
        GetClientAbsOrigin(client, pos1);
        CreateTimer(5.0, bombexplode, _);
        return Plugin_Handled;
    }
}
public Action bombexplode(Handle timer)
{
    if (bomberdead == true)
    {
        return Plugin_Handled;
    }
    else
    {
        if (IsPlayerAlive(bomber) == false)
        {
            PrintToChatAll("The bomber, %N, is dead!", bomber);
            bomberdead = true;
        }
        ConVar bombrad = FindConVar("bombradius");
        ConVar dbomb = FindConVar("damagebomb");
        int cteam = GetClientTeam(bomber);
        for (int i = 1; i <= MaxClients; i++)
        {
            if (i != bomber && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) != cteam)
            {
                if(!TF2_IsPlayerInCondition(i, TFCond_Ubercharged))
                {  
                    GetClientAbsOrigin(i, pos2);
                    if(GetVectorDistance(pos1, pos2) <= GetConVarFloat(bombrad))
                    {
                        int damage = GetConVarInt(dbomb);
                        if(GetClientHealth(i) - damage <= 0)
                        {
                            PrintToChatAll("%N has died from the explosion!", i);
                        }
                        SDKHooks_TakeDamage(i, 0, bomber, GetConVarFloat(dbomb), DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB);
                    }
                }
                ForcePlayerSuicide(bomber);
            }
        }
    }
    return Plugin_Handled;
}
public Action roundstart(Event event, const char[] name, bool dontBroadcast)
{
    bomber = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
public Action arenawin(Event event, const char[] name, bool dontBroadcast)
{
    bomber = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
Long code intensifies, this is the prototype which I am currently ironing out and testing on Buns's server (TY so much Buns btw).
Very happy with what it does so far.
Ahh this is why i love code:
bool bomberexists = false; yeah i know the joke barely exists.
 

SNC

Recognized Member
Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_gamerules>
#include <sdkhooks>
#pragma semicolon 1

float pos1[3];
float pos2[3];
int finalbomber = 0;
int rv = 0;
int pbomber = 0;
int bomber = 0;
int votes = 0;
int voters = 0;
int votesneeded = 0;
int sizeofteam = 0;
int reds[32];
bool bomberused = false;
bool bomblock = true;
bool bomberdead = false;
bool bomberexists = false;
bool voted[MAXPLAYERS + 1] = {false, ...};
public OnPluginStart()
{
    CreateConVar("bomberratio", "0.6", "voteratio for bomber", 0, true, 0.1, true, 1.0);
    RegAdminCmd("sm_wtb", whosthebomber, 0);
    RegAdminCmd("sm_iamtb", iamthebomber, 0);
    CreateConVar("bombradius", "600", "Explosion radius.", 0, true, 50.0, true, 3000.0);
    CreateConVar("damagebomb", "220", "Damage when bomb explodes.");
    HookEvent("arena_round_start", roundstart);
    HookEvent("arena_win_panel", arenawin);
}
public Action whosthebomber(int client, int args)
{
    if (bomblock == true)
    {
        PrintToChat(client, "You cannot vote at this time.");
        voted[client] = false;
        return Plugin_Handled;
    }
   
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    votesneeded = RoundToFloor(float(votes) * cv_votesneeded);
    if (voted[client] == true)
    {
        PrintToChat(client, "[SM] You have already voted!");
    }
    if (voted[client] == false)
    {
        if (votes == 0)
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
        else
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
    }
    if (votes >= votesneeded && finalbomber == 0 && bomberexists == false)
    {
        for (bomber = 1; bomber <= MaxClients; bomber++)
        {
            if (IsClientInGame(bomber) == true && IsPlayerAlive(bomber) == true)
            {
                if (TF2_GetClientTeam(bomber) == TFTeam_Red)
                {
                    reds[rv++] = bomber;
                }
            }
        }
        sizeofteam = GetTeamClientCount(2);
        pbomber = GetRandomInt(0, sizeofteam);
        finalbomber = reds[pbomber];
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
        bomberused = false;
    }
    return Plugin_Handled;
}
public void OnClientDisconnect(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    if (voted[client] == true)
    {
        votes--;
    }
    voters--;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    voted[client] = false;
    return Plugin_Handled;
}
public void OnClientConnected(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    voted[client] = false;
    voters++;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    return Plugin_Handled;
}
public Action iamthebomber(int client, int args)
{
    if (bomberexists == false)
    {
        PrintToChat(client, "Bomber does not exist yet!");
        return Plugin_Handled;
    }
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    if (bomberexists == true && finalbomber != client)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    else
    {
        if (bomberused == true && finalbomber == client)
        {
            PrintToChat(client, "Your bomb has been used!");
        }
        if (bomberused == false && finalbomber == client)
        {
            ServerCommand("sm_beacon %N", client);
            GetClientAbsOrigin(client, pos1);
            CreateTimer(5.0, bombexplode, _);
            return Plugin_Handled;
        }
        return Plugin_Handled;
    }
}
public Action bombexplode(Handle timer)
{
    if (bomberdead == true)
    {
        return Plugin_Handled;
    }
    else
    {
        ConVar bombrad = FindConVar("bombradius");
        ConVar dbomb = FindConVar("damagebomb");
        for (int i = 1; i <= MaxClients; i++)
        {
            if (i != finalbomber && IsClientInGame(i) && IsPlayerAlive(i) && TF2_GetClientTeam(i) != TFTeam_Red)
            {
                if(!TF2_IsPlayerInCondition(i, TFCond_Ubercharged))
                {   
                    GetClientAbsOrigin(i, pos2);
                    if(GetVectorDistance(pos1, pos2) <= GetConVarFloat(bombrad))
                    {
                        int damage = GetConVarInt(dbomb);
                        if(GetClientHealth(i) - damage <= 0)
                        {
                            PrintToChatAll("%N has died from the explosion!", i);
                        }
                        SDKHooks_TakeDamage(i, 0, finalbomber, GetConVarFloat(dbomb), DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB);
                    }
                }
                ForcePlayerSuicide(finalbomber);
                if (IsPlayerAlive(finalbomber) == false)
                {
                    PrintToChatAll("The bomber, %N, is dead!", finalbomber);
                    bomberdead = true;
                }
            }
        }
    }
    return Plugin_Handled;
}
public Action roundstart(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = false;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
public Action arenawin(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = true;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
Getting to be the final code.
 

Tricky

•~•
So basically firethewarden on random REDs?
 

Shrooms

Recognized Member
Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_gamerules>
#include <sdkhooks>
#pragma semicolon 1

float pos1[3];
float pos2[3];
int finalbomber = 0;
int rv = 0;
int pbomber = 0;
int bomber = 0;
int votes = 0;
int voters = 0;
int votesneeded = 0;
int sizeofteam = 0;
int reds[32];
bool bomberused = false;
bool bomblock = true;
bool bomberdead = false;
bool bomberexists = false;
bool voted[MAXPLAYERS + 1] = {false, ...};
public OnPluginStart()
{
    CreateConVar("bomberratio", "0.6", "voteratio for bomber", 0, true, 0.1, true, 1.0);
    RegAdminCmd("sm_wtb", whosthebomber, 0);
    RegAdminCmd("sm_iamtb", iamthebomber, 0);
    CreateConVar("bombradius", "600", "Explosion radius.", 0, true, 50.0, true, 3000.0);
    CreateConVar("damagebomb", "220", "Damage when bomb explodes.");
    HookEvent("arena_round_start", roundstart);
    HookEvent("arena_win_panel", arenawin);
}
public Action whosthebomber(int client, int args)
{
    if (bomblock == true)
    {
        PrintToChat(client, "You cannot vote at this time.");
        voted[client] = false;
        return Plugin_Handled;
    }
  
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    votesneeded = RoundToFloor(float(votes) * cv_votesneeded);
    if (voted[client] == true)
    {
        PrintToChat(client, "[SM] You have already voted!");
    }
    if (voted[client] == false)
    {
        if (votes == 0)
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
        else
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
    }
    if (votes >= votesneeded && finalbomber == 0 && bomberexists == false)
    {
        for (bomber = 1; bomber <= MaxClients; bomber++)
        {
            if (IsClientInGame(bomber) == true && IsPlayerAlive(bomber) == true)
            {
                if (TF2_GetClientTeam(bomber) == TFTeam_Red)
                {
                    reds[rv++] = bomber;
                }
            }
        }
        sizeofteam = GetTeamClientCount(2);
        pbomber = GetRandomInt(0, sizeofteam);
        finalbomber = reds[pbomber];
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
        bomberused = false;
    }
    return Plugin_Handled;
}
public void OnClientDisconnect(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    if (voted[client] == true)
    {
        votes--;
    }
    voters--;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    voted[client] = false;
    return Plugin_Handled;
}
public void OnClientConnected(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    voted[client] = false;
    voters++;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    return Plugin_Handled;
}
public Action iamthebomber(int client, int args)
{
    if (bomberexists == false)
    {
        PrintToChat(client, "Bomber does not exist yet!");
        return Plugin_Handled;
    }
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    if (bomberexists == true && finalbomber != client)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    else
    {
        if (bomberused == true && finalbomber == client)
        {
            PrintToChat(client, "Your bomb has been used!");
        }
        if (bomberused == false && finalbomber == client)
        {
            ServerCommand("sm_beacon %N", client);
            GetClientAbsOrigin(client, pos1);
            CreateTimer(5.0, bombexplode, _);
            return Plugin_Handled;
        }
        return Plugin_Handled;
    }
}
public Action bombexplode(Handle timer)
{
    if (bomberdead == true)
    {
        return Plugin_Handled;
    }
    else
    {
        ConVar bombrad = FindConVar("bombradius");
        ConVar dbomb = FindConVar("damagebomb");
        for (int i = 1; i <= MaxClients; i++)
        {
            if (i != finalbomber && IsClientInGame(i) && IsPlayerAlive(i) && TF2_GetClientTeam(i) != TFTeam_Red)
            {
                if(!TF2_IsPlayerInCondition(i, TFCond_Ubercharged))
                {  
                    GetClientAbsOrigin(i, pos2);
                    if(GetVectorDistance(pos1, pos2) <= GetConVarFloat(bombrad))
                    {
                        int damage = GetConVarInt(dbomb);
                        if(GetClientHealth(i) - damage <= 0)
                        {
                            PrintToChatAll("%N has died from the explosion!", i);
                        }
                        SDKHooks_TakeDamage(i, 0, finalbomber, GetConVarFloat(dbomb), DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB);
                    }
                }
                ForcePlayerSuicide(finalbomber);
                if (IsPlayerAlive(finalbomber) == false)
                {
                    PrintToChatAll("The bomber, %N, is dead!", finalbomber);
                    bomberdead = true;
                }
            }
        }
    }
    return Plugin_Handled;
}
public Action roundstart(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = false;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
public Action arenawin(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = true;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
Getting to be the final code.
Snc one question, can't we just evolve the toggle time bomb on self-command to a time bomb but that instantly kills all players of oppisate teams along with self?!? A.k.a. Toggle Japanese sucide bomber(not a Muslim racist joke; This one is about the holla cost)
 

SNC

Recognized Member
Snc one question, can't we just evolve the toggle time bomb on self-command to a time bomb but that instantly kills all players of oppisate teams along with self?!? A.k.a. Toggle Japanese sucide bomber(not a Muslim racist joke; This one is about the holla cost)
No cause that ruins the point of it?
So basically firethewarden on random REDs?
More like make a red a suicidebomber.
Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools_engine>
#include <sdktools_functions>
#include <sdktools_gamerules>
#include <sdkhooks>
#include <sdktools>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#pragma semicolon 1

float pos1[3];
float pos2[3];
int finalbomber = 0;
int rv = 0;
int pbomber = 0;
int bomber = 0;
int votes = 0;
int voters = 0;
int votesneeded = 0;
int sizeofteam = 0;
int reds[32];
int g_ExplosionSprite   = -1;
char g_BoomSound[PLATFORM_MAX_PATH];
bool bomberused = false;
bool bomblock = true;
bool bomberdead = false;
bool bomberexists = false;
bool voted[MAXPLAYERS + 1] = {false, ...};
public OnPluginStart()
{
    g_ExplosionSprite = PrecacheModel("materials/sprites/sprite_fire01.vmt");
    PrecacheSound("ambient/explosions/explode_8.wav", true);
    CreateConVar("bomberratio", "0.6", "voteratio for bomber", 0, true, 0.1, true, 1.0);
    RegAdminCmd("sm_wtb", whosthebomber, 0);
    RegAdminCmd("sm_iamtb", iamthebomber, 0);
    CreateConVar("bombradius", "600", "Explosion radius.", 0, true, 50.0, true, 3000.0);
    CreateConVar("damagebomb", "220", "Damage when bomb explodes.");
    HookEvent("arena_round_start", roundstart);
    HookEvent("arena_win_panel", arenawin);
}
public OnMapStart()
{
    Handle gameConfig = LoadGameConfigFile("funcommands.games");
    if (gameConfig == null)
    {
        SetFailState("Unable to load game config funcommands.games");
        return;
    }
    if (GameConfGetKeyValue(gameConfig, "SoundBoom", g_BoomSound, sizeof(g_BoomSound)) && g_BoomSound[0])
    {
        PrecacheSound(g_BoomSound, true);
    }
    char buffer[PLATFORM_MAX_PATH];
    if (GameConfGetKeyValue(gameConfig, "SpriteExplosion", buffer, sizeof(buffer)) && buffer[0])
    {
        g_ExplosionSprite = PrecacheModel(buffer);
    }
    delete gameConfig;
}
public Action whosthebomber(int client, int args)
{
    if (bomblock == true)
    {
        PrintToChat(client, "You cannot vote at this time.");
        voted[client] = false;
        return Plugin_Handled;
    }

    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    votesneeded = RoundToFloor(float(votes) * cv_votesneeded);
    if (voted[client] == true)
    {
        PrintToChat(client, "[SM] You have already voted!");
    }
    if (voted[client] == false)
    {
        if (votes == 0)
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
        else
        {
            votes++;
            PrintToChatAll("%N has voted for 'Who's the Bomber', vote %i.", client, votes);
            voted[client] = true;
        }
    }
    if (votes >= votesneeded && finalbomber == 0 && bomberexists == false)
    {
        for (bomber = 1; bomber <= MaxClients; bomber++)
        {
            if (IsClientInGame(bomber) == true && IsPlayerAlive(bomber) == true)
            {
                if (TF2_GetClientTeam(bomber) == TFTeam_Red)
                {
                    reds[rv++] = bomber;
                }
            }
        }
        sizeofteam = GetTeamClientCount(2);
        pbomber = GetRandomInt(0, sizeofteam);
        finalbomber = reds[pbomber];
        PrintToChatAll("A bomber has been selected!");
        bomberexists = true;
        bomberused = false;
    }
    return Plugin_Handled;
}
public void OnClientDisconnect(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    if (voted[client] == true)
    {
        votes--;
    }
    voters--;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    voted[client] = false;
    return Plugin_Handled;
}
public void OnClientConnected(int client)
{
    if (IsClientInGame(client) == false)
    {
        return Plugin_Handled;
    }
    ConVar imthebomber = FindConVar("bomberratio");
    float cv_votesneeded = GetConVarFloat(imthebomber);
    voted[client] = false;
    voters++;
    votesneeded = RoundToFloor(float(voters) * cv_votesneeded);
    return Plugin_Handled;
}
public Action iamthebomber(int client, int args)
{
    if (bomberexists == false)
    {
        PrintToChat(client, "Bomber does not exist yet!");
        return Plugin_Handled;
    }
    if (IsClientInGame(client) == false && IsClientConnected(client) == false)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    if (bomberexists == true && finalbomber != client)
    {
        PrintToChat(client, "You are not the bomber!");
        return Plugin_Handled;
    }
    else
    {
        if (bomberused == true && finalbomber == client)
        {
            PrintToChat(client, "Your bomb has been used!");
        }
        if (bomberused == false && finalbomber == client)
        {
            ServerCommand("sm_beacon %N", client);
            TF2_AddCondition(client, TFCond_HalloweenBombHead, TFCondDuration_Infinite, 0);
            GetClientAbsOrigin(client, pos1);
            CreateTimer(5.0, bombexplode, _);
            return Plugin_Handled;
        }
        return Plugin_Handled;
    }
}
public Action bombexplode(Handle timer)
{
    if (bomberdead == true)
    {
        return Plugin_Handled;
    }
    else
    {
        float EyeVec[3];
        GetClientEyePosition(finalbomber, EyeVec);
        ConVar bombrad = FindConVar("bombradius");
        ConVar dbomb = FindConVar("damagebomb");
        if (g_ExplosionSprite > -1)
        {
            TE_SetupExplosion(pos1, g_ExplosionSprite, 5.0, 1, 0, bombrad.IntValue, 5000);
            TE_SendToAll();
        }
        if (g_BoomSound[0])
        {
            EmitAmbientSound(g_BoomSound, EyeVec, finalbomber, SNDLEVEL_RAIDSIREN);
        }
        for (int i = 1; i <= MaxClients; i++)
        {
            if (i != finalbomber && IsClientInGame(i) && IsPlayerAlive(i) && TF2_GetClientTeam(i) != TFTeam_Red)
            {
                if(!TF2_IsPlayerInCondition(i, TFCond_Ubercharged))
                {
                    GetClientAbsOrigin(i, pos2);
                    if(GetVectorDistance(pos1, pos2) <= GetConVarFloat(bombrad))
                    {
                        int damage = GetConVarInt(dbomb);
                        if(GetClientHealth(i) - damage <= 0)
                        {
                            PrintToChatAll("%N has died from the explosion!", i);
                        }
                        SDKHooks_TakeDamage(i, 0, finalbomber, GetConVarFloat(dbomb), DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB);
                    }
                }
                ForcePlayerSuicide(finalbomber);
                if (IsPlayerAlive(finalbomber) == false)
                {
                    PrintToChatAll("The bomber, %N, is dead!", finalbomber);
                    TF2_RemoveCondition(finalbomber, TFCond_HalloweenBombHead);
                    bomberdead = true;
                }
            }
        }
    }
    return Plugin_Handled;
}
public Action roundstart(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = false;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
public Action arenawin(Event event, const char[] name, bool dontBroadcast)
{
    bomberused = false;
    bomblock = true;
    finalbomber = 0;
    rv = 0;
    votes = 0;
    bomberdead = false;
    bomberexists = false;
    for (int i = 1; i <= MaxClients; i++)
    {
        voted[i] = false;
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
I think I'm finished, and oh, is it awesomely funny.

You know that bombinomicon effect? Where your head becomes a bomb? It does this, and then you blow and and kill blus around you (if they don't kill you first).
You have 5 seconds to blow.

The vote convar is typically .6 vote ratio, so 32 times .6 for a full server means that 19 votes are required for the bomber to be selected, and to vote you do !wtb, /wtb, or sm_wtb.
The next step is the bomber. Now, the bomber himself can only do this, and that is the command !iamtb, /iamtb, or sm_iamtb, which allows you to become a suicide bomber for the reds.
Just a little idea I had that turned into a big code.
Happily, it works, under most scenarios (I haven't tested them all).
EDIT:
I think the bombinomicon shit broke it...
EDIT 2:
Fixed it, props to @EmNudge for suggesting it, simply putting a block on the console for the client index 0 fixed it.
I put a printtochatall function with the name and index of each finalbomber and found that console wasn't getting filtered properly.
So I filtered it.
 
Top