AFK leveling kicker + source

Joined
Aug 19, 2006
Messages
106
Reaction score
164
Hello,

today i will share my afk kicker, it will kick any afk leveler in 15 mins.
don't worry it will not affect players sitting in cities, safe zones, shops .. etc

dll is attached.

Source:
Code:
#pragma comment(lib, "detours.lib")
#undef UNICODE
#include <windows.h>
#include <detours.h> 
#include<stdio.h>
#include<iostream>
#include<map>


struct afk{
	ULONGLONG cd;
	DWORD x;
	DWORD y;
	DWORD z;
};
std::map<DWORD, afk> afkMap;


static void (__thiscall *sub_495B20)(DWORD a4,signed int a5) = (void (__thiscall*)(DWORD a4,signed int a5))0x00495B20; 




static signed int(__thiscall *ApplyDamage)(void* _this, int a5, int a6, int a7, int a8, int a9, int a10, int a11) = (signed int(__thiscall*)(void*, int a5, int a6, int a7, int a8, int a9, int a10, int a11))0x0043E950;


void __fastcall ApplyDamage_hooked(void *_this,void *_edx,int Player, int a3, int Damage, int a5, int a6, int a7, int a8)
{






  	 int* PlayerArray = (int*)Player;


	DWORD x = *(DWORD *)(PlayerArray + 83);
	DWORD y = *(DWORD *)(PlayerArray + 84);
	DWORD z = *(DWORD *)(PlayerArray + 85);
	DWORD pid = *(DWORD *)(PlayerArray + 113);


	if(afkMap[pid].x != x || afkMap[pid].y != y){
		afkMap[pid].x = x;
		afkMap[pid].y = y;
		afkMap[pid].cd = GetTickCount64();
	}










	if(GetTickCount64() > (afkMap[pid].cd + 900000)){
		Server::CPlayer::Write(PlayerArray, 60, "ss", "Server", "you have been kicked for AFK leveling!");
					Server::CChar::Write(PlayerArray,0x2D,"b",1);
					sub_495B20(*((DWORD *)PlayerArray + 419), 1);
					Server::Console::WriteRed("Player: %s Kicked for AFK leveling",(PlayerArray+8));


	}




      
       ApplyDamage(_this,Player,a3,Damage,a5,a6,a7,a8);    
    
	
}








BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        {




            DetourTransactionBegin();
            DetourUpdateThread(GetCurrentThread());
            DetourAttach(&(PVOID&)ApplyDamage, ApplyDamage_hooked);
            DetourTransactionCommit();
   
           break;
        }
    case DLL_PROCESS_DETACH:
        {
            DetourTransactionBegin();
            DetourUpdateThread(GetCurrentThread());
            DetourDetach(&(PVOID&)ApplyDamage, ApplyDamage_hooked);
            DetourTransactionCommit();
            break;
        }
    }
    return TRUE;
}

if you want to change kick time search for 900000 and change it for something else.

have fun.
 

Attachments

well so your dont clean up your map - dont even remove the kicked player of it.

well I dont the the point of this, since when you can lvl afk if you dont attack / kill monsters o_O

Oo how will you lvl afk without killing mobs? .. if you mean joining a party and sitting in a safe zone ..i think that's leaching, and since someone else is killing the mobs so it's fine in my opinion.

and for cleaning map after kicking a player just use:
Code:
afkMap.erase(pid);
 
Last edited:
I think this will actually only affect mages who do splash parties.
It is a good point to make sure people do not afk level, but actually the new "bots" nowadays even move to the monsters.
What i actually hope is that this will be improved in case that after 15 mins of not moving a message pops up asking if you are still there.
If that message box is not answered, within 5 mins then you will get kicked.

Think about it.

Cheers,
DreameR
 
I think this will actually only affect mages who do splash parties.
It is a good point to make sure people do not afk level, but actually the new "bots" nowadays even move to the monsters.
What i actually hope is that this will be improved in case that after 15 mins of not moving a message pops up asking if you are still there.
If that message box is not answered, within 5 mins then you will get kicked.

Think about it.

Cheers,
DreameR

good thought ;)
 
get use of classes :D

as MrDreameR said, you could do it like this, display a warning and kick afterwards if still not moving.
Code:
struct afk{
	int x;
	int y;
	int cd;
	bool Warning;
};

map<DWORD, afk> afkMap;

