Raised This Month: $51 Target: $400
 12% 

Need help with modifying TF2 plugin - Kritzkrieg crits


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jacobs
Junior Member
Join Date: Jul 2015
Old 07-31-2015 , 13:15   Need help with modifying TF2 plugin - Kritzkrieg crits
Reply With Quote #1

Hello,
I would need to edit this code (plugin for TF2) and add to code critical hits only for the red team. And farther so that the plugin (command sm_crits) worked for all players.
Thank you very much for your help.

PHP Code:
#include <tf2>
#include <tf2_stocks>

new bool:CritsEnabled[MAXPLAYERS+1] = false;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_crits",Command_CritsADMFLAG_GENERIC);
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
OnClientPutInServer(clientCritsEnabled[client] = false;

public 
Action:Command_Crits(client,args)
{
    if(
CritsEnabled[client])
    {
        
CritsEnabled[client] = false;
        if(
IsPlayerAlive(client)) TF2_RemoveCondition(clientTFCond_CritOnWin);
        
PrintToChat(client"\x04Crits Disabled");
        return 
Plugin_Handled;
    }
    else
    {
        
CritsEnabled[client] = true;
        if(
IsPlayerAlive(client)) TF2_AddCondition(clientTFCond_CritOnWin, -1.0);
        
PrintToChat(client"\x04Crits Enabled");
        return 
Plugin_Handled;
    }
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
CritsEnabled[client]) TF2_AddCondition(clientTFCond_CritOnWin, -1.0);

Jacobs is offline
Send a message via Skype™ to Jacobs
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 07-31-2015 , 13:46   Re: Need help with modifying TF2 plugin - Kritzkrieg crits
Reply With Quote #2

Here ya go, just add GetClientTeam.

PHP Code:
#include <tf2> 
#include <tf2_stocks> 

new bool:CritsEnabled[MAXPLAYERS+1] = false

public 
OnPluginStart() 

    
RegAdminCmd("sm_crits",Command_CritsADMFLAG_GENERIC); 
    
HookEvent("player_spawn"Event_PlayerSpawn); 


public 
OnClientPutInServer(clientCritsEnabled[client] = false

public 
Action:Command_Crits(client,args
{
    new 
clientTeam GetClientTeam(client);
    if(
clientTeam == _:TFTeam_Red) {
        if(
CritsEnabled[client]) 
        { 
            
CritsEnabled[client] = false
            if(
IsPlayerAlive(client)) TF2_RemoveCondition(clientTFCond_CritOnWin); 
            
PrintToChat(client"\x04Crits Disabled"); 
        } 
        else 
        { 
            
CritsEnabled[client] = true
            if(
IsPlayerAlive(client)) TF2_AddCondition(clientTFCond_CritOnWin, -1.0); 
            
PrintToChat(client"\x04Crits Enabled");  
        }
    }
    else {
        
PrintToChat(client"\x04No crits for blue team!"); 
    }
    return 
Plugin_Handled;


public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
clientTeam GetClientTeam(client);
    if(
CritsEnabled[client] && clientTeam == _:TFTeam_Red) {
        
TF2_AddCondition(clientTFCond_CritOnWin, -1.0);
    }

__________________

Last edited by Chaosxk; 07-31-2015 at 13:46.
Chaosxk is offline
Jacobs
Junior Member
Join Date: Jul 2015
Old 08-02-2015 , 09:40   Re: Need help with modifying TF2 plugin - Kritzkrieg crits
Reply With Quote #3

Quote:
Originally Posted by Chaosxk View Post
Here ya go, just add GetClientTeam.
code...
Thank you for your help,
but I need to command sm_crits added all the red team on the server crits. And not only me.
When I enter rcon sm_crits 1 it throws an error.

Code:
[SM] Native "GetClientTeam" reported: Client index 0 is invalid
Jacobs is offline
Send a message via Skype™ to Jacobs
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-02-2015 , 11:22   Re: Need help with modifying TF2 plugin - Kritzkrieg crits
Reply With Quote #4

Loop across all the clients (1 to MaxClients), check if they are on team RED, and then apply the crits?

Client index 0 is the server btw.
Potato Uno is offline
Reply



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 06:21.


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