Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- $$$$$$\ $$\ $$\ $$$$$$$$\ $$$$$$\ $$$$$$\ $$\ $$\ $$$$$$$$\ $$$$$$\ $$$$$$$$\
- $$ __$$\ $$$\ $$ |\__$$ __|\_$$ _|$$ __$$\ $$ | $$ |$$ _____|$$ __$$\\__$$ __|
- $$ / $$ |$$$$\ $$ | $$ | $$ | $$ / \__|$$ | $$ |$$ | $$ / $$ | $$ |
- $$$$$$$$ |$$ $$\$$ | $$ | $$ | $$ | $$$$$$$$ |$$$$$\ $$$$$$$$ | $$ |
- $$ __$$ |$$ \$$$$ | $$ | $$ | $$ | $$ __$$ |$$ __| $$ __$$ | $$ |
- $$ | $$ |$$ |\$$$ | $$ | $$ | $$ | $$\ $$ | $$ |$$ | $$ | $$ | $$ |
- $$ | $$ |$$ | \$$ | $$ | $$$$$$\ \$$$$$$ |$$ | $$ |$$$$$$$$\ $$ | $$ | $$ |
- \__| \__|\__| \__| \__| \______| \______/ \__| \__|\________|\__| \__| \__|
- Publics: 1/1/2021
- Last edited: 4/22/2022
- ==============================================================================*/
- #include <YSI_Coding\y_hooks>
- new BitArray:MsgAntiCheat<MAX_PLAYERS>;
- #define TS3 "bstorm-ts3"
- #define NO_SUSPICION_LOGS
- #define VERSION_AC "1.9"
- #define VERSION_AC_PLUS ""VERSION_AC".58"
- #define AC_TABLE_SETTINGS "anticheat_settings" // name of the table
- #define AC_TABLE_FIELD_CODE "ac_code" // table code from sql
- #define AC_TABLE_FIELD_TRIGGER "ac_code_trigger_type" // warn/ban/kick
- #define AC_MAX_CODES 54 // number of ac's
- #define AC_MAX_CODE_LENGTH (5) // 001, 002, 003... etc
- #define AC_MAX_CODE_NAME_LENGTH (33 + 1) // max name of the cheat +1 security
- #define AC_MAX_TRIGGER_TYPES 3 // warn, kick, ban
- #define AC_MAX_TRIGGER_TYPE_NAME_LENGTH (40 + 1)
- #define AC_GLOBAL_TRIGGER_TYPE_PLAYER 0
- #define AC_GLOBAL_TRIGGER_TYPE_IP 1
- #define AC_CODE_TRIGGER_TYPE_DISABLED 0 // AC_CODE_TRIGGER_TYPE_DISABLED - Value: #disable
- #define AC_CODE_TRIGGER_TYPE_WARNING 1 // AC_CODE_TRIGGER_TYPE_WARNING - Value: #warning
- #define AC_CODE_TRIGGER_TYPE_KICK 2 // AC_CODE_TRIGGER_TYPE_KICK - Value: #kick
- #define AC_TRIGGER_ANTIFLOOD_TIME 1 // Vreme anti-fluid(sekunde), #disabled in dialogs...
- #define AC_MAX_CODES_ON_PAGE (20 - 1) // Maksimum anticheata na jednoj strani dialoga
- #define AC_DIALOG_NEXT_PAGE_TEXT ">>> Nastavi" // Tekst za dalje...
- #define AC_DIALOG_PREVIOUS_PAGE_TEXT "<<< Vrati" // Tekst za nazad...
- #define DIALOG_ANTICHEAT_SETTINGS 0 // ID dialoga za anticheat settings...
- #define DIALOG_ANTICHEAT_EDIT_CODE 1 // ID dialoga za editovanje anticheat-a...
- static const AC_CODE[AC_MAX_CODES][AC_MAX_CODE_LENGTH] =
- {
- "1000",
- "1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009", "1010", "1011", "1012", "1013", "1014", "1015", "1016", "1017", "1018", "1019", "1020",
- "1021", "1022", "1023", "1024", "1025", "1026", "1027", "1028", "1029", "1030", "1031", "1032", "1033", "1034", "1035", "1036", "1037", "1038", "1039", "1040", "1041",
- "1042", "1043", "1044", "1045", "1046", "1047", "1048", "1049", "1050", "1051", "1052", "1053"
- };
- static const AC_CODE_NAME[AC_MAX_CODES][AC_MAX_CODE_NAME_LENGTH] =
- {
- {"AirBreak - onfoot"},
- {"AirBreak - veh"},
- {"Teleport - onfoot"},
- {"Teleport - in veh"},
- {"Teleport - veh"},
- {"Teleport - veh to player"},
- {"Teleport - pickups"},
- {"FlyHack - onfoot"},
- {"FlyHack - in veh"},
- {"SpeedHack - onfoot"},
- {"SpeedHack - in veh"},
- {"Health hack - in veh"},
- {"Health hack - onfoot"},
- {"Armour hack"},
- {"Money hack"},
- {"Weapon hack"},
- {"Ammo hack (add)"},
- {"Ammo hack (infinite)"},
- {"Special actions"},
- {"GodMode bullets - onfoot"},
- {"GodMode bullets - in veh"},
- {"Invisible hack"},
- {"Lagcomp-spoof"},
- {"Tuning hack"},
- {"Parkour mod"},
- {"Quick turn"},
- {"Rapid fire"},
- {"FakeSpawn"},
- {"FakeKill"},
- {"Pro Aim"},
- {"CJ run"},
- {"CarShot"},
- {"CarJack"},
- {"UnFreeze"},
- {"AFK Ghost"},
- {"Full Aiming"},
- {"Fake NPC"},
- {"Reconnect"},
- {"High ping"},
- {"Dialog hack"},
- {"Sandbox"},
- {"Invalid version"},
- {"Rcon hack"},
- {"Tuning crasher"},
- {"Invalid seat crasher"},
- {"Dialog crasher"},
- {"Attached object crasher"},
- {"Weapon Crasher"},
- {"Connects to one slot"},
- {"Flood callback functions"},
- {"Flood change seat"},
- {"DDos"},
- {"NOP's"},
- {"Fast Movement"}
- };
- static const AC_TRIGGER_TYPE_NAME[AC_MAX_TRIGGER_TYPES][AC_MAX_TRIGGER_TYPE_NAME_LENGTH] =
- {
- {"{A84032}#Ugasen"}, {"{DBEB34}#Warning"}, {"{55A832}#Kick"}
- };
- new
- AC_CODE_TRIGGER_TYPE[AC_MAX_CODES],
- AC_CODE_TRIGGERED_COUNT[AC_MAX_CODES] = {0, ...};
- new
- pAntiCheatLastCodeTriggerTime[MAX_PLAYERS][AC_MAX_CODES],
- pAntiCheatSettingsPage[MAX_PLAYERS char],
- pAntiCheatSettingsMenuListData[MAX_PLAYERS][AC_MAX_CODES_ON_PAGE],
- pAntiCheatSettingsEditCodeId[MAX_PLAYERS];
- hook OnGameModeInit()
- {
- new
- Cache:cache = mysql_query(Database, "SELECT * FROM "AC_TABLE_SETTINGS" ORDER BY "AC_TABLE_FIELD_CODE""),
- rows = cache_num_rows(),
- tick = GetTickCount();
- if(rows > 0)
- {
- for(new i = 0; i < AC_MAX_CODES; i++)
- {
- cache_get_value_name_int(i, ""AC_TABLE_FIELD_TRIGGER"", AC_CODE_TRIGGER_TYPE[i]);
- if(AC_CODE_TRIGGER_TYPE[i] == AC_CODE_TRIGGER_TYPE_DISABLED)
- EnableAntiCheat(i, 0);
- }
- printf("[MySql] Postavke AC Uspeno ucitane (ucitano: %d). Vreme: %dms. Verzija: %d\n", rows, GetTickCount() - tick, VERSION_AC_PLUS);
- }
- else
- {
- print("[MySQL] Postavke anticheata nisu ucitane proverite bazu.");
- return GameModeExit();
- }
- cache_delete(cache);
- return Y_HOOKS_CONTINUE_RETURN_1;
- }
- hook OnPlayerConnect(playerid)
- {
- for(new i = 0; i < AC_MAX_CODES; i++)
- pAntiCheatLastCodeTriggerTime[playerid][i] = -1;
- pAntiCheatSettingsPage{playerid} = 0;
- pAntiCheatSettingsEditCodeId[playerid] = -1;
- return Y_HOOKS_CONTINUE_RETURN_1;
- }
- forward OnCheatDetected(playerid, ip_address[], type, code, code2);
- public OnCheatDetected(playerid, ip_address[], type, code, code2)
- {
- if(type == AC_GLOBAL_TRIGGER_TYPE_PLAYER)
- {
- switch(code)
- {
- case 5, 6, 11, 22: return 1;
- case 32: // CarJack
- {
- new Float:X, Float:Y, Float:Z;
- AntiCheatGetPos( playerid, X, Y, Z );
- ac_SetPlayerPos( playerid, X, Y, Z );
- SendClientMessage( playerid, ANTICHEATDEC, "[BS-AC]"BELA" Zabranjeno je otimati vozila drugim igracima!" );
- return 1;
- }
- case 40: // Sandbox
- {
- SendClientMessage(playerid, -1, MAX_CONNECTS_MSG);
- return AntiCheatKickWithDesync(playerid, code);
- }
- case 41: // Invalid Version
- {
- SendClientMessage(playerid, -1, UNKNOWN_CLIENT_MSG);
- return AntiCheatKickWithDesync(playerid, code);
- }
- default:
- {
- if(gettime() - pAntiCheatLastCodeTriggerTime[playerid][code] < AC_TRIGGER_ANTIFLOOD_TIME)
- return 1;
- pAntiCheatLastCodeTriggerTime[playerid][code] = gettime();
- AC_CODE_TRIGGERED_COUNT[code]++;
- new trigger_type = AC_CODE_TRIGGER_TYPE[code];
- if(trigger_type == AC_CODE_TRIGGER_TYPE_WARNING) if(Bit_Get(MsgAntiCheat, playerid)) return va_SendClientMessageToAll(0xBE2D2DFF, "<Warning>{FFFFFF} %s[%i] Mozda koristi `%s [code: %03d]`.", ReturnPlayerName(playerid), playerid, AC_CODE_NAME[code], code + 1000);
- else // AC_CODE_TRIGGER_TYPE_KICK
- {
- if(Bit_Get(MsgAntiCheat, playerid)) return va_SendClientMessageToAll(0xBE2D2DFF, "<Kick>{FFFFFF} %s[%i] Zbog `%s [code: %03d]`.", ReturnPlayerName(playerid), playerid, AC_CODE_NAME[code], code + 1000);
- return ToCheat(code, playerid);
- }
- }
- }
- }
- return 1;
- }
- static stock ToCheat(code, playerid)
- {
- new days, year, month, hour, minutes, szIP[ 16 ];
- GetPlayerIp( playerid, szIP, sizeof( szIP ) );
- getdate(year, month, days);
- gettime(hour,minutes);
- format(szNormalString, sizeof(szNormalString), "%02i:%02i %02i.%02i.%i", hour, minutes, days, month, year);
- format(szLargeString, sizeof(szLargeString), ""ANTICHEAT"\nKickovani ste zbog sumnjivih radnji\n\
- Da izbegnete ovakve situacije u buducnosti\n\
- Obrisite cleo i ostale modifikacije u igrici\n\n{FFFFFF}- Account: %s\n- IP: %s\n- Code: %s (%i / 1).\n- NetStat: %i(%.2f) \n\n Da izadjete sa servera kucajte /q(uit).", ReturnPlayerName(playerid), szIP, AC_CODE_NAME[code], 1000+code, GetPlayerPing(playerid), NetStats_PacketLossPercent(playerid));
- ShowPlayerDialog(playerid, 0, 0, szNormalString, szLargeString, !"X", !"");
- AntiCheatKickWithDesync(playerid, code);
- return true;
- }
- static stock ShowPlayerDialogEx(playerid, dialogid, style, caption[], info[], button1[], button2[])
- {
- new dtheme[100] = "{BFBBBA}";
- strcat(dtheme, caption);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- ShowPlayerDialog(playerid, dialogid, style, dtheme, info, button1, button2);
- return 1;
- }
- static stock ShowPlayer_AntiCheatEditCode(playerid, code)
- {
- new
- dialog_header[22 - 4 + AC_MAX_CODE_LENGTH + AC_MAX_CODE_NAME_LENGTH],
- dialog_string[AC_MAX_TRIGGER_TYPE_NAME_LENGTH*AC_MAX_TRIGGER_TYPES];
- format(dialog_header, sizeof(dialog_header), "Kod %s | Naziv: %s", AC_CODE[code], AC_CODE_NAME[code]);
- for(new i = 0; i < AC_MAX_TRIGGER_TYPES; i++)
- {
- strcat(dialog_string, AC_TRIGGER_TYPE_NAME[i]);
- if(i + 1 != AC_MAX_TRIGGER_TYPES)
- strcat(dialog_string, "\n");
- }
- inline const AC_EDIT_CODE(pid, dialogid, response, listitem, string:inputtext[])
- {
- #pragma unused pid, dialogid, inputtext
- if(!response)
- {
- pAntiCheatSettingsEditCodeId[playerid] = -1;
- return ShowPlayer_AntiCheatSettings(playerid);
- }
- new
- item = pAntiCheatSettingsEditCodeId[playerid];
- if(AC_CODE_TRIGGER_TYPE[item] == listitem)
- return ShowPlayer_AntiCheatSettings(playerid);
- if(AC_CODE_TRIGGER_TYPE[item] == AC_CODE_TRIGGER_TYPE_DISABLED && listitem != AC_CODE_TRIGGER_TYPE_DISABLED)
- EnableAntiCheat(item, 1);
- AC_CODE_TRIGGER_TYPE[item] = listitem;
- new
- sql_query[101 - 4 + 1 + 2];
- format(sql_query, sizeof(sql_query), "UPDATE "AC_TABLE_SETTINGS" SET `"AC_TABLE_FIELD_TRIGGER"` = '%d' WHERE `"AC_TABLE_FIELD_CODE"` = '%d'", listitem, item);
- mysql_tquery(Database, sql_query, "", "");
- return ShowPlayer_AntiCheatSettings(playerid);
- }
- Dialog_ShowCallback(playerid, using inline AC_EDIT_CODE, DIALOG_STYLE_LIST, dialog_header, dialog_string, !"Odaberi", !"Nazad");
- return 1;
- }
- static stock ShowPlayer_AntiCheatSettings(playerid)
- {
- static
- dialog_string[42 + 19 - 8 + (AC_MAX_CODE_LENGTH + AC_MAX_CODE_NAME_LENGTH + AC_MAX_TRIGGER_TYPE_NAME_LENGTH + 10)*AC_MAX_CODES_ON_PAGE] = EOS;
- new
- triggeredCount = 0,
- page = pAntiCheatSettingsPage{playerid},
- next = 0,
- index = 0;
- dialog_string = "Kod i naziv\tRadnja\tBroj Triggera\n";
- for(new i = 0; i < AC_MAX_CODES; i++)
- {
- if(i >= (page * AC_MAX_CODES_ON_PAGE) && i < (page * AC_MAX_CODES_ON_PAGE) + AC_MAX_CODES_ON_PAGE)
- next++;
- if(i >= (page - 1) * AC_MAX_CODES_ON_PAGE && i < ((page - 1) * AC_MAX_CODES_ON_PAGE) + AC_MAX_CODES_ON_PAGE)
- {
- triggeredCount = AC_CODE_TRIGGERED_COUNT[i];
- format(dialog_string, sizeof(dialog_string), "%s[#%s] %s\t%s\t%d\n",
- dialog_string,
- AC_CODE[i],
- AC_CODE_NAME[i],
- AC_TRIGGER_TYPE_NAME[AC_CODE_TRIGGER_TYPE[i]],
- triggeredCount);
- pAntiCheatSettingsMenuListData[playerid][index++] = i;
- }
- }
- if(next)
- strcat(dialog_string, ""AC_DIALOG_NEXT_PAGE_TEXT"\n");
- if(page > 1)
- strcat(dialog_string, AC_DIALOG_PREVIOUS_PAGE_TEXT);
- inline const AC_EDIT(pid, dialogid, response, listitem, string:inputtext[])
- {
- #pragma unused pid, dialogid, inputtext
- if(!response)
- {
- pAntiCheatSettingsPage{playerid} = 0;
- return 1;
- }
- if(!strcmp(inputtext, AC_DIALOG_NEXT_PAGE_TEXT))
- {
- pAntiCheatSettingsPage{playerid} ++;
- }
- else if(!strcmp(inputtext, AC_DIALOG_PREVIOUS_PAGE_TEXT))
- {
- pAntiCheatSettingsPage{playerid} --;
- }
- else
- {
- pAntiCheatSettingsEditCodeId[playerid] = pAntiCheatSettingsMenuListData[playerid][listitem];
- return ShowPlayer_AntiCheatEditCode(playerid, pAntiCheatSettingsEditCodeId[playerid]);
- }
- return ShowPlayer_AntiCheatSettings(playerid);
- }
- Dialog_ShowCallback(playerid, using inline AC_EDIT, DIALOG_STYLE_TABLIST_HEADERS, !"Anti-Cheat", dialog_string, !"Odaberi", !"Odustani");
- return 1;
- }
- // cmds
- CMD:msganticheat(playerid)
- {
- //if(PI[playerid][pAdmin] < 1) return SendClientMessage(playerid, CRVENADEC, NO_DOSTUP_TEXT);
- if(Bit_Get(MsgAntiCheat, playerid)) Bit_Vet(MsgAntiCheat, playerid);
- else Bit_Let(MsgAntiCheat, playerid);
- return va_SendClientMessage(playerid, -1, "anti-cheat poruke: %s", MsgAntiCheat ? ("{FFFF00}Off") : ("{FFFF00} On"));
- }
- CMD:anticheat(playerid, params[])
- {
- pAntiCheatSettingsPage{playerid} = 1;
- ShowPlayer_AntiCheatSettings(playerid);
- return 1;
- }
- /* SQL SIDE
- CREATE TABLE IF NOT EXISTS `anticheat_settings` (
- `ac_code` int(2) NOT NULL,
- `ac_code_trigger_type` int(1) NOT NULL,
- UNIQUE KEY `ac_code` (`ac_code`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- INSERT INTO `anticheat_settings` (`ac_code`, `ac_code_trigger_type`) VALUES
- (0, 1),
- (1, 1),
- (2, 1),
- (3, 1),
- (4, 1),
- (5, 1),
- (6, 1),
- (7, 2),
- (8, 1),
- (9, 2),
- (10, 1),
- (11, 2),
- (12, 2),
- (13, 2),
- (14, 2),
- (15, 2),
- (16, 2),
- (17, 2),
- (18, 2),
- (19, 1),
- (20, 1),
- (21, 2),
- (22, 2),
- (23, 2),
- (24, 1),
- (25, 2),
- (26, 2),
- (27, 2),
- (28, 2),
- (29, 1),
- (30, 1),
- (31, 1),
- (32, 1),
- (33, 2),
- (34, 1),
- (35, 1),
- (36, 2),
- (37, 2),
- (38, 1),
- (39, 2),
- (40, 2),
- (41, 2),
- (42, 2),
- (43, 2),
- (44, 2),
- (45, 2),
- (46, 2),
- (47, 2),
- (48, 2),
- (49, 2),
- (50, 2),
- (51, 2),
- (52, 2);
- */
Add Comment
Please, Sign In to add comment