Advertisement
lucasgautheron

teabag detector

Jan 2nd, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. // server.cpp : "case SV_POSC" : add "if( ((cl->f >> 7)&1) == 1 && ((f>>7)&1) != 1) check_teabag(cl);"
  2.  
  3. // serverchecks.h :
  4. bool check_teabag(client *c)
  5. {
  6.     if(gamemillis - c->state.lastteabagmillis < 800) return false; // teabag occured too recently
  7.     loopv(clients) if(clients[i] && clients[i] != c && clients[i]->type == ST_TCPIP && clients[i]->isauthed  // target logged
  8.         && clients[i]->state.state == CS_DEAD && (gamemillis - clients[i]->state.lastdeath) < 6000           // target was killed recently enough
  9.         && (gamemillis - c->state.lastteabagmillis > 5000 || c->state.lastteabagcn != clients[i]->clientnum) // target was not teabagged recently
  10.         && clients[i]->state.o.dist(c->state.o) < 6.5f)                                                      // target is close enough
  11.     {
  12.         if(gamemillis - c->state.lastteabagmillis < 5500 && c->state.lastteabagcn == clients[i]->clientnum) continue;
  13.         loopj(4) c->state.crouches[4-j] = c->state.crouches[3-j];
  14.         c->state.crouches[0] = gamemillis;
  15.         bool fastenough = (gamemillis - c->state.crouches[2] < 5000) || (gamemillis - c->state.crouches[1] < 1000); // 3 crouches within 5 seconds or 2 within a second
  16.        
  17.         if(fastenough)
  18.         {
  19.             ++c->state.teabags_done;
  20.             ++clients[i]->state.teabags_received;
  21.             ++c->lscore.teabagsdone;
  22.             ++clients[i]->lscore.teabagsreceived;
  23.             c->state.lastteabagcn = clients[i]->clientnum;
  24.             c->state.lastteabagmillis = gamemillis;
  25.  
  26.             defformatstring(msg_actor)("\f9you teabagged %s", clients[i]->name);
  27.             defformatstring(msg_target)("\f9you were teabagged by %s", c->name);
  28.             sendservmsg(msg_actor, c->clientnum);
  29.             sendservmsg(msg_target, clients[i]->clientnum);
  30.             logline(ACLOG_INFO, "[%s] %s teabagged %s", c->hostname, c->name, clients[i]->name);
  31.  
  32.             loopj(5) c->state.crouches[j] = 0;
  33.             return true;
  34.         }
  35.     }
  36.     return false;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement