 |
|
AlliedModders Donor
Join Date: Dec 2012
Location: England
|

04-22-2014
, 14:44
Re: A way to limit mp_respawn_on_death_ct?
|
#10
|
Quote:
Originally Posted by Oshizu
PHP Code:
#include <cstrike>
#include <sdkhooks>
new Handle:roundwin;
new Lifes[MAXPLAYERS+1] = 0
public OnPluginStart()
{
HookEvent("player_death", PlayerDeath, EventHookMode_Pre) // When Player Dies
HookEvent("round_start", RoundStart, EventHookMode_Post) // When new round starts
roundwin = FindConVar("mp_ignore_round_win_conditions")
}
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
SetConVarInt(roundwin, 1)
for(new i = 1; i <= MaxClients; i++) // Loop Throught All Clients
{
if(IsClientInGame(i)) // If Player Is In Game
{
Lifes[i] = 3 // Reset Life To 3
}
}
}
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(Lifes[client] > 0) // If client has more than 0 lifes
{
CS_RespawnPlayer(client) // respawn him
Lifes[client]-- // remove one life
}
new ct_life = 0
new t_life = 0
for(new i = 1; i <= MaxClients; i++) // Loop Throught All Clients
{
if(IsClientInGame(i))
{
if(IsPlayerAlive(i))
{
if(GetClientTeam(i) == 2)
{
t_life++
}
else if(GetClientTeam(i) == 3)
{
ct_life++
}
}
}
}
if(ct_life == 0)
{
SetConVarInt(roundwin, 0)
DoItLazyWay(2)
}
else if(t_life == 0)
{
SetConVarInt(roundwin, 0)
DoItLazyWay(3)
}
}
public OnClientPutInServer(client)
{
Lifes[client] = 3 // When player joins server he will receive 3 lifes
}
stock DoItLazyWay(team)
{
new player = GetRandomPlayer(team)
CS_RespawnPlayer(player)
CreateTimer(0.5, LazyTimer, player)
}
public Action:LazyTimer(Handle:timer, any:player)
{
SDKHooks_TakeDamage(player, 0, 0, 1000.0)
}
stock GetRandomPlayer(team)
{
new clients[MaxClients+1], clientCount;
for (new i = 1; i <= MaxClients; i++)
if (IsClientInGame(i) && (GetClientTeam(i) == team))
clients[clientCount++] = i;
return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount-1)];
}
This one might fix round end issue
|
Thank you very much, this worked perfectly!
__________________
|
|
|
|