Raised This Month: $ Target: $400
 0% 

A way to limit mp_respawn_on_death_ct?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 04-22-2014 , 14:44   Re: A way to limit mp_respawn_on_death_ct?
Reply With Quote #10

Quote:
Originally Posted by Oshizu View Post
PHP Code:
#include <cstrike>
#include <sdkhooks>

new Handle:roundwin;
new 
Lifes[MAXPLAYERS+1] = 0

public OnPluginStart()
{
    
HookEvent("player_death"PlayerDeathEventHookMode_Pre// When Player Dies
    
HookEvent("round_start"RoundStartEventHookMode_Post// When new round starts
    
    
roundwin FindConVar("mp_ignore_round_win_conditions")
}

public 
Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
SetConVarInt(roundwin1)
    for(new 
1<= MaxClientsi++) // Loop Throught All Clients
    
{
        if(
IsClientInGame(i)) // If Player Is In Game
        
{
            
Lifes[i] = // 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 1<= MaxClientsi++) // 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(roundwin0)
        
DoItLazyWay(2)
    }
    else if(
t_life == 0)
    {
        
SetConVarInt(roundwin0)
        
DoItLazyWay(3)
    }
}

public 
OnClientPutInServer(client)
{
    
Lifes[client] = // When player joins server he will receive 3 lifes
}

stock DoItLazyWay(team)
{
    new 
player GetRandomPlayer(team)
    
CS_RespawnPlayer(player)
    
CreateTimer(0.5LazyTimerplayer)
}

public 
Action:LazyTimer(Handle:timerany:player)
{
    
SDKHooks_TakeDamage(player001000.0)
}

stock GetRandomPlayer(team
{
    new 
clients[MaxClients+1], clientCount;
    for (new 
1<= MaxClientsi++)
        if (
IsClientInGame(i) && (GetClientTeam(i) == team))
            
clients[clientCount++] = i;
    return (
clientCount == 0) ? -clients[GetRandomInt(0clientCount-1)];

This one might fix round end issue
Thank you very much, this worked perfectly!
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
 



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 05:03.


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