Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <Windows.h>
- #pragma warning(disable:4996)
- #define MAX_HITS_UNTIL_KICK (5)
- #define MAX_HITS_UNTIL_BAN (10)
- #define WIN32_LEAN_AND_MEAN
- enum FL_GOODS { EMPTY, WATER, FOOD, OXYGEN };
- 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
- to prevent cheating. It can also be updated automatically with simple file input/output, would just take a hour to do so.
- 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
- to make it work always.*/
- enum PLBASE_EX { PLBASE_ERR, BUY, SELL };
- typedef struct _PLAYER {
- wchar_t *pName[50 + 1];
- /* else */
- unsigned int pCash;
- } PLAYER;
- typedef struct _PL_BASE {
- wchar_t *plBase[100 + 1];
- /* else */
- unsigned int bCash;
- } PL_BASE;
- void *trigger_AntiCheat(PLAYER *trent, PL_BASE *base /*, time() */); /* External function, just a placeholder - replace this one with your version */
- unsigned int BaseDealerEx(PLAYER *trent, PL_BASE *base, float *price, unsigned int *opEx);
- unsigned int resetBaseEx(PLAYER *trent, PL_BASE *base, unsigned int *balance);
- int main(PLAYER *trent, PL_BASE *base, unsigned int *goodID, unsigned int *amount, unsigned int *opEx) { /* returns != 0 if successfully */
- static unsigned int hitCtr = { 0 };
- float temp = { 0.00f };
- temp = (float)(goodPrice[(*goodID)] * (*amount));
- 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 */
- if (hitCtr > MAX_HITS_UNTIL_BAN) {
- hitCtr = 0;
- trigger_AntiCheat(trent, base); /* I guess that the trigger_AntiCheat function leaves the client. So no more executed here... */
- }
- else if ((hitCtr++) > MAX_HITS_UNTIL_KICK) {
- trigger_AntiCheat(trent, base); /* I guess that the trigger_AntiCheat function does take care of the client from here on, no more code executed */
- }
- }
- return (1);
- }
- unsigned int BaseDealerEx(PLAYER *trent, PL_BASE *base, float *price, unsigned int *opEx) { /* returns != 0 if successfully */
- unsigned int backupBalance = { trent->pCash };
- switch ((*opEx)) {
- case PLBASE_ERR:
- break;
- 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 */
- /* PERFORM BUY ACTIONS HERE (in C use setjmp and longjmp.. hell maybe even goto if you need to, in Cpp use try/catch) */
- if (((float)(trent->pCash - (*price))) > (float)trent->pCash) {
- resetBaseEx(trent, base, &backupBalance);
- return (0);
- }
- break;
- case SELL: /* Trent sells good(s) to the Base dealer; tl:dr his cash gets increased (over 2 bil probably) */
- /* PERFORM SELL ACTIONS HERE (in C use setjmp and longjmp, in Cpp use try/catch) */
- if (((float)(trent->pCash + (*price))) < (float)trent->pCash) {
- resetBaseEx(trent, base, &backupBalance);
- return (0);
- }
- break;
- }
- return (1);
- }
- unsigned int resetBaseEx(PLAYER *trent, PL_BASE *base, unsigned int *balance) { /* returns != 0 if successfully */
- base->bCash = *balance; /* Reset Cash */
- /* base->bGoods = Reset(); */ /* Reset Goods that he/she tried to buy ... */
- if (!trigger_AntiCheat(trent, base /*, time() */))/* trigger Anti Cheat, write down to a logfile for the cheat attempt */
- return (0); /* leave freelancer. Unable to trigger AntiCheat! */
- return (1);
- }
- void *trigger_AntiCheat(PLAYER *trent, PL_BASE *base) {
- /* placeholder */
- return (NULL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement