Raised This Month: $51 Target: $400
 12% 

Help / Support [HELP] Get players correctly on infection mode 5.0


Post New Thread Reply   
 
Thread Tools Display Modes
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-06-2015 , 20:09   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #11

Make a global var like g_zombie_lastround[33], then upon round end, set it to 1 for those who are zombie, and 0 for those who aren't.
__________________
Currently offline for study.
RateX is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-06-2015 , 21:52   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #12

ok thx, well another problem is that when the zombies appears choose the same player twice, for example in the print say this "watch out sebastian, jackson and jackson are infected" choose the same person twice, how i can fix that?

i think i have to edit this:

PHP Code:
// Get Alive Count -returns alive players number- 
GetAliveCount() 

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id)) 
            
iAlive++ 
    } 
     
    return 
iAlive


// Get Random Alive -returns index of alive player number target_index - 
GetRandomAlive(target_index

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id)) 
            
iAlive++ 
         
        if (
iAlive == target_index
            return 
id
    } 
     
    return -
1


Last edited by wicho; 03-06-2015 at 21:54.
wicho is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-07-2015 , 09:24   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #13

It's simple. In zp_fw_gamemodes_choose_post, the players are chosen randomly, and the players aren't zombies yet. However GetRandomAlivehuman and GetAliveCountHuman functions contain check whether they are zombies or not, which result in player can be chosen more than once.
The solution is to add in their check if the player id equal to the previous chosen ones.
__________________
Currently offline for study.
RateX is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-07-2015 , 17:13   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #14

mm ok, I'm going to test some codes, but could you leave me an example code please..
wicho is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-07-2015 , 22:38   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #15

To prevent messing up the functionality of the plugin, first, in zp_fw_gamemodes_choose_post replace GetRandomAlivehuman and GetAliveCountHuman with GetRandomAlive and GetAliveCount respectively. Then in their check:
PHP Code:
if (is_user_alive(id)) 

PHP Code:
if (is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2
Finally reset g_TargetPlayer and g_TargetPlayer2 at round end if it hasn't done in the code.
__________________
Currently offline for study.

Last edited by RateX; 03-07-2015 at 22:39.
RateX is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-07-2015 , 23:34   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #16

mm so u say this..

PHP Code:
// Get Alive Count -returns alive players number-  
GetAliveCount()  
{  
    new 
iAliveid  
      
    
for (id 1id <= g_MaxPlayersid++)  
    {  
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2)  
            
iAlive++  
    }  
      
    return 
iAlive;  
}  

// Get Random Alive -returns index of alive player number target_index -  
GetRandomAlive(target_index)  
{  
    new 
iAliveid  
      
    
for (id 1id <= g_MaxPlayersid++)  
    {  
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2)  
            
iAlive++  
          
        if (
iAlive == target_index)  
            return 
id;  
    }  
      
    return -
1;  
}  

