AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Having a problem with my CD menu. (https://forums.alliedmods.net/showthread.php?t=183645)

Napoleon_be 04-24-2012 12:27

Having a problem with my CD menu.
 
It's not showing the hudmessages

PHP Code:

#define TASKID  1996
new iCountDown 

PHP Code:

case 2set_task(1.0"Cmd_StartCountDown"TASKID__"a"iCountDown

PHP Code:

case 0iCountDown 5
            
case 1iCountDown 10
            
case 2iCountDown 15
            
case 3iCountDown 30 

PHP Code:

if(task_exists(TASKID)) {
        return 
PLUGIN_HANDLED
    
}
    if(
iCountDown <= 0) {
        
set_hudmessage(02550, -1.00.5025.08.00.00.010)
        
show_hudmessage(0"Go Go Go!"
    }
    
    else {
        
set_hudmessage1201201200.500.5000.10.80.10.1, -)
        
show_hudmessage(0"%i"iCountDown--)
    } 


Exolent[jNr] 04-24-2012 12:45

Re: Having a problem with my CD menu.
 
Those snippets make no sense alone. Show your full code.

Napoleon_be 04-24-2012 13:17

Re: Having a problem with my CD menu.
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>
#include <colorchat>
#include <dhudmessage>

#define PLUGIN "CountDown Menu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

#define TASKID  1996

new iCountDown

new pPlugin

new iMenuItems[3][33] = {
    
"CountDown Seconds",
    
"Freeze Terrorists",
    
"Start CountDown"
}

new 
iCountDownSeconds[4][33] = {
    
"5",
    
"10",
    
"15",
    
"30"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /cd""Cmd_CountDown")
    
    
pPlugin register_cvar("cd_enable""1")
}

public 
Cmd_CountDown(iPlayer) {
    if(!
get_pcvar_num(pPlugin))
        return 
PLUGIN_HANDLED
        
    
if(cs_get_user_team(iPlayer) == CS_TEAM_CT) {
        new 
menu menu_create("\r[ \y Advanced \r] \yCountDown Menu:""CountDown_handler")
        
        new 
szTemp[200], Key[10]
        for(new 
0sizeof(iMenuItems); i++) {
            
formatex(szTempcharsmax(szTemp), "%s"iMenuItems[i])
            
num_to_str(iKeycharsmax(Key))
            
menu_additem(menuszTempKey)
        }
        
menu_display(iPlayermenu)
    }
    else if(
cs_get_user_team(iPlayer) != CS_TEAM_CT) {
        
ColorChat(iPlayerGREEN"[CountDown]^x01 You need to be a^x03 CT^x01 to do this!")
    }
    return 
PLUGIN_CONTINUE
}

public 
CountDown_handler(iPlayermenuitem) {
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    if(
is_user_alive(iPlayer)) {
        switch(
item) {
            case 
0Cmd_CountDownSub(iPlayer)
            case 
1Cmd_FreezePlayers(iPlayer)
            case 
2set_task(1.0"Cmd_StartCountDown"TASKID__"a"iCountDown)
        }
    }
    else {
        
ColorChat(iPlayerGREEN"[CountDown]^x01 You need to be alive to do this!")
    }
    return 
PLUGIN_CONTINUE
}

public 
Cmd_CountDownSub(iPlayer) {
    
    new 
menu menu_create("CountDown Seconds""CountDownSeconds_handler")
    new 
szTemp[200], Key[10]
    
    for(new 
0sizeof(iCountDownSeconds); i++) {
        
formatex(szTempcharsmax(szTemp), "%s"iCountDownSeconds[i])
        
num_to_str(iKeycharsmax(Key))
        
menu_additem(menuszTempKey)
    }
    
menu_display(iPlayermenu)
}

public 
CountDownSeconds_handler(iPlayermenuitem) {
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        
Cmd_CountDown(iPlayer)
        return 
PLUGIN_HANDLED
    
}
    
    if(
is_user_alive(iPlayer)) {
        switch(
item) {
            case 
0iCountDown 5
            
case 1iCountDown 10
            
case 2iCountDown 15
            
case 3iCountDown 30
        
}
    }
    
    
Cmd_CountDown(iPlayer)
    
    return 
PLUGIN_CONTINUE
}
// Not done "Cmd_FreezePlayers"
public Cmd_FreezePlayers(iPlayer) {
    
}

public 
Cmd_StartCountDown(iPlayer) {
    if(
task_exists(TASKID)) {
        return 
PLUGIN_HANDLED
    
}
    if(
iCountDown <= 0) {
        
set_hudmessage(02550, -1.00.5025.08.00.00.010)
        
show_hudmessage(0"Go Go Go!"
    }
    
    else {
        
set_hudmessage1201201200.500.5000.10.80.10.1, -)
        
show_hudmessage(0"%i"iCountDown--)
    }
    return 
PLUGIN_CONTINUE
        



Bilal Pro 04-24-2012 13:44

Re: Having a problem with my CD menu.
 
Channel -1?
Btw,
PHP Code:

#include <dhudmessage> 

You aint even using dhudmessage so why did u include that ?:O

<VeCo> 04-24-2012 14:08

Re: Having a problem with my CD menu.
 
I think the problem is here:

if(task_exists(TASKID)) {
return PLUGIN_HANDLED
}

Because you are checking if the task exist in it's own function and stop it.

Exolent[jNr] 04-24-2012 14:30

Re: Having a problem with my CD menu.
 
Quote:

Originally Posted by <VeCo> (Post 1695750)
I think the problem is here:

if(task_exists(TASKID)) {
return PLUGIN_HANDLED
}

Because you are checking if the task exist in it's own function and stop it.

Yep. That's why.

Napoleon_be 04-24-2012 15:43

Re: Having a problem with my CD menu.
 
Will try it and edit my post if it works.


All times are GMT -4. The time now is 07:54.

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