Raised This Month: $318 Target: $400
 79%   Almost there!

help register_event


Post New Thread Reply   
 
Thread Tools Display Modes
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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 09-19-2020 , 18:29   Re: help register_event
Reply With Quote #2

Quote:
Originally Posted by 1M1e View Post
reset the plugin
What does this mean?
__________________
Black Rose is offline
1M1e
Member
Join Date: Mar 2020
Old 09-19-2020 , 19:33   Re: help register_event
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
What does this mean?
sorry i meant restart
1M1e is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-19-2020 , 18:43   Re: help register_event
Reply With Quote #4

1. You can use bool:"Player Var"[32] for make this plugin working one time per round.
2. Try to cansel the codes before "RoundStartTime" come, something like:

Code:
register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0") public ev_RoundStart() {     if(!RoundStartTime)     {         remove_task(g_counter)                 new iPlayers[32]         new iNum                 get_players( iPlayers, iNum )                 for( new i = 0; i < iNum; i++ )         {             g_iRespawn[iPlayers[i]] = false         }     } }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 09-19-2020 at 18:44.
Supremache is offline
1M1e
Member
Join Date: Mar 2020
Old 09-19-2020 , 19:43   Re: help register_event
Reply With Quote #5

Quote:
Originally Posted by Supremache View Post
1. You can use bool:"Player Var"[32] for make this plugin working one time per round.
2. Try to cansel the codes before "RoundStartTime" come, something like:

Code:
register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0") public ev_RoundStart() {     if(!RoundStartTime)     {         remove_task(g_counter)                 new iPlayers[32]         new iNum                 get_players( iPlayers, iNum )                 for( new i = 0; i < iNum; i++ )         {             g_iRespawn[iPlayers[i]] = false         }     } }
sill dose not work the hudmessage still show
i want when the round end and start new round the hudmessage will remove

Code:
	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))
1M1e is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-19-2020 , 19:49   Re: help register_event
Reply With Quote #6

Quote:
Originally Posted by 1M1e View Post
sill dose not work the hudmessage still show
i want when the round end and start new round the hudmessage will remove

Code:
	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))
It will never be removed because in this plugin use the permanent hud, edit it from ShowSyncHudMsg to show_hudmessage

From:
Code:
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))

To:

Code:
set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)     show_hudmessage( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
1M1e
Member
Join Date: Mar 2020
Old 09-19-2020 , 19:54   Re: help register_event
Reply With Quote #7

can't compile

Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 128
Warning: Loose indentation on line 129
Error: Argument type mismatch (argument 2) on line 129
Warning: Loose indentation on line 131
Warning: Symbol is assigned a value that is never used: "g_SyncRestartTimer" on line 160

1 Error.
Could not locate output file D:\Counter Strike Server\cstrike\addons\amxmodx\plugins\respawn.dr.amx (compile failed).
1M1e is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-19-2020 , 20:00   Re: help register_event
Reply With Quote #8

Quote:
Originally Posted by 1M1e View Post
can't compile

Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 128
Warning: Loose indentation on line 129
Error: Argument type mismatch (argument 2) on line 129
Warning: Loose indentation on line 131
Warning: Symbol is assigned a value that is never used: "g_SyncRestartTimer" on line 160

1 Error.
Could not locate output file D:\Counter Strike Server\cstrike\addons\amxmodx\plugins\respawn.dr.amx (compile failed).
Oops, Small wrong:
PHP Code:
set_hudmessage255000.090.010.01.00.00.0, -1)
    
show_hudmessage0"%d Sec Remaining To Disable The Respawn Mod"floatround(fSec)) 
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-25-2020 , 16:27   Re: help register_event
Reply With Quote #9

I made this plugin yesterday, for coutdown timer, follow steps and you will know how to do that !!
P.s: Use "show_hudmessage" not "SyncObj hud"

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Countdown" #define VERSION "1.0" #define AUTHOR "Supremache" new PrecacheSoundList[10][] = {     "fvox/one.wav", "fvox/two.wav", "fvox/three.wav", "fvox/four.wav", "fvox/five.wav",     "fvox/six.wav", "fvox/seven.wav", "fvox/eight.wav", "fvox/nine.wav", "fvox/ten.wav" }; new iCountdown new iTime public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0") } public plugin_precache() {     for(new i = 0; i <= charsmax(PrecacheSoundList); i++)     {         precache_sound( PrecacheSoundList[i] )     } } public EventRoundStart() {     set_task(4.0, "ZombieCountdown")     iTime = 10     iCountdown = 10 } public ZombieCountdown() {     iCountdown--         emit_sound( 0, CHAN_VOICE, PrecacheSoundList[ iCountdown ], 1.0, ATTN_NORM, 0, PITCH_NORM )         set_hudmessage(179, 0, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);     show_hudmessage(0, "Infection in %i", iTime);                 --iTime;         if(iTime >= 1)     {         set_task(1.0, "ZombieCountdown")     } }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-25-2020 , 17:45   Re: help register_event
Reply With Quote #10

Quote:
Originally Posted by Supremache View Post
I made this plugin yesterday, for coutdown timer, follow steps and you will know how to do that !!
P.s: Use "show_hudmessage" not "SyncObj hud"
There are a few issues in your code
Spoiler
__________________
Bugsy is online now
Reply


Thread Tools
Display Modes

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 20:11.


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