AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [tf2] need to grant a condition to capping players (https://forums.alliedmods.net/showthread.php?t=340161)

possibly_yaboi_mark 10-29-2022 14:20

[tf2] need to grant a condition to capping players
 
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);
    }



PC Gamer 10-29-2022 15:37

Re: [tf2] need to grant a condition to capping players
 
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);    
        }        
    }



possibly_yaboi_mark 11-03-2022 20:59

Re: [tf2] need to grant a condition to capping players
 
thank you!


All times are GMT -4. The time now is 20:54.

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