Raised This Month: $ Target: $400
 0% 

Timer bugged.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-13-2012 , 16:47   Timer bugged.
Reply With Quote #1

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!
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-13-2012 , 16:54   Re: Timer bugged.
Reply With Quote #2

Are you trying to do a Countdown? Also: your "return PLUGIN_CONTINUE" have no effect.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 05-13-2012 at 16:54.
mottzi is offline
Send a message via MSN to mottzi
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-13-2012 , 17:05   Re: Timer bugged.
Reply With Quote #3

Im trying to make a timer (15 seconds) that repeats the menu.
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-13-2012 , 17:09   Re: Timer bugged.
Reply With Quote #4

I dont get it. What you you mean by "repeating a menu"?
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-13-2012 , 17:12   Re: Timer bugged.
Reply With Quote #5

I want to show the timer inside the menu, and therefore i gotta repeat the menu
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-13-2012 , 17:13   Re: Timer bugged.
Reply With Quote #6

Ah ok got it. Wait some minutes. Ill make you a Example...
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-13-2012 , 17:26   Re: Timer bugged.
Reply With Quote #7

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)

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 05-13-2012 at 17:26.
mottzi is offline
Send a message via MSN to mottzi
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-13-2012 , 17:30   Re: Timer bugged.
Reply With Quote #8

Thanks
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro 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 00:21.


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