void __fastcall ApplyDamage_hooked(int* thisMonster, void *_edx, int* PlayerArray, int a3, int Damage, int a5, int a6, int a7, int a8){
	auto_ptr<KPlayer> Player(new KPlayer(PlayerArray));
	auto_ptr<KServer> Server;

	[B]int WarningDelay = 10;//display a warning after 10min
	int KickDelay = 15; //kick after 15min[/B]

	int _WarningDelay = WarningDelay * 60000;
	int _KickDelay = KickDelay * 60000;

	int pid = Player->GetPid();//PlayerArray[113];
	int x = Player->GetX();//PlayerArray[83];
	int y = Player->GetY();//PlayerArray[84];
	
	
	if(afkMap[pid].x != x || afkMap[pid].y != y){
		afkMap[pid].x = (x);
		afkMap[pid].y = (y);
		afkMap[pid].cd = (GetTickCount64());
		afkMap[pid].Warning = (false);
	}

	[B]if(!afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _WarningDelay)){[/B]
		afkMap[pid].Warning = (true);
		Player->ChatMessage("Server", "Warning, move now or get kicked in %i min.", (KickDelay - WarningDelay));
	}
	[B]else if(afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _KickDelay))[/B]
	{
		Player->Kick("You've been kicked for AFK leveling");
		Server->ConsoleWrite(TextColor::DARK_MAGENTA, "Player: %s Kicked for AFK leveling at X:%i Y:%i", Player->GetName(), Player->GetX(), Player->GetY());
		afkMap.erase(pid);
	}
	[B]else{//Apply dmg to the Monster[/B]
		Server::CMonsterReal::ApplyDamage(thisMonster,PlayerArray,a3,Damage,a5,a6,a7,a8);
	}
}



BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){
	auto_ptr<LunaCore> Core(new LunaCore());
	Core->Init(ul_reason_for_call, Exports::ServerSide);
	Core->Register(&(PVOID&)Server::CMonsterReal::ApplyDamage, ApplyDamage_hooked);
	return Core->Run();
}
 
get use of classes :D

as @MrDreameR said, you could do it like this, display a warning and kick afterwards if still not moving.
Code:
struct afk{
    int x;
    int y;
    int cd;
    bool Warning;
};

map<DWORD, afk> afkMap;

void __fastcall ApplyDamage_hooked(int* thisMonster, void *_edx, int* PlayerArray, int a3, int Damage, int a5, int a6, int a7, int a8){
    auto_ptr<KPlayer> Player(new KPlayer(PlayerArray));
    auto_ptr<KServer> Server;

    [B]int WarningDelay = 10;//display a warning after 10min
    int KickDelay = 15; //kick after 15min[/B]

    int _WarningDelay = WarningDelay * 60000;
    int _KickDelay = KickDelay * 60000;

    int pid = Player->GetPid();//PlayerArray[113];
    int x = Player->GetX();//PlayerArray[83];
    int y = Player->GetY();//PlayerArray[84];
    
    
    if(afkMap[pid].x != x || afkMap[pid].y != y){
        afkMap[pid].x = (x);
        afkMap[pid].y = (y);
        afkMap[pid].cd = (GetTickCount64());
        afkMap[pid].Warning = (false);
    }

    [B]if(!afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _WarningDelay)){[/B]
        afkMap[pid].Warning = (true);
        Player->ChatMessage("Server", "Warning, move now or get kicked in %i min.", (KickDelay - WarningDelay));
    }
    [B]else if(afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _KickDelay))[/B]
    {
        Player->Kick("You've been kicked for AFK leveling");
        Server->ConsoleWrite(TextColor::DARK_MAGENTA, "Player: %s Kicked for AFK leveling at X:%i Y:%i", Player->GetName(), Player->GetX(), Player->GetY());
        afkMap.erase(pid);
    }
    [B]else{//Apply dmg to the Monster[/B]
        Server::CMonsterReal::ApplyDamage(thisMonster,PlayerArray,a3,Damage,a5,a6,a7,a8);
    }
}



BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){
    auto_ptr<LunaCore> Core(new LunaCore());
    Core->Init(ul_reason_for_call, Exports::ServerSide);
    Core->Register(&(PVOID&)Server::CMonsterReal::ApplyDamage, ApplyDamage_hooked);
    return Core->Run();
}

thanks for the improvements :)
 
get use of classes :D

as MrDreameR said, you could do it like this, display a warning and kick afterwards if still not moving.
Code:
struct afk{
	int x;
	int y;
	int cd;
	bool Warning;
};

map<DWORD, afk> afkMap;

