PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>
#pragma newdecls required
int g_Spawns[MAXPLAYERS + 1];
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
for (int i = 1; i <= MaxClients; i++)
{
OnClientConnected(i);
}
}
public void OnClientConnected(int client)
{
g_Spawns[client] = 0;
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
// team validation
int clientTeam = event.GetInt("teamnum");
if (clientTeam < CS_TEAM_T)
{
return;
}
int userId = event.GetInt("userid");
int client = GetClientOfUserId(userId);
// client validation
if (!client || !IsClientInGame(client))
{
return;
}
g_Spawns[client]++;
if (g_Spawns[client] >= 3)
{
g_Spawns[client] = 0;
RequestFrame(Frame_GiveHealth, userId);
}
}
public void Frame_GiveHealth(int userId)
{
int client = GetClientOfUserId(userId);
if (!client || !IsClientInGame(client) || !IsPlayerAlive(client))
{
return;
}
SetEntityHealth(client, 150);
}
__________________