Advertisement
Guest User

FL Discovery AntiCheat - PlayerBase Dealer Ex by JoeFlanigan

a guest
Jan 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3.  
  4. #pragma warning(disable:4996)
  5.  
  6. #define MAX_HITS_UNTIL_KICK (5)
  7. #define MAX_HITS_UNTIL_BAN (10)
  8. #define WIN32_LEAN_AND_MEAN
  9.  
  10. enum FL_GOODS { EMPTY, WATER, FOOD, OXYGEN };
  11. const float goodPrice[4 + 1] = { 0.00f, 2.50f, 1.00f, 2.00f }; /* put this into a shared header and give it to devs, to keep it always up to date. This can be used in many ways
  12.                                                                   to prevent cheating. It can also be updated automatically with simple file input/output, would just take a hour to do so.
  13.                                                                   Then it would read all the prices it needs from the ini files itself and no one would ever have to maintain this code again
  14.                                                                   to make it work always.*/
  15.  
  16. enum PLBASE_EX { PLBASE_ERR, BUY, SELL };
  17.  
  18. typedef struct _PLAYER {
  19.     wchar_t *pName[50 + 1];
  20.     /* else */
  21.     unsigned int pCash;
  22. } PLAYER;
  23.  
  24. typedef struct _PL_BASE {
  25.     wchar_t *plBase[100 + 1];
  26.     /* else */
  27.     unsigned int bCash;
  28. } PL_BASE;
  29.  
  30. void *trigger_AntiCheat(PLAYER *trent, PL_BASE *base /*, time() */); /* External function, just a placeholder - replace this one with your version */
  31.  
  32. unsigned int BaseDealerEx(PLAYER *trent, PL_BASE *base, float        *price, unsigned int *opEx);
  33. unsigned int  resetBaseEx(PLAYER *trent, PL_BASE *base, unsigned int *balance);
  34.  
  35. int main(PLAYER *trent, PL_BASE *base, unsigned int *goodID, unsigned int *amount, unsigned int *opEx) { /* returns != 0 if successfully */
  36.     static unsigned int hitCtr = { 0 };
  37.     float temp = { 0.00f };
  38.  
  39.     temp = (float)(goodPrice[(*goodID)] * (*amount));
  40.  
  41.     if (!BaseDealerEx(trent, base, &temp, opEx)) { /* use for() to cycle through base Array. I would rather use a pt to pt object then a struct for a dynamic object like base */
  42.         if (hitCtr > MAX_HITS_UNTIL_BAN) {
  43.             hitCtr = 0;
  44.             trigger_AntiCheat(trent, base); /* I guess that the trigger_AntiCheat function leaves the client. So no more executed here... */
  45.         }
  46.         else if ((hitCtr++) > MAX_HITS_UNTIL_KICK) {
  47.             trigger_AntiCheat(trent, base); /* I guess that the trigger_AntiCheat function does take care of the client from here on, no more code executed */
  48.         }
  49.     }
  50.  
  51.     return (1);
  52. }
  53.  
  54. unsigned int BaseDealerEx(PLAYER *trent, PL_BASE *base, float *price, unsigned int *opEx) { /* returns != 0 if successfully */
  55.     unsigned int backupBalance = { trent->pCash };
  56.  
  57.     switch ((*opEx)) {
  58.     case PLBASE_ERR:
  59.         break;
  60.     case BUY: /* Trent buys goo(s) from the Base dealer; maybe using a memory editor or ini quick fix to get below -2,5 bil on the run */
  61.         /* PERFORM BUY ACTIONS HERE (in C use setjmp and longjmp.. hell maybe even goto if you need to, in Cpp use try/catch) */
  62.         if (((float)(trent->pCash - (*price))) > (float)trent->pCash) {
  63.             resetBaseEx(trent, base, &backupBalance);
  64.             return (0);
  65.         }
  66.         break;
  67.     case SELL: /* Trent sells good(s) to the Base dealer; tl:dr his cash gets increased (over 2 bil probably) */
  68.         /* PERFORM SELL ACTIONS HERE (in C use setjmp and longjmp, in Cpp use try/catch) */
  69.         if (((float)(trent->pCash + (*price))) < (float)trent->pCash) {
  70.             resetBaseEx(trent, base, &backupBalance);
  71.             return (0);
  72.         }
  73.         break;
  74.     }
  75.  
  76.     return (1);
  77. }
  78.  
  79. unsigned int resetBaseEx(PLAYER *trent, PL_BASE *base, unsigned int *balance) { /* returns != 0 if successfully */
  80.     base->bCash = *balance; /* Reset Cash */
  81.     /* base->bGoods = Reset(); */ /* Reset Goods that he/she tried to buy ... */
  82.  
  83.     if (!trigger_AntiCheat(trent, base /*, time() */))/* trigger Anti Cheat, write down to a logfile for the cheat attempt */
  84.         return (0); /* leave freelancer. Unable to trigger AntiCheat! */
  85.  
  86.     return (1);
  87. }
  88.  
  89. void *trigger_AntiCheat(PLAYER *trent, PL_BASE *base) {
  90.     /* placeholder */
  91.  
  92.     return (NULL);
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement