Raised This Month: $535 Target: $400
 133% 

[tf2] need to grant a condition to capping players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
possibly_yaboi_mark
Junior Member
Join Date: Jul 2022
Old 10-29-2022 , 15:20   [tf2] need to grant a condition to capping players
Reply With Quote #1

i need to grant a condition to capping players, specifically through an sdkhook of the clients thinking. if "sdk of the clients thinking" is a bit too vauge, which i'll admit it probably is, i have a script below for elaborating on what i mean.

PHP Code:
#pragma semicolon 1
#include <sourcemod>

#include <tf2>
#include <sdkhooks>

#pragma newdecls required

public void OnMapStart() {
    for (
int i 1<= MaxClientsi++) {
        if (
IsClientInGame(i)) {
            
OnClientPutInServer(i);
        }
    }
}

public 
void OnClientPutInServer(int client) {
    
SDKHook(clientSDKHook_PostThinkPostOnClientPostThinkPost);
}

void OnClientPostThinkPost(int client) {
    if (
INSERT CHECK FOR WHETHER THE CLIENT IS CAPPING HERE) { //the check for whether the client is capping would go here
        
TF2_AddCondition(client421.0client);
    }

possibly_yaboi_mark is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-29-2022 , 16:37   Re: [tf2] need to grant a condition to capping players
Reply With Quote #2

I have a plugin that rewards players who captured (past tense) a control point. It wouldn't take much to change the hooked captured event to something more to your liking, as long as it lists the person(s) capping, like "teamplay_point_startcapture". Here's a link to Team Fortress 2 Events: https://wiki.alliedmods.net/Team_Fortress_2_Events

This particular plugin rewards every human player who captured the objective with $500 cash (I use money in my server), 5 seconds of a few nice buff conditions, a short visual effect, and a cheer sound heard by the cappers.

Note: I never would have been able to make this plugin without the help of the very talented Bacardi.

Code:
PHP Code:
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

#define CHEER    "/ambient_mp3/bumper_car_cheer3.mp3"

public Plugin myinfo 
{
    
name "[TF2] Who Captured the Point",
    
author "PC Gamer, with help from Bacardi",
    
description "Show who captured the control point",
    
version PLUGIN_VERSION,
    
url "www.sourcemod.com"
}

public 
void OnPluginStart()
{
    
HookEvent("teamplay_point_captured"teamplay_point_captured);
}

public 
void OnMapStart()
{
    
PrecacheSound(CHEER);
}

public 
void teamplay_point_captured(Event eventchar[] namebool dontBroadcast)
{
    
char cappers[32];        // example, event output "cappers" string: \x01\x02\x03
    
int client_index;

    
char message[200];

    
event.GetString("cappers"capperssizeof(cappers));

    
int cappers_count strlen(cappers);
    
int[] cappers_array = new int[cappers_count]; // store client indexs
    
    
for(int x 0cappers_countx++)
    {
        
client_index view_as<int>(cappers[x]);

        
Format(messagesizeof(message), "%s, %N"messageclient_index);
        
cappers_array[x] = client_index;
    }

    
PrintToServer("%s captured control point"message[2]);
    
    for(
int y 0cappers_county++)
    {
        if(!
IsFakeClient(cappers_array[y]))
        {
            
PrintToServer("%N is a Human who capped a control point"cappers_array[y]);

            
ServerCommand("sm_addcash #%d 500"GetClientUserId(cappers_array[y]));
            
ServerCommand("sm_addcond #%d 26 5"GetClientUserId(cappers_array[y])); 
            
ServerCommand("sm_addcond #%d 29 5"GetClientUserId(cappers_array[y]));
            
ServerCommand("sm_addcond #%d 16 5"GetClientUserId(cappers_array[y]));
            
ServerCommand("sm_addcond #%d 6 5"GetClientUserId(cappers_array[y]));
            
PrintToChat(cappers_array[y], "Enjoy Bonuses for capping the control point");
            
PrintToServer("Gave Capture Bonuses to %N"cappers_array[y]);
            
EmitSoundToClient(cappers_array[y], CHEER);    
        }        
    }


Last edited by PC Gamer; 10-29-2022 at 17:32.
PC Gamer is offline
possibly_yaboi_mark
Junior Member
Join Date: Jul 2022
Old 11-03-2022 , 21:59   Re: [tf2] need to grant a condition to capping players
Reply With Quote #3

thank you!
possibly_yaboi_mark is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:14.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Theme made by Freecode