Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LAGMAXTIME 15000 // a lag period of 15 seconds is needed
- #define NOLAGMINTIME 4000 // a client is considered as not lagging anymore after 4 seconds without lag
- #define MAXPING 500
- void check_lag(client *cl)
- {
- if(gamemillis < 10000 || (servmillis - cl->connectmillis) < 10000 || MAXPING < 300) return; // do not check at the beginning of a game or when the player joined too recently
- if(cl->spj > 50 || cl->ping > MAXPING || cl->ldt > 80) // currently lagging
- {
- if(!cl->lagmillis) // lag period starting
- {
- cl->lagmillis = servmillis;
- }
- else if(servmillis - cl->lagmillis > LAGMAXTIME) // lag max time reached
- {
- disconnect_client(cl->clientnum, DISC_LAG);
- }
- }
- else if(cl->lagmillis)
- if(!cl->nolagmillis)
- {// stopped lagging during a lag period
- cl->nolagmillis = servmillis;
- }
- else if(servmillis - cl->nolagmillis > NOLAGMINTIME) // no-lag period long enough, lag period ended
- {
- cl->lagmillis = cl->nolagmillis = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement