AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Zp respawn problem (https://forums.alliedmods.net/showthread.php?t=333900)

zollymaN 08-15-2021 12:01

Zp respawn problem
 
Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item : Zspawn"
#define VERSION "1.4"
#define AUTHOR "Fry!"

new g_item_name[] = { "Zspawn" }
new g_itemid_respawn, g_respawn_cost, g_respawn_time
new g_late_join_respawn_time

new bool:g_canRespawn[33]

new Float:g_gameTime
new bool:g_justConnected[33]


public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        register_cvar("zp_extra_zspawn",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
       
        g_respawn_cost = register_cvar("zp_respawn_cost", "8")
        g_respawn_time = register_cvar("zp_respawn_time", "2.0")
        g_late_join_respawn_time = register_cvar("zp_late_join_respawn_time", "15.0")
       
        register_clcmd("say /zspawn", "buy_respawn")
        register_clcmd("say_team /zspawn", "buy_respawn")
        register_clcmd("say /latejoin", "late_join")
        register_clcmd("say_team /latejoin", "late_join")
       
        register_event("DeathMsg", "Death", "a")
        register_logevent("ev_roundStart", 2, "1=Round_Start")
       
        g_itemid_respawn = zp_register_extra_item(g_item_name, get_pcvar_num(g_respawn_cost), 0)
}

public client_connect(id)
{
        g_canRespawn[id] = false
        g_justConnected[id] = true
}

public client_disconnect(id)
{
        g_canRespawn[id] = false
}

public ev_roundStart()
{
        g_gameTime = get_gametime() // To check how much time has passed since round start.
}

public Death()
{
        new player = read_data( 2 )
       
        if ( g_canRespawn[player] )
                set_task(get_pcvar_float(g_respawn_time), "respawn_player", player)

}

public zp_extra_item_selected(player, itemid)
{
        if (itemid == g_itemid_respawn)
        {
                if ( !is_user_alive(player) && !zp_get_user_zombie(player) && zp_get_user_zombie(player))
                {
                        g_canRespawn[player] = true
                        respawn_player(player)
                        client_print(player, print_chat, "[ZP] You have purchased a respawn ability")
                }
        }
}

public buy_respawn(id)
{
        if ( is_user_alive(id) )
        {
                g_canRespawn[id] = false
                client_print(id, print_chat, "[ZP] Only Dead people can purchase respawn ability", get_pcvar_num(g_respawn_cost))
               
                return PLUGIN_HANDLED
        }
       
        if ( g_canRespawn[id] )
        {
                zp_set_user_ammo_packs( id, zp_get_user_ammo_packs(id) + get_pcvar_num(g_respawn_cost) )
                client_print(id, print_chat, "[ZP] You already have a respawn ability")
                return PLUGIN_CONTINUE
        }

        new money = zp_get_user_ammo_packs(id)
       
        if ( money < get_pcvar_num(g_respawn_cost))
        {
                client_print(id, print_chat, "[ZP] You don't have enough ammo packs to buy this ability", get_pcvar_num(g_respawn_cost))
                return PLUGIN_HANDLED
        }
               
        zp_set_user_ammo_packs(id, money - get_pcvar_num(g_respawn_cost))
                       
        g_canRespawn[id] = true
        respawn_player(id)
        client_print(id, print_chat, "[ZP] You have purchased a respawn ability")
               
        return PLUGIN_CONTINUE
}

public late_join(id)
{
        if ( is_user_alive(id) )
        {
                client_print(id, print_chat, "[ZP] Only dead and Late Joined players can respawn")
                return PLUGIN_HANDLED
        }

        if ( g_justConnected[id] )
        {
                set_task( get_pcvar_float(g_late_join_respawn_time), "joinedTeam", id )
                g_justConnected[id] = false
                client_print(id, print_chat, "[ZP] You will respawn after %d seconds", get_pcvar_num(g_late_join_respawn_time) )
        }

        return PLUGIN_CONTINUE
}

public joinedTeam(id)
{       
        new Float:gmtm = get_gametime()
       
        // Check if the player is too late to join.
        if ( gmtm - g_gameTime >= get_pcvar_float(g_late_join_respawn_time) && get_user_team( id ) != 3 )
        {
                ExecuteHamB(Ham_CS_RoundRespawn, id)
                client_print(id, print_chat, "[ZP] You have just been respawned due to late join.")
        }
   
        return PLUGIN_CONTINUE
}

public respawn_player(id)
{
        ExecuteHamB(Ham_CS_RoundRespawn, id);
        g_canRespawn[id] = false
}

I would like that in special modes

nemesis
assassin
survivor
sniper
armageddon etc...

and all not to work respawn, only for normal infection

Natsheh 08-15-2021 12:27

Re: Zp respawn problem
 
This is scripting help, we help you to fix the issue we don't do the work for you...

so please post what are you not understanding to achieve?

zollymaN 08-15-2021 14:03

Re: Zp respawn problem
 
in this case you have nothing to do, it works but I tried to do it myself so that the respawn doesn't work in ways and still it works anyway

Natsheh 08-15-2021 14:19

Re: Zp respawn problem
 
check if the gamemode is not infection mode and do a return...


All times are GMT -4. The time now is 02:35.

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