Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- /* ============================================================================
- MetalAnticheat
- by CJ101
- ==============================================================================*/
- #define MAX_PING 1000
- #define COLOR_RED 0xFF0000AA
- #define BAD_NAMES_FILE "/metalac/badnames.txt" // The file where whe look for banned names.
- new AC_Timer;
- forward MetalAdminInit();
- public MetalAdminInit()
- {
- AC_Timer = SetTimer("ACTimer",5000,1);
- print("||=====|| MetalAnticheat by CJ101 Loaded ||=====||");
- return 1;
- }
- forward MetalAdminExit();
- public MetalAdminExit()
- {
- KillTimer(AC_Timer);
- print("||=====|| MetalAnticheat by CJ101 Unloaded ||=====||");
- return 1;
- }
- forward AddBadName(name[]);
- public AddBadName(name[])
- {
- new str[100];
- new File:file = fopen(BAD_NAMES_FILE,io_append);
- format(str,100,"%s\r\n",name);
- fwrite(file,str);
- fclose(file);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid,COLOR_RED,"This Server is running MetalAntiCheat. Cheat and you will be banned!");
- new filestr[128];
- new File:file = fopen(BAD_NAMES_FILE,io_read);
- if (file)
- {
- while(fread(file,filestr,sizeof(filestr)))
- {
- if (strfind(filestr,Name(playerid), true) != -1)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was kicked as there name is blacklisted.",Name(playerid));
- SendClientMessageToAll(COLOR_RED,string);
- Kick(playerid);
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(GetPlayerWeapon(killerid) == 38 || GetPlayerWeapon(killerid) == 36)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was auto-banned for killing with a banned weapon.",Name(killerid));
- SendClientMessageToAll(COLOR_RED,string);
- BanEx(killerid,"WeaponCheat");
- AddBadName(Name(killerid));
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(GetPVarInt(playerid,"SpamMute") == 1) return 0;
- SetPVarInt(playerid,"SpamMute",1);
- SetTimerEx("Unmute",1500,false,"d",playerid);
- return 1;
- }
- forward SpamUnmute(playerid);
- public SpamUnmute(playerid)
- {
- return SetPVarInt(playerid,"SpamMute",0);
- }
- forward ACTimer();
- public ACTimer()
- {
- new wpn;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- wpn = GetPlayerWeapon(i);
- if(wpn == 38 || wpn == 36 || wpn == 44 || wpn == 45)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was banned for weapon cheating.",Name(i));
- SendClientMessageToAll(COLOR_RED,string);
- BanEx(i,"WeaponCheat");
- AddBadName(Name(i));
- }
- if(GetPlayerMoney(i) - PlayerCash(i) > 55000)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was banned for money cheating.",Name(i));
- SendClientMessageToAll(COLOR_RED,string);
- BanEx(i,"Money");
- AddBadName(Name(i));
- }
- if(GetPlayerSpecialAction(i) == 2)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was kicked for having a jetpack.",Name(i));
- SendClientMessageToAll(COLOR_RED,string);
- BanEx(i,"Jetpack");
- AddBadName(Name(i));
- }
- if(GetPlayerPing(i) > MAX_PING)
- {
- new string[128];
- format(string,sizeof string,"ANTICHEAT: %s was kicked for having high ping.",Name(i));
- SendClientMessageToAll(COLOR_RED,string);
- Kick(i);
- }
- }
- }
- }
- stock GivePlayerCash(playerid,amount)
- {
- SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+amount);
- GivePlayerMoney(playerid,amount);
- }
- stock PlayerCash(playerid)
- {
- return GetPVarInt(playerid,"Money");
- }
- stock TakePlayerCash(playerid,amount)
- {
- SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")-amount);
- GivePlayerMoney(playerid,-amount);
- }
- stock ResetPlayerCash(playerid)
- {
- SetPVarInt(playerid,"Money",0);
- ResetPlayerMoney(playerid);
- }
- stock Name(playerid)
- {
- new name[24];
- GetPlayerName(playerid,name,sizeof name);
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment