Hallo Leute !
Da mein erstes logd_timerem so schlecht läuft und es den Server doch sehr belastet, habe ich mich wieder dem alten timerem2 zugewandt und den Code mit Timern benutzt.
Die Timer werden ab Game_Commencing gestartet. Mit Restart_Round werden sie gekillt und wieder neu gestartet.
Die mp_timelimit Veränderung wird nur beim Ausführen der Timer gecheckt.
Hat eine mp_timelimit Änderung stattgefunden, killt er die Timer wieder und startet sie neu.
Natürlich ist die Sache nicht mehr so sicher, aber sie sollte stabiler laufen als das alte logd_timerem.
Das mit dem changelevel (NextMap,4) habe ich rausnehmen müssen, da es sein kann, das vorherige Mapvotings gar nicht mehr beachtet werden.
Der Code ist sehr länglich geworden, da die Funktion Execute_All aus dem ursprünglichen logd_timerem nicht mehr funktioniert hat. Keine Ahnung wieso.... Daher musste ich das execclient in jede Timerfunktion reinschreiben.
Hier der Code, den es zu verbessern gilt :
Code:
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#define ACCESS_CONSOLE 131072
#define ACCESS_BAN 256
new STRING_VERSION[MAX_DATA_LENGTH] = "1.1";
#define MinutesRed 255
#define MinutesGreen 0
#define MinutesBlue 0
#define SecondsRed 255
#define SecondsGreen 255
#define SecondsBlue 255
new GameCommencing=0;
new maptimer;
new checktime;
new t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19 ;
new origtimelimit;
public lt_welt(HLCommand,HLData,HLUserName,UserIndex)
{
new Data [MAX_DATA_LENGTH];
new x [MAX_DATA_LENGTH];
new dummy[MAX_DATA_LENGTH];
convert_string( HLData, Data, MAX_DATA_LENGTH );
strsplit(Data,"_",x,MAX_DATA_LENGTH,dummy,MAX_DATA_LENGTH);
if(strcmp(x,"Game")==0 && GameCommencing == 0)
{
GameCommencing = 1;
checktime =systemtime();
origtimelimit = getvar("mp_timelimit")*60+2;
lt_timerstart();
}
else if(strcmp(x,"Restart")==0)
{
checktime =systemtime();
origtimelimit = getvar("mp_timelimit")*60+2;
lt_timerkill();
}
return PLUGIN_CONTINUE;
}
public lt_timerstart()
{
maptimer =origtimelimit-(systemtime()-checktime);
t1=set_timer("warn30", maptimer - 1800, 0);
t2=set_timer("warn25", maptimer - 1500, 0);
t3=set_timer("warn20", maptimer - 1200, 0);
t4=set_timer("warn15", maptimer - 900, 0);
t5=set_timer("warn10", maptimer - 600, 0);
t6=set_timer("warn5", maptimer - 300, 0);
t7=set_timer("warn1", maptimer - 60, 0);
t8=set_timer("warn030", maptimer - 30, 0);
t9=set_timer("warn010", maptimer - 10, 0);
t10=set_timer("warn009", maptimer - 9, 0);
t11=set_timer("warn008", maptimer - 8, 0);
t12=set_timer("warn007", maptimer - 7, 0);
t13=set_timer("warn006", maptimer - 6, 0);
t14=set_timer("warn005", maptimer - 5, 0);
t15=set_timer("warn004", maptimer - 4, 0);
t16=set_timer("warn003", maptimer - 3, 0);
t17=set_timer("warn002", maptimer - 2, 0);
t18=set_timer("warn001", maptimer - 1, 0);
t19=set_timer("warn000", maptimer - 0, 0);
return PLUGIN_CONTINUE;
}
public lt_timerkill()
{
kill_timer( t1 );
kill_timer( t2 );
kill_timer( t3 );
kill_timer( t4 );
kill_timer( t5 );
kill_timer( t6 );
kill_timer( t7 );
kill_timer( t8 );
kill_timer( t9 );
kill_timer( t10 );
kill_timer( t11 );
kill_timer( t12 );
kill_timer( t13 );
kill_timer( t14 );
kill_timer( t15 );
kill_timer( t16 );
kill_timer( t17 );
kill_timer( t18 );
kill_timer( t19 );
lt_timerstart();
return PLUGIN_CONTINUE;
}
public warn1(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("60 Sekunden bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/sixty seconds remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn5(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("5 Minuten bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/five minutes remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn10(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("10 Minuten bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/ten minutes remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn15(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("15 Minuten bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/fifteen minutes remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn20(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("20 Minuten bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/twenty minutes remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn30(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("30 Minuten bis Mapchange!",12,MinutesRed,MinutesGreen,MinutesBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/thirty minutes remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn030(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60+2;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("30 Sekunden bis Mapchange!",12,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/thirty seconds remaining^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn010(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("TEN",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/ten^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn009(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("NINE",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/nine^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn008(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("EIGHT",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/eight^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn007(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("SEVEN",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/seven^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn006(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("SIX",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/six^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn005(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("FIVE",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/five^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn004(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("FOUR",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/four^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn003(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("THREE",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/three^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn002(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("TWO",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/two^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn001(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("ONE",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"fvox/one^"");
}
}
}
return PLUGIN_CONTINUE;
}
public warn000(Timer,Repeat,HLUser,HLParam)
{
if (getvar("mp_timelimit")*60+2 != origtimelimit)
{
checktime = systemtime()-(systemtime()- checktime);
origtimelimit= getvar("mp_timelimit")*60;
lt_timerkill();
}
else
{
new i;
new Target[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
centersay("GAME OVER",1,SecondsRed,SecondsGreen,SecondsBlue);
for(i=1; i<=maxplayers; i++)
{
strinit(Target);
if(playerinfo(i,Target,MAX_NAME_LENGTH)==1)
{
execclient(Target,"speak ^"have a nice day^"");
}
}
}
return PLUGIN_CONTINUE;
}
public plugin_init()
{
plugin_registerinfo("Ein Timeremember auf LogD-Basis","",STRING_VERSION);
plugin_registercmd("lt_welt", "lt_welt", ACCESS_CONSOLE);
exec("logd_reg 62 admin_command lt_welt");
return PLUGIN_CONTINUE;
}