Raised This Month: $ Target: $400
 0% 

[tf2] need to grant a condition to capping players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-29-2022 , 15: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 16:32.
PC Gamer is offline
 



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 20:54.


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