Raised This Month: $51 Target: $400
 12% 

Refresh MenuTitle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-09-2013 , 03:21   Refresh MenuTitle
Reply With Quote #1

Hello,

i wanna display the current value of a running timer in the title of a menu.
but i dont know how i can refresh the menu without closing it

my first idea was to set a global handle and redraw the menu somehow in the timer..

thx 4 help

Last edited by abckrieger; 08-09-2013 at 03:24.
abckrieger is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 08-09-2013 , 09:53   Re: Refresh MenuTitle
Reply With Quote #2

It seems you cannot re-set a title once it's been set and displayed, so this is the best I can come up with:

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegAdminCmd("sm_menutimer"OnMenuTimerADMFLAG_ROOT);
}

public 
Action:OnMenuTimer(clientargs)
{
    if (
client == 0)
    {
        return 
Plugin_Handled;
    }

    
ShowMenu(client20);
    
    return 
Plugin_Handled;
}

ShowMenu(const client, const duration)
{
    new 
Handle:menu CreateMenu(MenuCallback);
    
SetMenuTitle(menu"Time left: %d"duration);
    
AddMenuItem(menu"0""Some Value");
    
DisplayMenu(menuclientduration);
    
    new 
Handle:pack;
    
CreateDataTimer(1.0MenuUpdatepack);
    
WritePackCell(packGetClientUserId(client));
    
WritePackCell(packduration 1);
}

public 
MenuCallback(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        
//Stuff
    
}
    else if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}

public 
Action:MenuUpdate(Handle:timerHandle:pack)
{
    
ResetPack(pack);
    new 
client GetClientOfUserId(ReadPackCell(pack));
    new 
duration ReadPackCell(pack);
    
    if (
client && duration >= 1)
    {
        
ShowMenu(clientduration);
    }

__________________

Last edited by 11530; 08-09-2013 at 10:13.
11530 is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-09-2013 , 10:49   Re: Refresh MenuTitle
Reply With Quote #3

working perfectly, thx :-)

Last edited by abckrieger; 08-09-2013 at 13:57.
abckrieger 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 21:58.


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