AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Timer bugged. (https://forums.alliedmods.net/showthread.php?t=185180)

Bilal Pro 05-13-2012 16:47

Timer bugged.
 
Hello there,

My timer is bugged, possibly because im using a loop that when the timer hits 0 that everyone opens the menu. Now for example 2 players are connected to my server its going from 15 to 13 to 11 so on but when im alone its going 15 14 13 so on. heres my little code

PHP Code:

public KickMenu3(id)
{    
    
// timer
    
Timer 15
    
    
// sound
    
client_cmd(0"spk misc/bilalvote.wav")
    
    
// menu
    
KickMenu4(id)
    
KickMenu6(id)
    
    return 
PLUGIN_CONTINUE
}

public 
KickMenu4(id)
{
    if(
task_exists(TASKID))
        
remove_task(TASKID)
    
    
set_task(1.0"KickMenu5"TASKID__"a"Timer)
}

public 
KickMenu5(id)
{
    new 
players[32], iNum
    get_players
(playersiNum"ch")
    
    for (new 
i<iNumi++)
    {
        if (
Timer == 0
        {
            
EndVote(players[i])
        }
        else 
        {
            
KickMenu6(players[i])
        }
    }
    return 
PLUGIN_CONTINUE


By the way if im trying to use for example: KickMenu6(id), i will get a server crash. Thats why i used a loop!

mottzi 05-13-2012 16:54

Re: Timer bugged.
 
Are you trying to do a Countdown? Also: your "return PLUGIN_CONTINUE" have no effect.

Bilal Pro 05-13-2012 17:05

Re: Timer bugged.
 
Im trying to make a timer (15 seconds) that repeats the menu.

mottzi 05-13-2012 17:09

Re: Timer bugged.
 
I dont get it. What you you mean by "repeating a menu"?

Bilal Pro 05-13-2012 17:12

Re: Timer bugged.
 
I want to show the timer inside the menu, and therefore i gotta repeat the menu

mottzi 05-13-2012 17:13

Re: Timer bugged.
 
Ah ok got it. Wait some minutes. Ill make you a Example...

mottzi 05-13-2012 17:26

Re: Timer bugged.
 
PHP Code:

new g_Seconds 0
new g_MaxPlayers

new const TASK_TIMER 1337

public plugin_init()
{
    
register_clcmd("say /startMenu""cmdStartTimer")
    
g_MaxPlayers get_maxplayers()
}

public 
cmdStartTimer(id)
{
    
g_Seconds 15
    set_task
(1.0"cmdTimerTick"TASK_TIMER, .flags "a", .repeat g_Seconds)
}

public 
cmdTimerTick(id)
{
    for(
1<= g_MaxPlayersi++)
    {
        if(
is_user_connected(i))
        {
            
cmdMenu(i)
        }
    }

    
g_Seconds--

    if(!
g_Seconds)
    {
        if(
task_exists(TASK_TIMER)) remove_task(TASK_TIMER)
    }
}

public 
cmdMenu(id)
{
    new 
szTitle[50]
    
formatex(szTitlecharsmax(szTitle), "My Timer: %i"g_Seconds)

    new 
menu menu_create(szTitle"menu_handler")

    
menu_additem(menu"\wI'm Selection #1""1"0)
    
menu_additem(menu"\wI'm Selection #2""2"0)

    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
 
    
menu_display(idmenu0)



Bilal Pro 05-13-2012 17:30

Re: Timer bugged.
 
Thanks


All times are GMT -4. The time now is 00:21.

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