public 
zp_fw_gamemodes_end() 
{                 
    
g_TargetPlayer 0
    g_TargetPlayer2 
0


Last edited by wicho; 03-07-2015 at 23:50.
wicho is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-08-2015 , 00:55   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #17

^Did you test it?
__________________
Currently offline for study.
RateX is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-08-2015 , 01:21   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #18

i will test when i get home but i have a question i dont need to add g_TargetPlayer3 too?

EDIT: i tested but choose the first zombie when are thirteen or less players and i put in code to choose one zombie when are ten on less, I guess when we do these checks (id != g_TargetPlayer && id != g_TargetPlayer2) increases the amount for two when the zombies appears, I choose zombies depends of the amount of players like this:

-if there are ten players or less pick one zombie.
-if there are ten players or more pick two zombies.
-if there are twenty five players or more pick three zombies.

with these checks would look like this:

-if there are thirteen players or less pick one zombie.
-if there are thirteen players or more pick two zombies.
-if there are twenty eight players or more pick three zombies.

Last edited by wicho; 03-08-2015 at 04:11.
wicho is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-09-2015 , 02:24   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #19

sorry for double post but sometimes the first zombie dont appear and in logs appear this:

L 03/08/2015 - 227:44: Start of error session.
L 03/08/2015 - 227:44: Info (map "zm_foda") (file "addons/amxmodx/logs/error_20150308.log")
L 03/08/2015 - 227:44: [zp50_zp43_compat.amxx] ERROR - first zombie index not found!
L 03/08/2015 - 227:44: [AMXX] Displaying debug trace (plugin "zp50_zp43_compat.amxx", version "5.0.5")
L 03/08/2015 - 227:44: [AMXX] Run time error 27: unknown error
L 03/08/2015 - 227:44: [AMXX] [0] zp50_zp43_compat.sma::zp_fw_gamemodes_start (line 146)

PHP Code:
public zp_fw_gamemodes_start(game_mode_id)
{
    if (
game_mode_id == g_GameModeInfectionID)
    {
        
// Get first zombie index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_core_is_zombie(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - first zombie index not found!")
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_INFECTIONplayer_index)
    }
    else if (
game_mode_id == g_GameModeMultiID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_MULTI0)
    }
    else if (
game_mode_id == g_GameModeNemesisID)
    {
        
// Get nemesis index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_class_nemesis_get(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - nemesis index not found!"//this is the line
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_NEMESISplayer_index)
    }
    else if (
game_mode_id == g_GameModeSurvivorID)
    {
        
// Get survivor index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_class_survivor_get(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - survivor index not found!")
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_SURVIVORplayer_index)
    }
    else if (
game_mode_id == g_GameModeSwarmID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_SWARM0)
    }
    else if (
game_mode_id == g_GameModePlagueID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_PLAGUE0)
    }
    else
    {
        
// Custom game mode started, pass MODE_CUSTOM (0) as mode parameter
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_CUSTOM0)
    }
    
    
g_ModeStarted true

I do not understand why this happens I have the code mode of infection in this form:

PHP Code:
/*================================================================================ 
     
    --------------------------------- 
    -*- [ZP] Game Mode: Infection -*- 
    --------------------------------- 
     
    This plugin is part of Zombie Plague Mod and is distributed under the 
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details. 
     
================================================================================*/ 

#include <amxmodx> 
#include <fun> 
#include <fakemeta> 
#include <hamsandwich> 
#include <cs_teams_api> 
#include <cs_ham_bots_api> 
#include <zp50_gamemodes> 
#include <zp50_deathmatch> 

// HUD messages 
#define HUD_EVENT_X -1.0 
#define HUD_EVENT_Y 0.17 
#define HUD_EVENT_R 255 
#define HUD_EVENT_G 0 
#define HUD_EVENT_B 0 

new g_MaxPlayers 
new g_HudSync 
new g_TargetPlayerg_TargetPlayer2g_TargetPlayer3 

new cvar_infection_chancecvar_infection_min_players 
new cvar_infection_show_hud 
new cvar_infection_allow_respawncvar_respawn_after_last_human 
new cvar_zombie_first_hp_multiplier
new cvar_zombie_second_hpcvar_zombie_third_hp 

public plugin_precache() 

    
// Register game mode at precache (plugin gets paused after this) 
    
