Raised This Month: $ Target: $400
 0% 

Zp respawn problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
zollymaN
Junior Member
Join Date: Aug 2021
Location: Romania
Old 08-15-2021 , 12:01   Zp respawn problem
Reply With Quote #1

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

Last edited by zollymaN; 08-15-2021 at 12:02.
zollymaN is offline
 



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 02:35.


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