Thread: Start health ct
View Single Post
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-19-2018 , 16:32   Re: Start health ct
Reply With Quote #9

Quote:
Originally Posted by CliptonHeist View Post
Also cfg file isn't being created so those convars are basically useless and there's no client validity check in the timer...

This should work however I haven't tested it:
PHP Code:
#include <sourcemod>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

//Plugin Information:
public Plugin myinfo 
{
    
name "Set HP"
    
author "The Doggy"
    
description "Sets CT HP."
    
version PLUGIN_VERSION,
    
url "coldcommunity.com"
};

ConVar CTHealthenable;

public 
void OnPluginStart()
{
    
CTHealth CreateConVar("sm_cthp_on_spawn""1000""Change CT health");
    
enable CreateConVar("sm_enable_change_hp""1""enable/disable plugin");
    
AutoExecConfig(true"sm_cthp");
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client event.GetInt("userid");
    if (
enable.BoolValue)
    {
        if (
IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT)
            
CreateTimer(2.0ChangeHPclientTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action ChangeHP(Handle timerint client)
{
    if(
IsValidClient(client))
    {
        
int hp CTHealth.IntValue;
        
SetEntityHealth(clienthp);
    }
    return 
Plugin_Stop;
}

stock bool IsValidClient(int client)
{
    return 
client >= && 
    
client <= MaxClients && 
    
IsClientConnected(client) && 
    
IsClientAuthorized(client) && 
    
IsClientInGame(client);

I never use AutoExecConfig functionality. I use server.cfg and server.cfg only. if alliedmods wanted, they could just make one large file, more efficient in term of issues in linux, since lots of cfg files can crash some linux servers in L4D2. That's why I always push my ConVars into server.cfg
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline