[vJass] Anti map hack

User avatar
Enalias
Site Admin
Site Admin
Posts: 200
Joined: Sat Sep 15, 2018 1:57 pm
Reputation: 9
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:
United States of America

[vJass] Anti map hack

#1

Post by Enalias » Mon Nov 05, 2018 11:23 am

Hello Chaos Realm!
Here's a powerful Anti Hack System.
*Only recommended for experient makers*

Instructions:
To make it work, you need to create a dummy, invisible unit, with object id 'anmh'.
After, you need to create two regions: One where you must create a visibility modifier enabling visiblity for all players and other fogged. We gonna call the visibile on "Vis" and fogged other "Show".
Now, pick the X and Y coordinates of the center of those regions and put on script configuration.
Now, define the periodic time that the system will check for MH in 'TimePick'.
Voalá! Your map hack system is ready to be used.
*CAUTION: THE FOGGED AREA NEVER, *NEVER*, CAN BE SHOWN OR ACCESSIBLE TO ANY PLAYER*

Pros:
- works for safe mode MH
- don't change player camera
- it's automatic and doesn't require a player to type a command
Cons:
- doesn't detect mini map hack [actually that's impossible to prevent]
- it clears the players selection each time it check for map hack. if the periodic check is too short, can affect the gameplay.

Code:
Spoiler
Show
library AntiMh initializer InitAntiMh

globals
private constant real TimePick = 10.0

public unit ShowPickUnit
public unit VisPickUnit
public unit ShowNoPickUnit

private constant real ShowX = 8000
private constant real ShowY = -8000
private constant real VisX = -8000
private constant real VisY = -8000


private integer array counter1
private unit array lastunit1
private unit array lastunit2
private boolean array testr1
private boolean array testr2
private boolean first = true


private trigger TriggerEn1
private trigger TriggerEn2
private timer TimerMh
endglobals

function ActionSelect takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)
if u == ShowPickUnit then
set testr1[id] = true
set testr2[id] = true
endif

if u == VisPickUnit then
if (GetPlayerController(p) == MAP_CONTROL_USER) and (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING ) then
if testr1[id] == false or testr2[id] == true then



if IsUnitVisible(ShowNoPickUnit,p) == false then
call DisplayTextToForce( GetPlayersAll(), GetPlayerName(p)+"|cffff0000 is using map hack!!|r" )
call CustomDefeatBJ(p, "GTFO, Hacker!!")

// ___ ___ __ ______ _ ___ _______

endif
call SelectUnit(ShowPickUnit, false)
endif

set testr1[id] = false
set testr2[id] = false
endif
endif

if ShowPickUnit != u and VisPickUnit != u then
set counter1[id] = counter1[id] + 1
if counter1[id] == 12 then
set lastunit1[id] = u
endif
if counter1[id] == 11 then
set lastunit2[id] = u
endif
if counter1[id] > 12 then
set counter1[id] = 12

endif
endif
endfunction


function ActionDeSelect takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetTriggerPlayer()
local integer id = GetPlayerId(p)

if ShowPickUnit != u and VisPickUnit != u then
set counter1[id] = counter1[id] - 1
if lastunit1[id] == u then
set lastunit1[id] = null
endif
if lastunit2[id] == u then
set lastunit2[id] = null
endif
endif

if u == ShowPickUnit then
set testr2[id] = false
endif


endfunction


function DetectMh takes nothing returns nothing
call SetUnitX(ShowPickUnit,VisX)
call SetUnitY(ShowPickUnit,VisY)
if counter1[GetPlayerId(GetTriggerPlayer())] <= 10 then
call SelectUnit(ShowPickUnit, true)
call SelectUnit(VisPickUnit, true)
call SelectUnit(VisPickUnit, false)
call SelectUnit(ShowPickUnit, false)
else
call DisableTrigger(TriggerEn1)
call DisableTrigger(TriggerEn2)
call SelectUnit(lastunit1[GetPlayerId(GetLocalPlayer())], false)
call SelectUnit(lastunit2[GetPlayerId(GetLocalPlayer())], false)
call SelectUnit(ShowPickUnit, true )
call SelectUnit(VisPickUnit, true)
call SelectUnit(VisPickUnit, false)
call SelectUnit(ShowPickUnit, false)
call SelectUnit(lastunit1[GetPlayerId(GetLocalPlayer())], true )
call SelectUnit(lastunit2[GetPlayerId(GetLocalPlayer())], true )
call EnableTrigger(TriggerEn1)
call EnableTrigger(TriggerEn2)
endif
call SetUnitX(ShowPickUnit,ShowX)
call SetUnitY(ShowPickUnit,ShowY)
endfunction



private function InitAntiMh takes nothing returns nothing
local integer i = 0

set ShowPickUnit = CreateUnit(Player(15),'anmh',ShowX,ShowY,0)
set VisPickUnit = CreateUnit(Player(15),'anmh',VisX,VisY,0)
set ShowNoPickUnit = CreateUnit(Player(15),'anmh',ShowX,ShowY,0)




set TriggerEn1 = CreateTrigger()
set TriggerEn2 = CreateTrigger()

loop
exitwhen i > 12
call TriggerRegisterPlayerUnitEvent(TriggerEn1, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
call TriggerRegisterPlayerUnitEvent(TriggerEn2, Player(i), EVENT_PLAYER_UNIT_DESELECTED, null)
set i = i + 1
endloop

call TriggerAddAction( TriggerEn1, function ActionSelect )
call TriggerAddAction( TriggerEn2, function ActionDeSelect )

set TimerMh = CreateTimer()

call TimerStart(TimerMh,TimePick,true,function DetectMh)



endfunction

endlibrary
Credits: Fire_Arkangel

Return to “Systems”

×