AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn in game mode (https://forums.alliedmods.net/showthread.php?t=338726)

JUSTINR 07-23-2022 10:31

Respawn in game mode
 
How can i add respawn in this mode SNIPER VS NEMESIS ?
Code:

#include < amxmodx >

#include < fun >

#include < zombie_plague_advance >



new const g_chance = 120

new const g_access_flag[] = "a"



new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemhp, g_msg_sync



public plugin_init( )

{

        register_plugin( "[ZP] Snipers VS Nemesis Mode","1.0", "zmd94" )

       

        cvar_minplayers = register_cvar("zp_minplayers", "2")

        cvar_sniperhp =          register_cvar("zp_sniper_hp", "1.5")

        cvar_nemhp =          register_cvar("zp_nem_hp", "1.0")

        cvar_ratio =          register_cvar("zp_svn_inf_ratio", "0.5")

       

        g_maxplayers = get_maxplayers()

        g_msg_sync = CreateHudSyncObj()

}



public plugin_natives()

{

    register_native("zp_is_svn_round", "native_is_svn_round", 1)

}



public plugin_precache( )

{

        new access_flag = read_flags( g_access_flag )

       

        g_gameid = zp_register_game_mode( "Sniper vs Nemesis Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )

}



public zp_player_spawn_post( id )

{

        if( zp_get_current_mode() == g_gameid )

        {

                if( zp_get_user_zombie( id ))

                {

                        zp_make_user_nemesis( id )

                       

                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )

                }

                else

                {

                        zp_make_user_sniper( id )

                       

                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )

                }

        }

}



public zp_round_started_pre( game )

{

        if( game == g_gameid )

        {

                if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )

                {

                        return ZP_PLUGIN_HANDLED

                }

                start_svn_mode( )

        }

        return PLUGIN_CONTINUE

}



public zp_round_started( game, id )

{

        if( game == g_gameid )

        {

                set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)

                ShowSyncHudMsg(0, g_msg_sync, "Snipers vs Nemesis Mode!")

        }

}



public zp_game_mode_selected( gameid, id )

{

        if( gameid == g_gameid )

                start_svn_mode( )



        return PLUGIN_CONTINUE

}



start_svn_mode( )

{

        static i_nemesiss, i_max_nemesiss, id, i_alive

        i_alive = fn_get_alive_players()

        id = 0

       

        i_max_nemesiss = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )

        i_nemesiss = 0

       

        while (i_nemesiss < i_max_nemesiss)

        {

                if ( (++id) > g_maxplayers) id = 1

               

                if ( !is_user_alive(id) )

                        continue;

               

                if (random_num(1, 5) == 1)

                {

                        zp_make_user_nemesis(id)

                       

                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )

                       

                        i_nemesiss++

                }

        }

       

        for (id = 1; id <= g_maxplayers; id++)

        {

                if ( !is_user_alive(id) || zp_get_user_nemesis(id) )

                        continue;

                       

                zp_make_user_sniper(id)

               

                set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )

        }

}



fn_get_alive_players( )

{

        static i_alive, id

        i_alive = 0

       

        for ( id = 1; id <= g_maxplayers; id++ )

        {

                if( is_user_alive( id ) )

                        i_alive++

        }

        return i_alive;

}



public native_is_svn_round()

{

    return zp_get_current_mode() == g_gameid ? true : false

}


JUSTINR 07-25-2022 05:32

Re: Respawn in game mode
 
Someone?

damage220 07-25-2022 06:50

Re: Respawn in game mode
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
/* ... */
    
RegisterHam(Ham_Killed"player""death_event"1);
}

public 
death_event(victimattackershouldgib)
{
    
ExecuteHamB(Ham_CS_RoundRespawnvictim);



JUSTINR 07-26-2022 01:34

Re: Respawn in game mode
 
This respawn in snipers/nemesis in all round?

XSlayer 07-26-2022 02:30

Re: Respawn in game mode
 
Quote:

Originally Posted by JUSTINR (Post 2784864)
This respawn in snipers/nemesis in all round?

PHP Code:

public zp_player_spawn_postid 

i think u already have a public for that, u just need it to register ham spawn with this public name, and the job is done

PHP Code:

RegisterHamHam_Spawn"player""zp_player_spawn_post"); 

try registering the forward ( Spawn for Players )

Also u can check this list of full tutorials, all about zombie plage:
https://forums.alliedmods.net/showth...taFileHandling

JUSTINR 07-26-2022 04:53

Re: Respawn in game mode
 
I edit , but no working ...

Code:

#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >
#include < hamsandwich >

new const g_chance = 120
new const g_access_flag[] = "a"

new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemhp, g_msg_sync

public plugin_init( )
{
        register_plugin( "[ZP] Snipers VS Nemesis Mode","1.0", "zmd94" )
        RegisterHam( Ham_Spawn, "player", "zp_player_spawn_post", 1 );
       
        cvar_minplayers = register_cvar("zp_minplayers", "2")
        cvar_sniperhp =          register_cvar("zp_sniper_hp", "1.5")
        cvar_nemhp =          register_cvar("zp_nem_hp", "0.3")
        cvar_ratio =          register_cvar("zp_svn_inf_ratio", "0.4")
       
        g_maxplayers = get_maxplayers()
        g_msg_sync = CreateHudSyncObj()
}

