Raised This Month: $ Target: $400
 0% 

help register_event


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
1M1e
Member
Join Date: Mar 2020
Old 09-19-2020 , 18:06   help register_event
Reply With Quote #1

hi

can some one tell me how to restart the plugin when the new round start?

i tried to add

Code:
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")

public event_round_start()
{
	return PLUGIN_HANDLED
}
but still did not work

can some one help me?

this is all code
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

new g_counter  

new g_SyncRestartTimer
new g_SyncGameStart

new Float:RoundStartTime

new g_Time_Interval;
const MAX_PLAYERS = 32;

new g_iRespawn[MAX_PLAYERS+1], g_TeamInfoCounter[MAX_PLAYERS+1], CsTeams:g_iPlayerTeam[MAX_PLAYERS+1];
new g_pCvarRespawnTime, g_pCvarRespawnDelay, g_pCvarMaxHealth;

public plugin_init()
{
	register_plugin("Dr.Respawn", "1.2", "Vicious Vixen"); 
	RegisterHam(Ham_Killed, "player", "fwdPlayerKilledPost", 1);
	RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawnPost", 1);
	register_event("TeamInfo", "eTeamInfo", "a");
	register_logevent( "LogEventRoundStart", 2, "1=Round_Start" )
	g_pCvarRespawnTime = register_cvar("amx_respawn_tickets", "0");
	g_pCvarRespawnDelay = register_cvar("amx_respawn_delay", "1");
	g_pCvarMaxHealth = register_cvar("amx_max_health", "100");
	g_Time_Interval = register_cvar("amx_max_time", "40");
	set_msg_block( get_user_msgid( "ClCorpse" ), BLOCK_SET );
	
	g_SyncRestartTimer = CreateHudSyncObj()
	g_SyncGameStart = CreateHudSyncObj()
	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	
}

public LogEventRoundStart()
{
	RoundStartTime = get_gametime()
	
	new iPlayers[32]
	new iNum
	
	get_players( iPlayers, iNum )
	
	for( new i = 0; i < iNum; i++ )
	{
		g_iRespawn[iPlayers[i]] = true
	}
	set_task(1.0,"TimeCounter",123456,_,_,"a",get_pcvar_num(g_Time_Interval))
	set_task(get_pcvar_float(g_Time_Interval),"Runda_Terminata",789123)
}

public Runda_Terminata()
{
	if(RoundStartTime)
	{
		set_hudmessage( 255, 0, 0, 0.09, 0.00, 1, 0.5, 1.0, 0.5, 15.0, -1)
		ShowSyncHudMsg( 0, g_SyncGameStart, "Respawn mode is disabled!")
	}
}

public fwdPlayerKilledPost(iVictim, iKiller, iShoudlGib)
{
	if(g_iRespawn[iVictim]++ < get_pcvar_num(g_pCvarRespawnTime) || get_pcvar_num(g_pCvarRespawnTime) == 0)
	{
		set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer", iVictim);
	}
	return HAM_IGNORED;
}

public fwdPlayerSpawnPost(iClient)
{
	if(is_user_alive(iClient))
	{
		set_pev(iClient, pev_health, get_pcvar_float(g_pCvarMaxHealth));
	}
}

public taskRespawnPlayer(id)
{
	if(is_user_connected(id) && RoundStartTime + get_pcvar_num(g_Time_Interval) >= get_gametime() && g_iRespawn[id] && !is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
		ExecuteHamB(Ham_CS_RoundRespawn, id)
		g_iRespawn[id] = false
		return PLUGIN_HANDLED;
	}
	return PLUGIN_HANDLED;
}  

public eTeamInfo() 
{ 
	new iClient = read_data(1);
	new szTeam[2];
	read_data(2, szTeam, charsmax(szTeam));
	switch(szTeam[0])
	{
		case 'T': 
		{
			remove_task(iClient);
			g_iPlayerTeam[iClient] = CS_TEAM_T;
		}
		case 'C': 
		{
			if(g_TeamInfoCounter[iClient] == 2 || g_iPlayerTeam[iClient] == CS_TEAM_SPECTATOR)
			{
				set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer",  iClient);
			}
			g_iPlayerTeam[iClient] = CS_TEAM_CT;
		}
		case 'S':
		{
			remove_task(iClient);
			g_iPlayerTeam[iClient] = CS_TEAM_SPECTATOR;
		}
	}
}

public TimeCounter() 
{
	g_counter++
	
	new Float:iRestartTime = get_pcvar_float(g_Time_Interval) - g_counter
	new Float:fSec
	fSec = iRestartTime 
	
	set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)
	ShowSyncHudMsg( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))
	
	if(get_pcvar_num(g_Time_Interval) - g_counter < 11 && get_pcvar_num(g_Time_Interval) - g_counter !=0)
	{
		static szNum[32]
		num_to_word(get_pcvar_num(g_Time_Interval) - g_counter, szNum, 31)
	}
	if(g_counter == get_pcvar_num(g_Time_Interval))
	{
		g_counter = 0
	}
	
}

public event_round_start()
{
	return PLUGIN_HANDLED
}

Last edited by 1M1e; 09-19-2020 at 19:32.
1M1e 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 13:46.


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