Problem with desyncs (GetLocalPlayer?)

needhelp2008

New Member
Reaction score
1
Hello, i have this code in my map which detects wheter a player is using maphack or not, but players in game desyncs even if they arent using maphack. is there a problem with GetLocalPlayer() function?

JASS:
constant function AntiHackDummy takes nothing returns integer
   return 'e002'
endfunction

function SafeVision takes nothing returns nothing
   call SetUnitAnimationByIndex(udg_u,1)
endfunction

function Anim takes nothing returns nothing
    set udg_t=udg_t+0.001
    if udg_t==0.025 or (IsUnitVisible(udg_u,GetLocalPlayer()) and udg_t<0.025) then
    call SetUnitAnimationByIndex(udg_u,1)
    endif
endfunction

function AntiMapHackTime takes timer t returns nothing
   set udg_t=0.
   call TimerStart(t,0.001,true,function Anim)
   call TriggerSleepAction(0.)
   call RemoveUnit(udg_u)
   call PauseTimer(t)
   call DestroyTimer(t)
endfunction

function Trig_AntiMapHack_Actions takes nothing returns nothing
   set udg_u=CreateUnit(Player(13),AntiHackDummy(),GetCameraTargetPositionX(),GetCameraTargetPositionY(),0)
   if not(IsUnitVisible(udg_u,GetLocalPlayer())) then
    call SetUnitAnimationByIndex(udg_u,0)
   else
    call SetUnitAnimationByIndex(udg_u,1)
   endif
   call AntiMapHackTime(CreateTimer())
endfunction

//===========================================================================
function InitTrig_AntiMapHack takes nothing returns nothing
    set gg_trg_AntiMapHack = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_AntiMapHack, 2.00 )
    call TriggerAddAction( gg_trg_AntiMapHack, function Trig_AntiMapHack_Actions )
endfunction


Trigger:
  • Variables
    • Acontecimientos
      • Map initialization
    • Condiciones
    • Acciones
      • Set t = 0.00
      • Set u = (Last created unit)
      • Set x = 0.00
      • Set y = 0.0
 

Bribe

vJass errors are legion
Reaction score
67
You can't create a unit at GetCameraTargetPositionX/Y. Those return different values for different players and cause desync.

Also, this:

JASS:

function InitTrig_AntiMapHack takes nothing returns nothing
    set gg_trg_AntiMapHack = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_AntiMapHack, 2.00 )
    call TriggerAddAction( gg_trg_AntiMapHack, function Trig_AntiMapHack_Actions )
endfunction


Could be shortened to just this:

JASS:

function InitTrig_AntiMapHack takes nothing returns nothing
    call TimerStart(CreateTimer(), 2, true, function Trig_AntiMapHack_Actions)
endfunction
 

needhelp2008

New Member
Reaction score
1
You can't create a unit at GetCameraTargetPositionX/Y. Those return different values for different players and cause desync.

Also, this:

JASS:

function InitTrig_AntiMapHack takes nothing returns nothing
    set gg_trg_AntiMapHack = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_AntiMapHack, 2.00 )
    call TriggerAddAction( gg_trg_AntiMapHack, function Trig_AntiMapHack_Actions )
endfunction


Could be shortened to just this:

JASS:

function InitTrig_AntiMapHack takes nothing returns nothing
    call TimerStart(CreateTimer(), 2, true, function Trig_AntiMapHack_Actions)
endfunction

is there another way to create units at camera position that doesnt causes desyncs? :(
 

Bribe

vJass errors are legion
Reaction score
67
Yes, instead of "IsUnitVisible" you could use "IsFoggedToPlayer" and avoid the whole unit issue altogether.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
There is no way even if you control the camera because it still can have a different value for each player, assuming a player minimize his warcraft3.
(Btw that's how you can break the replay detection which use camera pan + a TriggerSleepAction).

Alternatively you could synchronise a local value and use this one, but sync is not instant, however here it's not a problem.
Ofc if you control the camera by the script then you can simply create the unit where the camera is supposed to be, no matter where is it really (warcraft 3 minimized or not).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top