Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

AFK leveling kicker + source

Junior Spellweaver
Joined
Aug 19, 2006
Messages
106
Reaction score
162
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

You must be registered for see attachments list
Junior Spellweaver
Joined
Nov 27, 2014
Messages
142
Reaction score
38
excuse me sir, maybe i have party and leveing but i am not afk so i'll get kick ?:D
 
Legendary Battlemage
Joined
Oct 4, 2011
Messages
617
Reaction score
8
thx alot
but what about if some one make leacher party
 
Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
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
 
Junior Spellweaver
Joined
Aug 19, 2006
Messages
106
Reaction score
162
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:
Junior Spellweaver
Joined
Jan 2, 2008
Messages
159
Reaction score
169
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
 
Junior Spellweaver
Joined
Dec 17, 2011
Messages
167
Reaction score
36
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 ;)
 
Skilled Illusionist
Joined
Mar 20, 2009
Messages
374
Reaction score
378
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();
}
 
Junior Spellweaver
Joined
Aug 19, 2006
Messages
106
Reaction score
162
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 :)
 
Junior Spellweaver
Joined
Oct 20, 2012
Messages
128
Reaction score
68
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?
 
Newbie Spellweaver
Joined
Jul 2, 2016
Messages
93
Reaction score
9
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
Top