Yet another plugin (probably not done right, it's for VSH)

SNC

Recognized Member
#include <sourcemod>
#include <tf2>
#include <freak_fortress_2>

#pragma semicolon 1

int saxtonclientid = -1;
int saxtonhealth = -1;
public OnPluginStart()
{
HookEvent("player_death", Event_Playerdeath);
HookEvent("arena_win_panel", Event_ArenaWin);
}
public Action Event_Playerdeath(Event event, const char[] name, bool dontBroadcast)
{
int useridhale = 0;
saxtonclientid = GetClientOfUserId(useridhale);
if (saxtonclientid == -1 || IsPlayerAlive(saxtonclientid) == false || IsClientInGame(saxtonclientid) == false)
{
return Plugin_Handled;
}
saxtonhealth = GetClientHealth(saxtonclientid);
if (saxtonhealth <= 10000)
{
TF2_AddCondition(saxtonclientid, TFCond_SpeedBuffAlly, TFCondDuration_Infinite, 0);
PrintToChatAll("The boss has been given a speed boost!");
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action Event_ArenaWin(Event event, const char[] name, bool dontBroadcast)
{
TF2_RemoveCondition(saxtonclientid, TFCond_SpeedBuffAlly);
return Plugin_Handled;
}

Ok, so what this does is basically when hale's health goes below 10,000 he gets a speed boost (like from the Disciplinary Action). This isn't necessarily going to be implemented, and I don't even know if it works (it should, but I don't have any experience to tell you that this will work).
It probably won't even work on a game level, with this being a practical nightmare for players going against hale. It's just a test to see if I can code for VSH.
Any critiques would be helpful.
I think, I THINK, it would work though.
 

SNC

Recognized Member
Teach me how to code
I hope you're talking to asu. I am a novice, if I were to teach you all your code would look like gobbledygook.
 

Nessmonk

Recognized Member
I hope you're talking to asu. I am a novice, if I were to teach you all your code would look like gobbledygook.
I'll speak to Asu in private, thanks for the heads-up XD
 

EmNudge

allowed the sun back into the spy room
Because I don't want to post a dump of code in private chat:
PHP:
#pragma semicolon 1

#include <sourcemod>

public void OnPluginStart()
{
    RegAdminCmd("sm_8ball", Command_Eightball, 0, "Returns a psuedo-random answer from an array of strings" );
}

    new LastUsed[MAXPLAYERS+1];
public OnClientPutInServer(client){
    LastUsed[client] = 0;
}

public Action:Command_Eightball(client, args)
{
    new currentTime = GetTime();

    if (currentTime - LastUsed[client] < 5){
        PrintToChat(client, "\x01[SM] \x04%d\x01 seconds left for the cool down.", 5-(currentTime-LastUsed[client]));
        return Plugin_Handled;
    }

    LastUsed[client] = currentTime;


    new String:g_strAnswers[][] = {"Certainly.", "The Stars Say Yes.", "My Sources Say No.",
    "Ask Again Later.", "Yes, Obviously.", "Yup", "Of Course.", "Definitely Not."};

    new randomans = GetRandomInt(0, 7);
    decl String:Message[192];


    if (args > 0){
        GetCmdArgString(Message, sizeof(Message));
        PrintToChat(client, "\x04You asked\x01: %s", Message);
    }

    PrintToChat(client, "\x04The Magic 8 Ball Replies\x01: %s", g_strAnswers[randomans]);

    return Plugin_Handled;
}

That's the magic 8 ball plugin thing. I just like the simple idea, so I took 5 minutes from my time.

usage:
sm_8ball
sm_8ball <message>

Adding a message will return what you said in chat for reference. No message will just return an answer.
8ball.png

Note: I used a listen server for this and it works perfectly. If you use one as well to test out a plugin (which I strongly advise if you lack access to a dedicated server) make sure to use the
-insecure
parameter within TF2's Launch Options or else TF2 will not let any third party plugin, like sourcemod, function.
 
Last edited:

Yuki

Administrator
Staff member
TF2 Admin
Because I don't want to post a dump of code in private chat:
PHP:
#pragma semicolon 1

#include <sourcemod>

public void OnPluginStart()
{
    RegAdminCmd("sm_8ball", Command_Eightball, 0, "Returns a psuedo-random answer from an array of strings" );
}

    new LastUsed[MAXPLAYERS+1];
public OnClientPutInServer(client){
    LastUsed[client] = 0;
}

public Action:Command_Eightball(client, args)
{
    new currentTime = GetTime();

    if (currentTime - LastUsed[client] < 5){
        PrintToChat(client, "\x01[SM] \x04%d\x01 seconds left for the cool down.", 5-(currentTime-LastUsed[client]));
        return Plugin_Handled;
    }

    LastUsed[client] = currentTime;


    new String:g_strAnswers[][] = {"Certainly.", "The Stars Say Yes.", "My Sources Say No.",
    "Ask Again Later.", "Yes, Obviously.", "Yup", "Of Course.", "Definitely Not."};

    new randomans = GetRandomInt(0, 7);
    decl String:Message[192];


    if (args > 0){
        GetCmdArgString(Message, sizeof(Message));
        PrintToChat(client, "\x04You asked\x01: %s", Message);
    }

    PrintToChat(client, "\x04The Magic 8 Ball Replies\x01: %s", g_strAnswers[randomans]);

    return Plugin_Handled;
}

That's the magic 8 ball plugin thing. I just like the simple idea, so I took 5 minutes from my time.

usage:
sm_8ball
sm_8ball <message>

Adding a message will return what you said in chat for reference. No message will just return an answer.
View attachment 2219
Note: I used a listen server for this and it works perfectly. If you use one as well to test out a plugin (which I strongly advise if you lack access to a dedicated server) make sure to use the parameter within TF2's Launch Options or else TF2 will not let any third party plugin, like sourcemod, function.
How do you survive with old decls and non transitional syntax?
 

EmNudge

allowed the sun back into the spy room
How do you survive with old decls and non transitional syntax?
Haven't touched the language since 1.6 - the transitional, C like syntax was introduced in 1.7.
Doesn't make much of a difference here, but:
PHP:
#pragma semicolon 1

#include <sourcemod>

public void OnPluginStart()
{
    RegAdminCmd("sm_8ball", Command_Eightball, 0, "Returns a psuedo-random answer from an array of strings" );
}

    int LastUsed[MAXPLAYERS+1];
public OnClientPutInServer(client){
    LastUsed[client] = 0;
}

public Action:Command_Eightball(client, args)
{
    int currentTime = GetTime();
   
    if (currentTime - LastUsed[client] < 5){
        PrintToChat(client, "\x01[SM] \x04%d\x01 seconds left for the cool down.", 5-(currentTime-LastUsed[client]));
        return Plugin_Handled;
    }

    LastUsed[client] = currentTime;
   
   
    char g_strAnswers[][] = {"Certainly.", "The Stars Say Yes.", "My Sources Say No.", 
    "Ask Again Later.", "Yes, Obviously.", "Yup", "Of Course.", "Definitely Not."};
   
    int randomans = GetRandomInt(0, 7);
    char Message[192];
   
   
    if (args > 0){
        GetCmdArgString(Message, sizeof(Message));
        PrintToChat(client, "\x04You asked\x01: %s", Message);
    }

    PrintToChat(client, "\x04The Magic 8 Ball Replies\x01: %s", g_strAnswers[randomans]);
   
    return Plugin_Handled;
}
 
Last edited:
Top