←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

[ROZWIĄZANE] Pobieranie czasu rundy

Locked

  • +
  • -
daniosik's Photo daniosik 06.02.2012

Cześć! Chciałbym, aby ktoś mi podał funkcję, która będzie sprawdzać czy czas rundy wynosi 0:00 (lub dowolnie inny czas), jeśli tak to ma coś tam wykonać.

Pozdro

Refresh
Quote

hardbot's Photo hardbot 07.02.2012

proszę gdy czas osiągnie wartość 00:00 wtedy powinno na say wypisać Czas Rundy == 00:00

#include <amxmodx>
#include <engine>
new GetTime;
public plugin_init()
{
register_plugin("RoundTime==00:00", "1", "[H]ARDBO[T]")
GetTime = get_cvar_pointer("mp_roundtime");
}
public client_PreThink()
{
if(get_pcvar_num(GetTime) == 0)
{
client_print(0, print_chat, "Czas Rundy == 00:00");
return false;
}
return true;
}
Quote

  • +
  • -
G[o]Q's Photo G[o]Q 07.02.2012

nie ma to jak 100x na sekunde sprawdzać czy aby czasem nie wybila juz nasza sekunda xD
pozatym mp_roundtime przechowuje chyba czas trwania rundy a nie czas do konca
Quote

  • +
  • -
daniosik's Photo daniosik 07.02.2012

Niestety hard, ale nie działa. :(
Quote

  • +
  • -
FetaGreen's Photo FetaGreen 07.02.2012

by R3X

Half-Life 1 Game Events - AlliedModders Wiki


register_event("RoundTime", "eventRoundTime", "b");

public eventRoundTime(id){

}


Wysyłane jest osobno do każdego raz (a nie co sekundę) i nie masz pewności, że to początek rundy.

Musisz użyć set_task(1.0, ...) z flagą "b", na początku zapisywać w zmiennej globalnej czas, coś takiego (nie testowałem)


#define TASKID 146

new gRoundStart;

public plugin_init(){
register_logevent("eventStartRound", 2, "1=Round_Start");
register_logevent("eventEndRound", 2, "1=Round_End");
}
public eventStartRound(){
gRoundStart = get_systime();
set_task(1.0, "eventTimerTick", TASKID, _, _, "b")
}
public eventEndRound(){
if(task_exists( TASKID ))
remove_task(TASKID );
}

public eventTimerTick(){
new iRoundTime = get_systime() - gRoundStart;
//iRoundTime - tyle sekund minęło od początku rundy
}


by diablix


#include <amxmodx>

#define VERSION "0.1"

public plugin_init(){
register_plugin("Czas Rundy", VERSION, "diablix");
register_event("RoundTime", "eventRoundTime", "bc");
}

public eventRoundTime(){
new iTimer = read_data(1), iNum;
new iPlayers[32];
new Float:flCvarTime = (get_cvar_float("mp_roundtime") * 60.0);

set_hudmessage(100, 72, 12, 0.01, 0.16, 0, 0.1, 0.1, 0.1, 0.1, 3);
get_players(iPlayers, iNum);

for(new i = 0 ; i < iNum ; i ++)
ShowSyncHudMsg(i, CreateHudSyncObj(), "Czas do końca rundy: %d", floatround(flCvarTime - iTimer));
}

Edited by FetaGreen, 07.02.2012 12:24.
Quote

  • +
  • -
daniosik's Photo daniosik 07.02.2012

Dziękuje FetaGreen za pomoc. Można zamknąć.
Quote

  • +
  • -
Ojciec Dyrektor's Photo Ojciec Dyrektor 07.02.2012

Wiadomość wygenerowana automatycznie


Ten temat został zamknięty przez moderatora.

Powód: Pomoc udzielona

Jeśli się z tym nie zgadzasz, Posted Image raportuj ten post, a moderator lub administrator rozpatrzy go ponownie.


Z pozdrowieniami,
Zespół AMXX.PL
Quote
Locked