public plugin_natives()
{
    register_native("zp_is_svn_round", "native_is_svn_round", 1)
}

public plugin_precache( )
{
        new access_flag = read_flags( g_access_flag )
       
        g_gameid = zp_register_game_mode( "Sniper vs Nemesis Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}

public zp_player_spawn_post( id )
{
        if( zp_get_current_mode() == g_gameid )
        {
                if( zp_get_user_zombie( id ))
                {
                        zp_make_user_nemesis( id )
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
                }
                else
                {
                        zp_make_user_sniper( id )
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
                }
        }
}

public zp_round_started_pre( game )
{
        if( game == g_gameid )
        {
                if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
                {
                        return ZP_PLUGIN_HANDLED
                }
                start_svn_mode( )
        }
        return PLUGIN_CONTINUE
}

public zp_round_started( game, id )
{
        if( game == g_gameid )
        {
                set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
                ShowSyncHudMsg(0, g_msg_sync, "Snipers vs Nemesis Mode!")
        }
}

public zp_game_mode_selected( gameid, id )
{
        if( gameid == g_gameid )
                start_svn_mode( )

        return PLUGIN_CONTINUE
}

start_svn_mode( )
{
        static i_nemesiss, i_max_nemesiss, id, i_alive
        i_alive = fn_get_alive_players()
        id = 0
       
        i_max_nemesiss = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
        i_nemesiss = 0
       
        while (i_nemesiss < i_max_nemesiss)
        {
                if ( (++id) > g_maxplayers) id = 1
               
                if ( !is_user_alive(id) )
                        continue;
               
                if (random_num(1, 5) == 1)
                {
                        zp_make_user_nemesis(id)
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
                       
                        i_nemesiss++
                }
        }
       
        for (id = 1; id <= g_maxplayers; id++)
        {
                if ( !is_user_alive(id) || zp_get_user_nemesis(id) )
                        continue;
                       
                zp_make_user_sniper(id)
               
                set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
}

fn_get_alive_players( )
{
        static i_alive, id
        i_alive = 0
       
        for ( id = 1; id <= g_maxplayers; id++ )
        {
                if( is_user_alive( id ) )
                        i_alive++
        }
        return i_alive;
}

public native_is_svn_round()
{
    return zp_get_current_mode() == g_gameid ? true : false
}


damage220 07-26-2022 09:06

Re: Respawn in game mode
 
Quote:

Originally Posted by JUSTINR (Post 2784864)
This respawn in snipers/nemesis in all round?

It respawns on player death. I know nothing about this mode and how it works. Try to paste this code and reply whether it works or not.

JUSTINR 07-26-2022 11:17

Re: Respawn in game mode
 
Quote:

Originally Posted by JUSTINR (Post 2784873)
I edit , but no working ...

Code:

#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >
#include < hamsandwich >

new const g_chance = 120
new const g_access_flag[] = "a"

new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemhp, g_msg_sync

public plugin_init( )
{
        register_plugin( "[ZP] Snipers VS Nemesis Mode","1.0", "zmd94" )
        RegisterHam( Ham_Spawn, "player", "zp_player_spawn_post", 1 );
       
        cvar_minplayers = register_cvar("zp_minplayers", "2")
        cvar_sniperhp =          register_cvar("zp_sniper_hp", "1.5")
        cvar_nemhp =          register_cvar("zp_nem_hp", "0.3")
        cvar_ratio =          register_cvar("zp_svn_inf_ratio", "0.4")
       
        g_maxplayers = get_maxplayers()
        g_msg_sync = CreateHudSyncObj()
}

public plugin_natives()
{
    register_native("zp_is_svn_round", "native_is_svn_round", 1)
}

public plugin_precache( )
{
        new access_flag = read_flags( g_access_flag )
       
        g_gameid = zp_register_game_mode( "Sniper vs Nemesis Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}

public zp_player_spawn_post( id )
{
        if( zp_get_current_mode() == g_gameid )
        {
                if( zp_get_user_zombie( id ))
                {
                        zp_make_user_nemesis( id )
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
                }
                else
                {
                        zp_make_user_sniper( id )
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
                }
        }
}

public zp_round_started_pre( game )
{
        if( game == g_gameid )
        {
                if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
                {
                        return ZP_PLUGIN_HANDLED
                }
                start_svn_mode( )
        }
        return PLUGIN_CONTINUE
}

public zp_round_started( game, id )
{
        if( game == g_gameid )
        {
                set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
                ShowSyncHudMsg(0, g_msg_sync, "Snipers vs Nemesis Mode!")
        }
}

public zp_game_mode_selected( gameid, id )
{
        if( gameid == g_gameid )
                start_svn_mode( )

        return PLUGIN_CONTINUE
}

start_svn_mode( )
{
        static i_nemesiss, i_max_nemesiss, id, i_alive
        i_alive = fn_get_alive_players()
        id = 0
       
        i_max_nemesiss = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
        i_nemesiss = 0
       
        while (i_nemesiss < i_max_nemesiss)
        {
                if ( (++id) > g_maxplayers) id = 1
               
                if ( !is_user_alive(id) )
                        continue;
               
                if (random_num(1, 5) == 1)
                {
                        zp_make_user_nemesis(id)
                       
                        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
                       
                        i_nemesiss++
                }
        }
       
        for (id = 1; id <= g_maxplayers; id++)
        {
                if ( !is_user_alive(id) || zp_get_user_nemesis(id) )
                        continue;
                       
                zp_make_user_sniper(id)
               
                set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
}

fn_get_alive_players( )
{
        static i_alive, id
        i_alive = 0
       
        for ( id = 1; id <= g_maxplayers; id++ )
        {
                if( is_user_alive( id ) )
                        i_alive++
        }
        return i_alive;
}

public native_is_svn_round()
{
    return zp_get_current_mode() == g_gameid ? true : false
}


I edit with this code , but dont working ... I think I have to use native in the base.

wilian159 07-26-2022 11:31

Re: Respawn in game mode
 
test:

PHP Code:

#include <amxmodx>
#include <fun>
#include <zombie_plague_advance>
#include <hamsandwich>

new const g_chance 120
new const g_access_flag[] = "a"

new g_gameidg_maxplayerscvar_minplayerscvar_ratiocvar_sniperhpcvar_nemhpg_msg_sync

public plugin_init( )
{
    
register_plugin"[ZP] Snipers VS Nemesis Mode","1.0""zmd94" 
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled_Post"1)

    
cvar_minplayers register_cvar("zp_minplayers""2")
    
cvar_sniperhp =      register_cvar("zp_sniper_hp""1.5")
    
cvar_nemhp =      register_cvar("zp_nem_hp""0.3")
    
cvar_ratio =       register_cvar("zp_svn_inf_ratio""0.4")
    
    
g_maxplayers get_maxplayers()
    
g_msg_sync CreateHudSyncObj()
}

public 
plugin_natives()
{
    
register_native("zp_is_svn_round""native_is_svn_round"1)
}

public 
plugin_precache( )
{
    new 
access_flag read_flagsg_access_flag )
    
    
g_gameid zp_register_game_mode"Sniper vs Nemesis Mode"access_flagg_chance0ZP_DM_BALANCE )
}

public 
fw_PlayerKilled_Post(victimattackershouldgib)
{
    if(
is_user_connected(victim) && zp_get_current_mode() == g_gameid)
    {
        
set_task(2.0"xReviveUser"victim)
    }
}

public 
xReviveUser(victim)
{
    if(
is_user_connected(victim) && zp_get_current_mode() == g_gameid)
    {
        new 
random_num(01)
        
zp_respawn_user(victimZP_TEAM_SNIPER ZP_TEAM_NEMESIS)
    }
}

public 
zp_round_started_pregame )
{
    if( 
game == g_gameid )
    {
        if( 
fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
        {
            return 
ZP_PLUGIN_HANDLED
        
}
        
start_svn_mode( )
    }
    return 
PLUGIN_CONTINUE
}

public 
zp_round_startedgameid )
{
    if( 
game == g_gameid )
    {
        
set_hudmessage(22115621, -1.00.1710.05.01.01.0, -1)
        
ShowSyncHudMsg(0g_msg_sync"Snipers vs Nemesis Mode!")
    }
}

public 
zp_game_mode_selectedgameidid )
{
    if( 
gameid == g_gameid )
        
start_svn_mode( )

    return 
PLUGIN_CONTINUE
}

start_svn_mode( )
{
    static 
i_nemesissi_max_nemesissidi_alive
    i_alive 
fn_get_alive_players()
    
id 0
    
    i_max_nemesiss 
floatround( ( i_alive get_pcvar_floatcvar_ratio ) ), floatround_ceil )
    
i_nemesiss 0
    
    
while (i_nemesiss i_max_nemesiss)
    {
        if ( (++
id) > g_maxplayersid 1
        
        
if ( !is_user_alive(id) )
            continue;
        
        if (
random_num(15) == 1)
        {
            
zp_make_user_nemesis(id)
            
            
set_user_healthidfloatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
            
            
i_nemesiss++
        }
    }
    
    for (
id 1id <= g_maxplayersid++)
    {
        if ( !
is_user_alive(id) || zp_get_user_nemesis(id) )
            continue;
            
        
zp_make_user_sniper(id)
        
        
set_user_healthidfloatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
    }
}

fn_get_alive_players( )
{
    static 
i_aliveid
    i_alive 
0
    
    
for ( id 1id <= g_maxplayersid++ )
    {
        if( 
is_user_aliveid ) )
            
i_alive++
    }
    return 
i_alive;
}

public 
native_is_svn_round()
{
    return 
zp_get_current_mode() == g_gameid true false



JUSTINR 07-26-2022 15:06

Re: Respawn in game mode
 
Give respawn , but spawn humans / zombies no snipers /nemesis


All times are GMT -4. The time now is 15:34.

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