Page 1 of 1

restart

Posted: 2013 Jan 18 18:12
by GhostMan
Prasideda žemėlapis... Kol serveryje yra 2 ir mažiau žmonių - rodoma žinutė. Kai į serverį ateina 3 ir daugiau žmonių daromas vienas restartas. Jei žaidėjų skaičius vėl nukrenta žemiau 3 (2 ir mažiau) vėl rodoma žinutė ir t.t.

Code: Select all

#include <amxmodx> new g_Restartas = 0new g_SVRestartnew g_HudSync public plugin_init(){    new const VERSION[ ] = "1.0"     register_plugin("DeathRun RoundRR", VERSION, "me")     g_SVRestart =   get_cvar_pointer( "sv_restart" );    g_HudSync = CreateHudSyncObj();     set_task(8.0, "Check", _, _, _, "b")} public Check(){    if(g_Restartas == 0)    {        set_hudmessage(0, 85, 255, -1.0, 0.35, 0, 6.0, 8.0);        ShowSyncHudMsg(0, g_HudSync, "At least 3 players required to start a game!");                if(get_playersnum() >= 3)        {            client_print(0, print_chat, "* Restarting the game!")            set_pcvar_num(g_SVRestart, 1);            g_Restartas = 1        }    }} public client_disconnect(){    if(get_playersnum() <= 2)    {        g_Restartas = 0    }} 
Kažkodėl pirmą kartą restartą padaro, tačiau poto kodas tampa neveiklus.

Re: restart

Posted: 2013 Jan 18 19:56
by Tetusis
gal logikos klaida, p.s blogai buvo sulygiuotas kodas.

Code: Select all

#include <amxmodx>#include <amxmisc> // auto palikti new g_Restartas = 0new g_SVRestartnew g_HudSync public plugin_init() {    new const VERSION[ ] = "1.0"     register_plugin("DeathRun RoundRR", VERSION, "me")     g_SVRestart = get_cvar_pointer("sv_restart");    g_HudSync = CreateHudSyncObj();     set_task(8.0, "Check", _, _, _, "b")} public Check() {    if(get_playersnum() >= 3) {        client_print(0, print_chat, "* Restarting the game!")        set_pcvar_num(g_SVRestart, 1);        g_Restartas = 1    }     else if(g_Restartas == 0) {        set_hudmessage(0, 85, 255, -1.0, 0.35, 0, 6.0, 8.0);        ShowSyncHudMsg(0, g_HudSync, "At least 3 players required to start a game!");    }} public client_disconnect() {    if(get_playersnum() <= 2) {        g_Restartas = 0    }}