AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   c4 hud fix (https://forums.alliedmods.net/showthread.php?t=51355)

SAMURAI16 02-16-2007 13:06

c4 hud fix
 
hi, i maked this:
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>

new g_c4timer;
new mp_timec4;
new bool:b_planted = false;


public plugin_init()
{
    register_plugin("Test","0.1","SAMURAI");
    mp_timec4 = get_cvar_num("mp_c4timer")
   
    register_event("RoundTime", "newRound", "bc")
    register_event("SendAudio", "endRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
}


public newRound()
{
    g_c4timer = 0
    b_planted = false;
}

public endRound()
{
    g_c4timer = -2
}

public bomb_planted()
{
    b_planted = true;
    g_c4timer = mp_timec4
    set_task(1.0, "dispTime", 652450, "", 0, "b")
}

public dispTime()
{
   
    if(!b_planted)
    remove_task(652450)
   
   
    if(g_c4timer < 8) set_hudmessage(150, 0, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 7) set_hudmessage(150, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 13) set_hudmessage(0, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)
       
    show_hudmessage(0, "C4: %d",max(--g_c4timer,0))
   
}

But doesen't works correctly
So, for example "mp_c4timer is 35", appear with hudmessage only C4 : 34 ;
Any ideia to fix this ? thanks

Brad 02-16-2007 13:20

Re: c4 hud fix
 
I'd reckon it's because you have --g_c4timer which subtracts 1 from g_c4timer.

SAMURAI16 02-16-2007 13:21

Re: c4 hud fix
 
should be
Code:

show_hudmessage(0, "C4: %d",g_c4timer)
?

P34nut 02-16-2007 13:33

Re: c4 hud fix
 
I think:
Code:

show_hudmessage(0, "C4: %d", g_c4timer)
g_c4timer--


Brad 02-16-2007 13:36

Re: c4 hud fix
 
Quote:

Originally Posted by SAMURAI16 (Post 441163)
should be
Code:

show_hudmessage(0, "C4: %d",g_c4timer)
?

I don't know. You tell me. I really don't know what you're trying to do. I thought I did but then you were subtracting 1 from the variable at which point I gave up trying to understand.

SAMURAI16 02-16-2007 13:41

Re: c4 hud fix
 
with this works,
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>

new g_c4timer;
new mp_timec4;
new bool:b_planted = false;


public plugin_init()
{
    register_plugin("Test","0.1","SAMURAI");
    mp_timec4 = get_cvar_num("mp_c4timer")
   
    register_event("RoundTime", "newRound", "bc")
    register_event("SendAudio", "endRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
}


public newRound()
{
    g_c4timer = 0
    b_planted = false;
}

public endRound()
{
    g_c4timer = -2
}

public bomb_planted()
{
    b_planted = true;
    g_c4timer = mp_timec4
    set_task(1.0, "dispTime", 652450, "", 0, "b")
}

public bomb_explode()
{
    if(b_planted)
    remove_task(652450)
   
    return PLUGIN_CONTINUE;
}
   

public dispTime()
{
   
    if(!b_planted)
    remove_task(652450)
   
   
    if(g_c4timer < 8) set_hudmessage(150, 0, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 7) set_hudmessage(150, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 13) set_hudmessage(0, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)
       
   
    show_hudmessage(0, "C4: %d",g_c4timer)
    g_c4timer--
   
}

- I added bomb_explode forward to stop c4 timer because it's appear after 0, -1,-2,-3 etc ;P
- But, it's changed completely the c4 timer cvar ; It's changed it in "45 seconds" . Why ?

[ --<-@ ] Black Rose 02-16-2007 14:08

Re: c4 hud fix
 
EDIT: I think this will work.
Code:
#include <amxmodx> #include <csx> new g_c4timer; public plugin_init() {     register_plugin("Test", "0.1", "SAMURAI");         register_event("RoundTime", "newRound", "bc")     register_event("SendAudio", "endRound", "a", "1=0") } public bomb_planted() {     g_c4timer = get_cvar_num("mp_c4timer");     set_task(1.0, "dispTime", 652450, "", 0, "a", g_c4timer) } public bomb_explode()     remove_task(652450) public bomb_defused()     remove_task(652450) public dispTime() {     g_c4timer--     show_hudmsg() } show_hudmsg() {     switch ( g_c4timer ) {         case 0..7 : set_hudmessage(150, 0, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)                     case 8..13 : set_hudmessage(150, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)                     default : set_hudmessage(0, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)     }     show_hudmessage(0, "C4: %d", g_c4timer) }

SAMURAI16 02-24-2007 09:37

Re: c4 hud fix
 
i remaked with pcvars, and doesent works
CODE:
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>

new g_c4timer;
new mp_timec4;
new bool:b_planted = false;
new pointnum

new const PLUGIN[] = "Bomb CountHUD Timer"
new const VERSION[] = "0.1"
new const AUTHOR[] = "SAMURAI"

public plugin_init()
{
    register_plugin(PLUGIN,VERSION,AUTHOR);
 
    pointnum = get_cvar_pointer("mp_c4timer");
   
    register_event("RoundTime", "newRound", "bc");
    register_event("SendAudio", "endRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw");
   
   
    mp_timec4 = get_pcvar_num(pointnum);
}


public newRound()
{
    mp_timec4 = get_pcvar_num(pointnum);
   
    g_c4timer = 0
    b_planted = false;
}

public endRound()
{
    mp_timec4 = get_pcvar_num(pointnum);
   
    g_c4timer = -2
}

public bomb_planted()
{
    mp_timec4 = get_pcvar_num(pointnum)
   
    b_planted = true;
    g_c4timer = mp_timec4
    set_task(1.0, "dispTime", 652450, "", 0, "b")
}

public bomb_defused()
{
    mp_timec4 = get_pcvar_num(pointnum)
   
    if(b_planted)
    remove_task(652450);
}

public bomb_explode()
{
    mp_timec4 = get_pcvar_num(pointnum)

    if(b_planted)
    remove_task(652450)
   
}
 
 
public dispTime()
{
    mp_timec4 = get_pcvar_num(pointnum)
   
    if(!b_planted)
    remove_task(652450)
   
    if(g_c4timer < 8) set_hudmessage(150, 0, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 7) set_hudmessage(150, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)

    if(g_c4timer > 13) set_hudmessage(0, 150, 0, -1.0, 0.80, 0, 1.0, 1.0, 0.01, 0.01, -1)
       
   
    show_hudmessage(0, "C4: %d",g_c4timer)
    g_c4timer--
   
}

It's changed the mp_c4timer timer cvar, and i don't understand why
Have anybody an idea to fix it ?


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

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