Raised This Month: $32 Target: $400
 8% 

API Scripting Help Limited respawn in surv/nems rounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 07-12-2019 , 02:14   Limited respawn in surv/nems rounds
Reply With Quote #1

Hi,
this is respawn system in zombie plague , what i should do to make it limited respawn in nemesis/survivor rounds ? (only 2 , 3 times respawn in surv/nemes rounds)
PHP Code:
// Respawn Player Task (deathmatch)
public respawn_player_task(taskid)
{
    
// Already alive or round ended
    
if (g_isalive[ID_SPAWN] || g_endround)
        return;
    
    
// Get player's team
    
static team
    team 
fm_cs_get_user_team(ID_SPAWN)
    
    
// Player moved to spectators
    
if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
        return;
    
    
// Respawn player automatically if allowed on current round
    
if (!g_swarmround || get_pcvar_num(cvar_allowrespawnswarm)) 
    && (!
g_nemround || get_pcvar_num(cvar_allowrespawnnem)) 
    && (!
g_plagueround || get_pcvar_num(cvar_allowrespawnplague)) 
    && ((!
g_survround || get_pcvar_num(cvar_allowrespawnsurv)) 
    {

        
// Infection rounds = none of the above
        
if (!get_pcvar_num(cvar_allowrespawninfection) && !g_survround && !g_nemround &&  && !g_swarmround && !g_plagueround)
            return;
        
        
// Respawn if only the last human is left? (ignore this setting on survivor rounds)
        
if (!g_survround && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() <= 1)
            return;
        
        
// Respawn as zombie?
        
if (get_pcvar_num(cvar_deathmatch) == || (get_pcvar_num(cvar_deathmatch) == && random_num(01)) || (get_pcvar_num(cvar_deathmatch) == && fnGetZombies() < fnGetAlive()/2))
            
g_respawn_as_zombie[ID_SPAWN] = true
        
        
// Override respawn as zombie setting on nemesis and survivor rounds
        
if (g_survroundg_respawn_as_zombie[ID_SPAWN] = true
        
else if (g_nemroundg_respawn_as_zombie[ID_SPAWN] = false
        
        respawn_player_manually
(ID_SPAWN)
    }
}

// Respawn Player Check Task (if killed by worldspawn)
public respawn_player_check_task(taskid)
{
    
// Successfully spawned or round ended
    
if (g_isalive[ID_SPAWN] || g_endround)
        return;
    
    
// Get player's team
    
static team
    team 
fm_cs_get_user_team(ID_SPAWN)
    
    
// Player moved to spectators
    
if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
        return;
    
    
// If player was being spawned as a zombie, set the flag again
    
if (g_zombie[ID_SPAWN]) g_respawn_as_zombie[ID_SPAWN] = true
    
else g_respawn_as_zombie[ID_SPAWN] = false
    
    respawn_player_manually
(ID_SPAWN)
}

// Respawn Player Manually (called after respawn checks are done)
respawn_player_manually(id)
{
    
// Set proper team before respawning, so that the TeamInfo message that's sent doesn't confuse PODBots
    
if (g_respawn_as_zombie[id])
        
fm_cs_set_user_team(idFM_CS_TEAM_T)
    else
        
fm_cs_set_user_team(idFM_CS_TEAM_CT)
    
    
// Respawning a player has never been so easy
    
ExecuteHamB(Ham_CS_RoundRespawnid)

Thanks.
LearninG is offline
AmXDusT
Member
Join Date: Feb 2019
Location: Italy / Albania
Old 07-12-2019 , 17:17   Re: Limited respawn in surv/nems rounds
Reply With Quote #2

create a counter for respawns.
whenever you're checking respawns, check if counter >= max_respawns when it's survround or nemround. if it is, return. otherwise do counter++

eventually reset the counter on round start.
AmXDusT is offline
Reply


Thread Tools
Display Modes

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 09:38.


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