AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Timeleft in hostname (https://forums.alliedmods.net/showthread.php?t=60392)

vl@d 09-02-2007 15:00

Timeleft in hostname
 
Code:

#include <amxmodx>
#include <string>

static const NumeSRV[] = "Cs 1.6 Hl.DarkStriKe.Ro"

public plugin_init(){
    register_plugin("LiveUpdate","1.0","FireW@ll")
    set_task(0.0, "live",_,_,_,"b")
    return PLUGIN_CONTINUE
}

public live(){
    new map[32]
    new numenou[255]
    new formated[32]
    new timeleft = get_timeleft()
    get_mapname(map,31)
    format(formated,254,map[3])
    strtoupper(formated)
    format(numenou,254,"[%s]-=-[Acum Este:%s]-=-[Timp Ramas:%d:%02d]", NumeSRV, formated,timeleft / 60,timeleft * 60)
    set_cvar_string("hostname", numenou)
    return PLUGIN_CONTINUE
}

It works but the timeleft is like this:
[Cs 1.6 Hl.DarkStriKe.Ro]-=-[Acum Este:DUST2]-=-[Timp Ramas:38:136980]

Any idea?

X-Script 09-02-2007 15:19

Re: Timeleft in hostname
 
you need to have %d in there.

edit: Alka got it first.

vl@d 09-02-2007 15:21

Re: Timeleft in hostname
 
ok and what about the timeleft?

Alka 09-02-2007 15:22

Re: Timeleft in hostname
 
Oh sorry, now i get it what you want to do :D, this is the correct way :

Code:

public live()
{
 new const server_name[] = "nume server";
 
 new mapname[32];
 get_mapname(mapname, sizeof mapname - 1);
 
 new time_left = get_timeleft();
 
 new Buffer[256];
 format(Buffer, sizeof Buffer - 1, "[%s]-=-[Harta: %s]-=-[Timp Ramas: %d:%d]", server_name, mapname, time_left / 60, time_left % 60);
 
 set_cvar_string("hostname", Buffer);
}


X-Script 09-02-2007 15:23

Re: Timeleft in hostname
 
take out %02d

edit: damnit alka :)

vl@d 09-02-2007 16:03

Re: Timeleft in hostname
 
nice. :)
very competitiv :P
thx alka for that one :P

edit: omg is this right :|
[Cs 1.6 Hl.DarkStriKe.Ro]-=-[Acum Este:80]-=-[Timp Ramas:41:149460]
the map is 35hp :|
Edit: nevermind i rr the server it works. thx :P


All times are GMT -4. The time now is 16:06.

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