void __fastcall ApplyDamage_hooked(int* thisMonster, void *_edx, int* PlayerArray, int a3, int Damage, int a5, int a6, int a7, int a8){
	auto_ptr<KPlayer> Player(new KPlayer(PlayerArray));
	auto_ptr<KServer> Server;

	[B]int WarningDelay = 10;//display a warning after 10min
	int KickDelay = 15; //kick after 15min[/B]

	int _WarningDelay = WarningDelay * 60000;
	int _KickDelay = KickDelay * 60000;

	int pid = Player->GetPid();//PlayerArray[113];
	int x = Player->GetX();//PlayerArray[83];
	int y = Player->GetY();//PlayerArray[84];
	
	
	if(afkMap[pid].x != x || afkMap[pid].y != y){
		afkMap[pid].x = (x);
		afkMap[pid].y = (y);
		afkMap[pid].cd = (GetTickCount64());
		afkMap[pid].Warning = (false);
	}

	[B]if(!afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _WarningDelay)){[/B]
		afkMap[pid].Warning = (true);
		Player->ChatMessage("Server", "Warning, move now or get kicked in %i min.", (KickDelay - WarningDelay));
	}
	[B]else if(afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _KickDelay))[/B]
	{
		Player->Kick("You've been kicked for AFK leveling");
		Server->ConsoleWrite(TextColor::DARK_MAGENTA, "Player: %s Kicked for AFK leveling at X:%i Y:%i", Player->GetName(), Player->GetX(), Player->GetY());
		afkMap.erase(pid);
	}
	[B]else{//Apply dmg to the Monster[/B]
		Server::CMonsterReal::ApplyDamage(thisMonster,PlayerArray,a3,Damage,a5,a6,a7,a8);
	}
}



BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){
	auto_ptr<LunaCore> Core(new LunaCore());
	Core->Init(ul_reason_for_call, Exports::ServerSide);
	Core->Register(&(PVOID&)Server::CMonsterReal::ApplyDamage, ApplyDamage_hooked);
	return Core->Run();
}

which microsoft visual c.. for compile to dll?
 
Anyone know the problem?

Code:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#pragma comment(lib, "LunaLib.lib")
#include "KPlayer.h"
#include "KServer.h"
#include "LunaCore.h"
#include "KExports.h"
struct afk{
    int x;
    int y;
    int cd;
    bool Warning;
};map<DWORD, afk> afkMap;
void __fastcall ApplyDamage_hooked(int* thisMonster, void *_edx, int* PlayerArray, int a3, int Damage, int a5, int a6, int a7, int a8)
{    auto_ptr<KPlayer> Player(new KPlayer(PlayerArray));
    auto_ptr<KServer> Server;
    int WarningDelay = 10;//display a warning after 10min
    int KickDelay = 15; //kick after 15min
    int _WarningDelay = WarningDelay * 60000;
    int _KickDelay = KickDelay * 60000;
    int pid = Player->GetPID();//PlayerArray[113];
    int x = Player->GetX();//PlayerArray[83];
    int y = Player->GetY();//PlayerArray[84];
            if(afkMap[pid].x != x || afkMap[pid].y != y){
        afkMap[pid].x = (x);
        afkMap[pid].y = (y);
        afkMap[pid].cd = (GetTickCount64());
        afkMap[pid].Warning = (false);
    }    if(!afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _WarningDelay)){        afkMap[pid].Warning = (true);
        Player->ChatMessage("Server", "Warning, move now or get kicked in %i min.", (KickDelay - WarningDelay));
    }    else if(afkMap[pid].Warning && GetTickCount64() > (afkMap[pid].cd + _KickDelay))    {
        Player->Kick("You've been kicked for AFK leveling");
        Server->ConsoleWrite(TextColor::DARK_MAGENTA, "Player: %s Kicked for AFK leveling at X:%i Y:%i", Player->GetName(), Player->GetX(), Player->GetY());
        afkMap.erase(pid);
    }    else{//Apply dmg to the Monster
        Server::CMonsterReal::ApplyDamage(thisMonster,PlayerArray,a3,Damage,a5,a6,a7,a8);    }}BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){
    auto_ptr<LunaCore> Core(new LunaCore());
    Core->Init(ul_reason_for_call, Exports::ServerSide);
    Core->Register(&(PVOID&)Server::CMonsterReal::ApplyDamage, ApplyDamage_hooked);
    return Core->Run();
}

Code:
1>------ Rebuild All started: Project: afk_checker, Configuration: Release Win32 ------
1>  stdafx.cpp
1>  afk_checker.cpp
1>  dllmain.cpp
1>dllmain.cpp(37): warning C4244: '=' : conversion from 'ULONGLONG' to 'int', possible loss of data
1>dllmain.cpp(47): error C2660: 'KPlayer::Kick' : function does not take 1 arguments
1>dllmain.cpp(48): warning C4482: nonstandard extension used: enum 'TextColor' used in qualified name
1>dllmain.cpp(60): error C2653: 'Exports' : is not a class or namespace name
1>dllmain.cpp(60): error C2065: 'ServerSide' : undeclared identifier
 
Back