AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   The plugin doesnt show the hud msg (https://forums.alliedmods.net/showthread.php?t=159892)

GarbageBox 06-23-2011 05:41

The plugin doesnt show the hud msg
 
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
}


fysiks 06-23-2011 05:51

Re: The plugin doesnt show the hud msg
 
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.

GarbageBox 06-23-2011 07:58

Re: The plugin doesnt show the hud msg
 
1 Attachment(s)
After I add
Code:

set_task(1.0, "client_PreThink", TASKID, _, _, "b")
The console shows me a lots of errors and cause me lag.

Hunter-Digital 06-23-2011 08:10

Re: The plugin doesnt show the hud msg
 
Rename "client_PreThink" to something else, because prethink is called TOO frequent for your needs.

GarbageBox 06-23-2011 08:46

Re: The plugin doesnt show the hud msg
 
If I rename it, it wont show hud msg again.

Hunter-Digital 06-23-2011 09:10

Re: The plugin doesnt show the hud msg
 
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.


All times are GMT -4. The time now is 23:32.

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