AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]Help with SyncHud (https://forums.alliedmods.net/showthread.php?t=108059)

#8 SickneSS 11-01-2009 09:18

[SOLVED]Help with SyncHud
 
I have a problem with this, works all right, but in the countdown no,show an static hud,like ( " You Will Respawn in 3 seconds" )but dont show 2 - 1,etc....i dont know which is the problem :s

Here I leave the code ...

PHP Code:

//Global
new respawntimer
new delay

#define TASK_HUD    1437

//Init
respawntimer CreateHudSyncObj()
delay register_cvar("amx_respawn_delay","3.0")

//Task
set_task(1.0,"CmdHud",id+TASK_HUD,_,_,"b")

//Function
public CmdHud(id) { 
        
    
id -= TASK_HUD
    
new respawnsegs[33]
    
respawnsegs[id] = get_pcvar_num(delay)
    
    if(
respawnsegs[id] <= 0) {
        
remove_task(id+TASK_HUD)
        
chat_color(id,"!g%s!y Para deshabilitar tu respawn,tipea!team /respawn!y.",szPrefix)
    }
    
    else {
    
set_hudmessage(255255255, -1.00.7906.01.00.10.2)
    
ShowSyncHudMsg(id,respawntimer,"Respawnearas en %d segundo%s",respawnsegs[id],get_pcvar_num(delay) < "" "s")
    }
    
    
respawnsegs[id]--


Thanks! and sorry 4 my bad english

joropito 11-01-2009 10:38

Re: Help with SyncHud
 
Try this (not tested)

PHP Code:

// Global
new respawntimer[32]
new 
respawnsegs[32]
new 
delay

public plugin_init()
{
    
delay register_cvar("amx_respawn_delay""3.0")
}

//Function to Init timer
public respawnFunc(player)
{
    new 
param[1]
    
param[0] = player
    respawntimer
[player] = CreateHudSyncObj()
    
respawnsegs[player] = get_pcvar_num(delay)
    
set_task(1.0"CmdHud"player TASK_HUDparam_"b")
}

// Function CmdHud
public CmdHud(param[])
{        
    
player param[0]

    if(
respawnsegs[player] <= 0)
    {
        
remove_task(player TASK_HUD)
        
chat_color(player"!g%s!y Para deshabilitar tu respawn,tipea!team /respawn!y."szPrefix)
    }
    else
    {
        
set_hudmessage(255255255, -1.00.7906.01.00.10.2)
        
ShowSyncHudMsg(playerrespawntimer[player], "Respawnearas en %d segundo%s"respawnsegs[id], get_pcvar_num(delay) < "" "s")
    }
    
respawnsegs[id]--


Add your code to call respawnFunc with player id as a parameter.

#8 SickneSS 11-01-2009 10:57

Re: Help with SyncHud
 
Thanks but dont works:/

joropito 11-01-2009 11:07

Re: Help with SyncHud
 
Quote:

Originally Posted by #8 SickneSS (Post 977931)
Thanks but dont works:/

Gives you an error?
What it does?

#8 SickneSS 11-01-2009 11:26

Re: Help with SyncHud
 
Now,make all right,show " You Will Respawn in 3 seconds",and hide the hud after 3 seconds.

but dont make the countdown

like...

" You Will Respawn in 3 seconds"
" You Will Respawn in 2 seconds"
" You Will Respawn in 1 second"

joropito 11-01-2009 12:04

Re: Help with SyncHud
 
Quote:

Originally Posted by #8 SickneSS (Post 977955)
Now,make all right,show " You Will Respawn in 3 seconds",and hide the hud after 3 seconds.

but dont make the countdown

like...

" You Will Respawn in 3 seconds"
" You Will Respawn in 2 seconds"
" You Will Respawn in 1 second"

Change this

PHP Code:

    respawnsegs[id]-- 

to this

PHP Code:

    respawnsegs[player]-- 

And change this

PHP Code:

 ShowSyncHudMsg(playerrespawntimer[player], "Respawnearas en %d segundo%s"respawnsegs[id], get_pcvar_num(delay) < "" "s"

to this

PHP Code:

 ShowSyncHudMsg(playerrespawntimer[player], "Respawnearas en %d segundo%s"respawnsegs[player], respawnsegs[player] < "" "s"


#8 SickneSS 11-01-2009 12:20

Re: Help with SyncHud
 
does the same

Alucard^ 11-01-2009 15:00

Re: Help with SyncHud
 
Try this:

Code:
#include <amxmodx> #define PLUGIN    "New Plugin" #define AUTHOR    "Alucard" #define VERSION    "1.0" #define TASK_HUD    1437 new respawntimer new p_delay new iCountdown public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         respawntimer = CreateHudSyncObj()     p_delay = register_cvar("amx_respawn_delay","3")         iCountdown = get_pcvar_num(p_delay) } //Task set_task(1.0,"CmdHud",id+TASK_HUD) //Function public CmdHud(taskid) {     new id = taskid-TASK_HUD         if(iCountdown > 0)     {         set_hudmessage(255, 255, 255, -1.0, 0.79, 0, 6.0, 1.0, 0.1, 0.2)         ShowSyncHudMsg(id,respawntimer,"Respawnearas en %d segundo%s", iCountdown, iCountdown < 2 ? "" : "s")                 iCountdown--                 set_task(1.0,"CmdHud",id+TASK_HUD)     }     else     {         chat_color(id,"!g%s!y Para deshabilitar tu respawn,tipea!team /respawn!y.",szPrefix)     } }

#8 SickneSS 11-01-2009 16:00

Re: Help with SyncHud
 
does the same

matsi 11-01-2009 17:40

Re: Help with SyncHud
 
Quote:

Originally Posted by #8 SickneSS (Post 978202)
does the same

Here:
Code:
#include <amxmodx> #include <amxmisc> #define task_id    1445 new g_iCounter new g_HudSyncObj new p_delay public plugin_init() {     register_plugin( "respawn", "1.0", "matsi")     register_clcmd( "say /respawn", "cmd_respawn" )         p_delay = register_cvar( "amx_respawn_delay", "3" ) } public plugin_cfg() {     g_HudSyncObj = CreateHudSyncObj() } public cmd_respawn( id ) {     if( task_exists( task_id ) )         remove_task( task_id )         g_iCounter = get_pcvar_num( p_delay )         set_task( 1.0, "start_countdown", task_id, _, _, "b" )         return PLUGIN_HANDLED } public start_countdown( id ) {     if( !g_iCounter ) //time is up     {         remove_task( task_id )         set_hudmessage( 255, 255, 255, -1.0, 0.79, 0, 6.0, 1.0, 0.1, 0.2, -1 )         ShowSyncHudMsg( 0, g_HudSyncObj, "You have been respawned" )         //set player to respawn here         return     }         set_hudmessage( 255, 255, 255, -1.0, 0.79, 0, 6.0, 1.0, 0.1, 0.2, -1 )     ShowSyncHudMsg( 0, g_HudSyncObj, "You will respawn in %i second%s", g_iCounter, g_iCounter < 2 ? "" : "s" )         g_iCounter-- }

I didn't really understand what you were doing but this is what i came up with. :)


All times are GMT -4. The time now is 02:30.

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