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

Zombie Plague Multi Mod Random Survivor Problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 07-15-2020 , 06:11   Zombie Plague Multi Mod Random Survivor Problems
Reply With Quote #1

Now I have added mixed survivor to multi infection mode of this ZP 5.0.8. However, I encountered a problem like this. normally under 10 people, survivor is where it should come depending on the chance of percentage. The 80% guarantee comes to any. How do you think we can fix this situation?

PHP Code:

/*================================================================================
    
    ------------------------------------------
    -*- [ZP] Game Mode: Multiple 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 <fakemeta>
#include <hamsandwich>
#include <amx_settings_api>
#include <cs_teams_api>
#include <cs_ham_bots_api>
#include <zp50_gamemodes>
#include <zp50_deathmatch>
#include <zp50_class_survivor>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Default sounds
new const sound_multi[][] = { "ambience/the_horror2.wav" }

#define SOUND_MAX_LENGTH 64

new Array:g_sound_multi

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

new g_MaxPlayers

new cvar_multi_chancecvar_multi_min_playerscvar_multi_min_zombies
new cvar_multi_ratio
new cvar_multi_allow_respawncvar_respawn_after_last_human
new cvar_multi_ratio_surv

public plugin_precache()
{
    
// Register game mode at precache (plugin gets paused after this)
    
register_plugin("[ZP] Game Mode: Multiple Infection"ZP_VERSION_STRING"ZP Dev Team")
    
zp_gamemodes_register("Multiple Infection Mode")
    
    
g_MaxPlayers get_maxplayers()
    
    
cvar_multi_chance register_cvar("zp_multi_chance""20")
    
cvar_multi_min_players register_cvar("zp_multi_min_players""0")
    
cvar_multi_min_zombies register_cvar("zp_multi_min_zombies""2")
    
cvar_multi_ratio register_cvar("zp_multi_ratio""0.15")
    
cvar_multi_ratio_surv register_cvar("zp_multi_ratio_survivor""0.1")
    
cvar_multi_allow_respawn register_cvar("zp_multi_allow_respawn""1")
    
cvar_respawn_after_last_human register_cvar("zp_respawn_after_last_human""1")
    
    
// Initialize arrays
    
g_sound_multi ArrayCreate(SOUND_MAX_LENGTH1)
    
    
// Load from external file
    
amx_load_setting_string_arr(ZP_SETTINGS_FILE"Sounds""ROUND MULTI"g_sound_multi)
    
    
// If we couldn't load custom sounds from file, use and save default ones
    
new index
    
if (ArraySize(g_sound_multi) == 0)
    {
        for (
index 0index sizeof sound_multiindex++)
            
ArrayPushString(g_sound_multisound_multi[index])
        
        
// Save to external file
        
amx_save_setting_string_arr(ZP_SETTINGS_FILE"Sounds""ROUND MULTI"g_sound_multi)
    }
    
    
// Precache sounds
    
new sound[SOUND_MAX_LENGTH]
    for (
index 0index ArraySize(g_sound_multi); index++)
    {
        
ArrayGetString(g_sound_multiindexsoundcharsmax(sound))
        if (
equal(sound[strlen(sound)-4], ".mp3"))
        {
            
format(soundcharsmax(sound), "sound/%s"sound)
            
precache_generic(sound)
        }
        else
            
precache_sound(sound)
    }
}

// Deathmatch module's player respawn forward
public zp_fw_deathmatch_respawn_pre(id)
{
    
// Respawning allowed?
    
if (!get_pcvar_num(cvar_multi_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)
{
    new 
alive_count GetAliveCount()
    
    
// Calculate zombie count with current ratio setting
    
new zombie_count floatround(alive_count get_pcvar_float(cvar_multi_ratio), floatround_ceil)
    new 
survivor_count floatround(alive_count get_pcvar_float(cvar_multi_ratio_surv), floatround_ceil)
    if (!
skipchecks)
    {
        new 
id
        
if(zp_class_survivor_get(id))
        {
            if (
alive_count 10)
            {
                if (
random_num(180) != 43)
                    return 
PLUGIN_HANDLED;
            }
            
//return PLUGIN_HANDLED;
            /*if (alive_count < 6)
            {
                if (random_num(1, 120) != 43)
                    return PLUGIN_HANDLED;
            }*/
            // Min zombies
            
if (survivor_count 5)
                return 
PLUGIN_HANDLED;
        }
        else {
        
// Random chance
            
if (random_num(1get_pcvar_num(cvar_multi_chance)) != 1)
                return 
PLUGIN_HANDLED;
            
            
// Min players
            
if (alive_count get_pcvar_num(cvar_multi_min_players))
                return 
PLUGIN_HANDLED;
            
            
// Min zombies
            
if (zombie_count get_pcvar_num(cvar_multi_min_zombies))
                return 
PLUGIN_HANDLED;
        }
    }
    
    
// Zombie count should be smaller than alive players count, so that there's humans left in the round
    
if (zombie_count >= alive_count)
        return 
PLUGIN_HANDLED;
    if (
survivor_count >= alive_count)
        return 
PLUGIN_HANDLED;
        
    
// Game mode allowed
    
return PLUGIN_CONTINUE;
}

public 
zp_fw_gamemodes_start()
{
    
// Allow infection for this game mode
    
zp_gamemodes_set_allow_infect()
    
    
// iMaxZombies is rounded up, in case there aren't enough players
    
new iZombiesidalive_count GetAliveCount()
    new 
iSurvivors
    
new iMaxZombies floatround(alive_count get_pcvar_float(cvar_multi_ratio), floatround_ceil)
    new 
iMaxSurvivors floatround(alive_count get_pcvar_float(cvar_multi_ratio_surv), floatround_ceil)
    
    
// Randomly turn iMaxZombies players into zombies
    
while (iSurvivors iMaxSurvivors)
    {
        
// Choose random guy
        
id GetRandomAlive(random_num(1alive_count))
        
        
// Dead or already a zombie
        
if (zp_class_survivor_get(id))
            continue;
        
        
// Turn into a zombie
        
zp_class_survivor_set(id)
        
iSurvivors++
    }
    while (
iZombies iMaxZombies)
    {
        
// Choose random guy
        
id GetRandomAlive(random_num(1alive_count))
        
        
// Dead or already a zombie
        
if (!is_user_alive(id) || zp_core_is_zombie(id))
            continue;
        
        
// Turn into a zombie
        
zp_core_infect(id0)
        
iZombies++
    }
    
    
    
// Turn the remaining players into humans
    
for (id 1id <= g_MaxPlayersid++)
    {
        
// Only those of them who aren't zombies
        
if (!is_user_alive(id) || zp_core_is_zombie(id))
            continue;
        
        
// Switch to CT
        
cs_set_player_team(idCS_TEAM_CT)
    }
    
    
// Play multi infection sound
    
    
new sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_multirandom_num(0ArraySize(g_sound_multi) - 1), soundcharsmax(sound))
    
PlaySoundToClients(sound)

}

// Plays a sound on clients
PlaySoundToClients(const sound[])
{
    if (
equal(sound[strlen(sound)-4], ".mp3"))
        
client_cmd(0"mp3 play ^"sound/%s^""sound)
    else
        
client_cmd(0"spk ^"%s^""sound)
}

// 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;

__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 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 09:28.


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