|
Veteran Member
|
12-19-2018
, 16:32
Re: Start health ct
|
#9
|
Quote:
Originally Posted by CliptonHeist
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 CTHealth, enable;
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[] name, bool dontBroadcast)
{
int client = event.GetInt("userid");
if (enable.BoolValue)
{
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT)
CreateTimer(2.0, ChangeHP, client, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action ChangeHP(Handle timer, int client)
{
if(IsValidClient(client))
{
int hp = CTHealth.IntValue;
SetEntityHealth(client, hp);
}
return Plugin_Stop;
}
stock bool IsValidClient(int client)
{
return client >= 1 &&
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
|
|
|
|