edubart / otclient

An alternative tibia client for otserv written in C++11 and Lua, made with a modular system that uses lua scripts for ingame interface and functionality, making otclient flexible and easy to customize
Other
652 stars 399 forks source link

Limiting packets sent by OTClient #564

Open Sceptero opened 10 years ago

Sceptero commented 10 years ago

Many new servers use "maxPacketsPerSecond = 25". Holding down a hotkey button pressed results in a kick from those servers. Cipsoft's tibia client must be limiting number of packets which are sent while holding down a hotkey because you can do it and not get kicked out of the server. Maybe adding some configurable delay between each packet of the same type would solve the problem.

zakius commented 9 years ago

I'm pretty sure that cipbia currently sends packet onKeyDown and if given time passes onKeyUp, this was used to reduce dummies abuse

gesior commented 9 years ago

Code to limit hotkey (not packets per second of whole client). In source src\framework\luafunctions.cpp add new function (we need high precision time in LUA):

g_lua.bindGlobalFunction("timeMillis", []() { return (int) stdext::millis(); });

In modules game_hotkeys\hotkeys_manager.lua before:

function doKeyCombo(keyCombo)

Add:

local lastHotkeyUse = 0

After:

if hotKey.autoSend then

Add:

if timeMillis() - lastHotkeyUse < 100 then return end
lastHotkeyUse = timeMillis()

Simple limit until we get source fix for it. 100 = 100 miliseconds (0.1 sec) between hotkeys actions. Tested on newest sources.