register_plugin("[ZP] Game Mode: Infection"ZP_VERSION_STRING"ZP Dev Team"
    new 
game_mode_id zp_gamemodes_register("Infection Mode"
    
zp_gamemodes_set_default(game_mode_id
     
    
// Create the HUD Sync Objects 
    
g_HudSync CreateHudSyncObj() 
     
    
g_MaxPlayers get_maxplayers() 
     
    
cvar_infection_chance register_cvar("zp_infection_chance""1"
    
cvar_infection_min_players register_cvar("zp_infection_min_players""0"
    
cvar_infection_show_hud register_cvar("zp_infection_show_hud""1"
    
cvar_infection_allow_respawn register_cvar("zp_infection_allow_respawn""1"
    
cvar_respawn_after_last_human register_cvar("zp_respawn_after_last_human""1"
    
cvar_zombie_first_hp_multiplier register_cvar("zp_zombie_first_hp_multiplier""2.0")
    
cvar_zombie_second_hp register_cvar("zp_zombie_second_hp""3.0"
    
cvar_zombie_third_hp register_cvar("zp_zombie_third_hp""2.0")


// Deathmatch module's player respawn forward 
public zp_fw_deathmatch_respawn_pre(id

    
// Respawning allowed? 
    
if (!get_pcvar_num(cvar_infection_allow_respawn)) 
        return 
PLUGIN_HANDLED
     
    
// Respawn if only the last human is left? 
    
if (!get_pcvar_num(cvar_respawn_after_last_human) && zp_core_get_human_count() == 1
        return 
PLUGIN_HANDLED
     
    return 
PLUGIN_CONTINUE


public 
zp_fw_gamemodes_choose_pre(game_mode_idskipchecks

    if (!
skipchecks
    { 
        
        
// Random chance 
        
if (random_num(1get_pcvar_num(cvar_infection_chance)) != 1
            return 
PLUGIN_HANDLED
         
        
// Min players 
        
if (GetAliveCountHuman() < get_pcvar_num(cvar_infection_min_players)) 
            return 
PLUGIN_HANDLED;
                 
    } 
     
    
// Game mode allowed 
    
return PLUGIN_CONTINUE


public 
zp_fw_gamemodes_choose_post(game_mode_idtarget_player)
{             
    
// Pick player randomly?
    
g_TargetPlayer = (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player
    g_TargetPlayer2 
= (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player   
    g_TargetPlayer3 
= (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player    


public 
zp_fw_gamemodes_start() 
{        
    
// Allow infection for this game mode 
    
zp_gamemodes_set_allow_infect()
    
    switch (
GetAliveCountHuman()) 
    { 
        case 
.. 10
        { 
             if(
is_user_alive(g_TargetPlayer))
             {     
                
zp_core_infect(g_TargetPlayerg_TargetPlayer
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))      
             }
        }  
    
        case 
11 .. 20
        {     
             if(
is_user_alive(g_TargetPlayer2))
             {                 
                
zp_core_infect(g_TargetPlayer2g_TargetPlayer2
                
set_user_health(g_TargetPlayer2floatround(get_user_health(g_TargetPlayer2) * get_pcvar_float(cvar_zombie_second_hp)))      
             }

             if(
is_user_alive(g_TargetPlayer))
             {
                
zp_core_infect(g_TargetPlayerg_TargetPlayer)
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))            
             }
        }
    
        case 
21 .. 32
        {     
             if(
is_user_alive(g_TargetPlayer3))
             {      
                
zp_core_infect(g_TargetPlayer3g_TargetPlayer3
                
set_user_health(g_TargetPlayer3floatround(get_user_health(g_TargetPlayer3) * get_pcvar_float(cvar_zombie_third_hp))) 
             }
       
             if(
is_user_alive(g_TargetPlayer2))
             {                 
                
zp_core_infect(g_TargetPlayer2g_TargetPlayer2
                
set_user_health(g_TargetPlayer2floatround(get_user_health(g_TargetPlayer2) * get_pcvar_float(cvar_zombie_second_hp)))      
             }

             if(
is_user_alive(g_TargetPlayer))
             {
                
zp_core_infect(g_TargetPlayerg_TargetPlayer)
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))            
             }
        }           
    }
    
// Remaining players should be humans (CTs) 
    
new id 
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        
// Not alive 
        
if (!is_user_alive(id)) 
            continue; 
         
        
// This is our first zombie 
        
if (zp_core_is_zombie(id)) 
            continue; 
         
        
// Switch to CT 
        
cs_set_player_team(idCS_TEAM_CT
    } 
     
    if (
get_pcvar_num(cvar_infection_show_hud)) 
    { 
        
// Show First Zombie HUD notice 
        
new name[32
        
get_user_name(g_TargetPlayernamecharsmax(name)) 
        
set_hudmessage(HUD_EVENT_RHUD_EVENT_GHUD_EVENT_BHUD_EVENT_XHUD_EVENT_Y00.05.01.01.0, -1
        
ShowSyncHudMsg(0g_HudSync"%L"LANG_PLAYER"NOTICE_FIRST"name
    } 


// Get Alive Count -returns alive players number- 
GetAliveCountHuman() 

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id)) 
            
iAlive++ 
    } 
     
    return 
iAlive


// Get Alive Count -returns alive players number- 
GetAliveCount() 

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2 && id != g_TargetPlayer3
            
iAlive++ 
    } 
     
    return 
iAlive


// Get Random Alive -returns index of alive player number target_index - 
GetRandomAlive(target_index

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2 && id != g_TargetPlayer3
            
iAlive++ 
         
        if (
iAlive == target_index
            return 
id
    } 
     
    return -
1
}  

public 
zp_fw_gamemodes_end() 
{                 
    
g_TargetPlayer 0
    g_TargetPlayer2 
0
    g_TargetPlayer3 
0

you look something wrong? the server had six players when this happened.

Last edited by wicho; 03-09-2015 at 02:27.
wicho is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-09-2015 , 07:21   Re: [HELP] Get players correctly on infection mode 5.0
Reply With Quote #20

Quote:
Originally Posted by wicho View Post
sorry for double post but sometimes the first zombie dont appear and in logs appear this:

L 03/08/2015 - 227:44: Start of error session.
L 03/08/2015 - 227:44: Info (map "zm_foda") (file "addons/amxmodx/logs/error_20150308.log")
L 03/08/2015 - 227:44: [zp50_zp43_compat.amxx] ERROR - first zombie index not found!
L 03/08/2015 - 227:44: [AMXX] Displaying debug trace (plugin "zp50_zp43_compat.amxx", version "5.0.5")
L 03/08/2015 - 227:44: [AMXX] Run time error 27: unknown error
L 03/08/2015 - 227:44: [AMXX] [0] zp50_zp43_compat.sma::zp_fw_gamemodes_start (line 146)

PHP Code:
public zp_fw_gamemodes_start(game_mode_id)
{
    if (
game_mode_id == g_GameModeInfectionID)
    {
        
// Get first zombie index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_core_is_zombie(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - first zombie index not found!")
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_INFECTIONplayer_index)
    }
    else if (
game_mode_id == g_GameModeMultiID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_MULTI0)
    }
    else if (
game_mode_id == g_GameModeNemesisID)
    {
        
// Get nemesis index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_class_nemesis_get(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - nemesis index not found!"//this is the line
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_NEMESISplayer_index)
    }
    else if (
game_mode_id == g_GameModeSurvivorID)
    {
        
// Get survivor index
        
new player_index 1
        
while ((!is_user_alive(player_index) || !zp_class_survivor_get(player_index)) && player_index <= g_MaxPlayers)
            
player_index++
        
        if (
player_index g_MaxPlayers)
        {
            
abort(AMX_ERR_GENERAL"ERROR - survivor index not found!")
            
player_index 0
        
}
        
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_SURVIVORplayer_index)
    }
    else if (
game_mode_id == g_GameModeSwarmID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_SWARM0)
    }
    else if (
game_mode_id == g_GameModePlagueID)
    {
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_PLAGUE0)
    }
    else
    {
        
// Custom game mode started, pass MODE_CUSTOM (0) as mode parameter
        
ExecuteForward(g_Forwards[FW_ROUND_STARTED], g_ForwardResultMODE_CUSTOM0)
    }
    
    
g_ModeStarted true

I do not understand why this happens I have the code mode of infection in this form:

PHP Code:
/*================================================================================ 
     
    --------------------------------- 
    -*- [ZP] Game Mode: Infection -*- 
    --------------------------------- 
     
    This plugin is part of Zombie Plague Mod and is distributed under the 
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details. 
     
================================================================================*/ 

#include <amxmodx> 
#include <fun> 
#include <fakemeta> 
#include <hamsandwich> 
#include <cs_teams_api> 
#include <cs_ham_bots_api> 
#include <zp50_gamemodes> 
#include <zp50_deathmatch> 

// HUD messages 
#define HUD_EVENT_X -1.0 
#define HUD_EVENT_Y 0.17 
#define HUD_EVENT_R 255 
#define HUD_EVENT_G 0 
#define HUD_EVENT_B 0 

new g_MaxPlayers 
new g_HudSync 
new g_TargetPlayerg_TargetPlayer2g_TargetPlayer3 

new cvar_infection_chancecvar_infection_min_players 
new cvar_infection_show_hud 
new cvar_infection_allow_respawncvar_respawn_after_last_human 
new cvar_zombie_first_hp_multiplier
new cvar_zombie_second_hpcvar_zombie_third_hp 

public plugin_precache() 

    
// Register game mode at precache (plugin gets paused after this) 
    
register_plugin("[ZP] Game Mode: Infection"ZP_VERSION_STRING"ZP Dev Team"
    new 
game_mode_id zp_gamemodes_register("Infection Mode"
    
zp_gamemodes_set_default(game_mode_id
     
    
// Create the HUD Sync Objects 
    
g_HudSync CreateHudSyncObj() 
     
    
g_MaxPlayers get_maxplayers() 
     
    
cvar_infection_chance register_cvar("zp_infection_chance""1"
    
cvar_infection_min_players register_cvar("zp_infection_min_players""0"
    
cvar_infection_show_hud register_cvar("zp_infection_show_hud""1"
    
cvar_infection_allow_respawn register_cvar("zp_infection_allow_respawn""1"
    
cvar_respawn_after_last_human register_cvar("zp_respawn_after_last_human""1"
    
cvar_zombie_first_hp_multiplier register_cvar("zp_zombie_first_hp_multiplier""2.0")
    
cvar_zombie_second_hp register_cvar("zp_zombie_second_hp""3.0"
    
cvar_zombie_third_hp register_cvar("zp_zombie_third_hp""2.0")


// Deathmatch module's player respawn forward 
public zp_fw_deathmatch_respawn_pre(id

    
// Respawning allowed? 
    
if (!get_pcvar_num(cvar_infection_allow_respawn)) 
        return 
PLUGIN_HANDLED
     
    
// Respawn if only the last human is left? 
    
if (!get_pcvar_num(cvar_respawn_after_last_human) && zp_core_get_human_count() == 1
        return 
PLUGIN_HANDLED
     
    return 
PLUGIN_CONTINUE


public 
zp_fw_gamemodes_choose_pre(game_mode_idskipchecks

    if (!
skipchecks
    { 
        
        
// Random chance 
        
if (random_num(1get_pcvar_num(cvar_infection_chance)) != 1
            return 
PLUGIN_HANDLED
         
        
// Min players 
        
if (GetAliveCountHuman() < get_pcvar_num(cvar_infection_min_players)) 
            return 
PLUGIN_HANDLED;
                 
    } 
     
    
// Game mode allowed 
    
return PLUGIN_CONTINUE


public 
zp_fw_gamemodes_choose_post(game_mode_idtarget_player)
{             
    
// Pick player randomly?
    
g_TargetPlayer = (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player
    g_TargetPlayer2 
= (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player   
    g_TargetPlayer3 
= (target_player == RANDOM_TARGET_PLAYER) ? GetRandomAlive(random_num(1GetAliveCount())) : target_player    


public 
zp_fw_gamemodes_start() 
{        
    
// Allow infection for this game mode 
    
zp_gamemodes_set_allow_infect()
    
    switch (
GetAliveCountHuman()) 
    { 
        case 
.. 10
        { 
             if(
is_user_alive(g_TargetPlayer))
             {     
                
zp_core_infect(g_TargetPlayerg_TargetPlayer
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))      
             }
        }  
    
        case 
11 .. 20
        {     
             if(
is_user_alive(g_TargetPlayer2))
             {                 
                
zp_core_infect(g_TargetPlayer2g_TargetPlayer2
                
set_user_health(g_TargetPlayer2floatround(get_user_health(g_TargetPlayer2) * get_pcvar_float(cvar_zombie_second_hp)))      
             }

             if(
is_user_alive(g_TargetPlayer))
             {
                
zp_core_infect(g_TargetPlayerg_TargetPlayer)
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))            
             }
        }
    
        case 
21 .. 32
        {     
             if(
is_user_alive(g_TargetPlayer3))
             {      
                
zp_core_infect(g_TargetPlayer3g_TargetPlayer3
                
set_user_health(g_TargetPlayer3floatround(get_user_health(g_TargetPlayer3) * get_pcvar_float(cvar_zombie_third_hp))) 
             }
       
             if(
is_user_alive(g_TargetPlayer2))
             {                 
                
zp_core_infect(g_TargetPlayer2g_TargetPlayer2
                
set_user_health(g_TargetPlayer2floatround(get_user_health(g_TargetPlayer2) * get_pcvar_float(cvar_zombie_second_hp)))      
             }

             if(
is_user_alive(g_TargetPlayer))
             {
                
zp_core_infect(g_TargetPlayerg_TargetPlayer)
                
set_user_health(g_TargetPlayerfloatround(get_user_health(g_TargetPlayer) * get_pcvar_float(cvar_zombie_first_hp_multiplier)))            
             }
        }           
    }
    
// Remaining players should be humans (CTs) 
    
new id 
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        
// Not alive 
        
if (!is_user_alive(id)) 
            continue; 
         
        
// This is our first zombie 
        
if (zp_core_is_zombie(id)) 
            continue; 
         
        
// Switch to CT 
        
cs_set_player_team(idCS_TEAM_CT
    } 
     
    if (
get_pcvar_num(cvar_infection_show_hud)) 
    { 
        
// Show First Zombie HUD notice 
        
new name[32
        
get_user_name(g_TargetPlayernamecharsmax(name)) 
        
set_hudmessage(HUD_EVENT_RHUD_EVENT_GHUD_EVENT_BHUD_EVENT_XHUD_EVENT_Y00.05.01.01.0, -1
        
ShowSyncHudMsg(0g_HudSync"%L"LANG_PLAYER"NOTICE_FIRST"name
    } 


// Get Alive Count -returns alive players number- 
GetAliveCountHuman() 

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id)) 
            
iAlive++ 
    } 
     
    return 
iAlive


// Get Alive Count -returns alive players number- 
GetAliveCount() 

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2 && id != g_TargetPlayer3
            
iAlive++ 
    } 
     
    return 
iAlive


// Get Random Alive -returns index of alive player number target_index - 
GetRandomAlive(target_index

    new 
iAliveid 
     
    
for (id 1id <= g_MaxPlayersid++) 
    { 
        if (
is_user_alive(id) && id != g_TargetPlayer && id != g_TargetPlayer2 && id != g_TargetPlayer3
            
iAlive++ 
         
        if (
iAlive == target_index
            return 
id
    } 
     
    return -
1
}  

public 
zp_fw_gamemodes_end() 
{                 
    
g_TargetPlayer 0
    g_TargetPlayer2 
0
    g_TargetPlayer3 
0

you look something wrong? the server had six players when this happened.
PHP Code:
player_index <= g_MaxPlayers 

PHP Code:
player_index g_MaxPlayers 
About your other issue, I'll take a look at the code and see if there any way to solve it.
__________________
Currently offline for study.

Last edited by RateX; 03-09-2015 at 07:38.
RateX is offline
Reply



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 17:31.


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