Raised This Month: $ Target: $400
 0% 

The plugin doesnt show the hud msg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 06-23-2011 , 05:41   The plugin doesnt show the hud msg
Reply With Quote #1

Code:
#include <amxmodx>

#define PLUGIN "Nextmap Countdown"
#define VERSION "1.0"
#define AUTHOR "u"

new hudsync, g_nextMap[32]

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_cvar("amx_countdown", "30")
	hudsync = CreateHudSyncObj()
}

getNextMapName(szArg[], iMax)
{
	new len = get_cvar_string("amx_nextmap", szArg, iMax)
	
	if (is_map_valid(szArg)) return len
	len = copy(szArg, iMax, g_nextMap)
	set_cvar_string("amx_nextmap", g_nextMap)
	
	return len
}


public client_PreThink(id)
{
	if(!is_user_connected(id))
		return PLUGIN_CONTINUE
		
	if(!get_cvar_float("mp_timelimit"))
		return PLUGIN_CONTINUE
		
	new timeleft = (get_timeleft() + 1)
	if(timeleft <= get_cvar_num("amx_countdown"))
	{
		new name[32]
		getNextMapName(name, 31)
		new mapname[32]
		get_mapname(mapname, 31)
		set_hudmessage(50, 255, 50, 0.05, 0.50, 0, 0.1, 0.1, 0.1, 2.0, -1) 
		ShowSyncHudMsg(0, hudsync, "%s is gonna finish after %d sec, nextmap will be %s.", mapname, timeleft, name)
	}
	return PLUGIN_CONTINUE
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2011 , 05:51   Re: The plugin doesnt show the hud msg
Reply With Quote #2

Have you tried to debug it?

Make sure the HUD message functions are correct by taking it out of prethink (bad place for it anyways) and see if it works but remember to change the hold time so that it won't just disappear.
__________________
fysiks is online now
GarbageBox
Senior Member
Join Date: Feb 2010
Old 06-23-2011 , 07:58   Re: The plugin doesnt show the hud msg
Reply With Quote #3

After I add
Code:
set_task(1.0, "client_PreThink", TASKID, _, _, "b")
The console shows me a lots of errors and cause me lag.
Attached Thumbnails
Click image for larger version

Name:	Image 042.jpg
Views:	134
Size:	57.7 KB
ID:	87868  
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-23-2011 , 08:10   Re: The plugin doesnt show the hud msg
Reply With Quote #4

Rename "client_PreThink" to something else, because prethink is called TOO frequent for your needs.
__________________
Hunter-Digital is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 06-23-2011 , 08:46   Re: The plugin doesnt show the hud msg
Reply With Quote #5

If I rename it, it wont show hud msg again.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-23-2011 , 09:10   Re: The plugin doesnt show the hud msg
Reply With Quote #6

That's what the set_task() is for... add a repeatitive task ("b" flag, you're using it already) at the start of plugin, check your stuff and then send the hud message to everybody.

You also might want to extend the HUD message duration and/or reduce the task delay... a 1.0 for both should be enough for counting down seconds.

That client_PreThink is verry WRONG here, it's called dozen of times per second for each player... and you're sending a message to all players from each player's prethink... imagine how much useless traffic you're adding.
__________________

Last edited by Hunter-Digital; 06-23-2011 at 09:14.
Hunter-Digital is offline
Reply



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 23:32.


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