-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new event onPlayerTeleport. #3941
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Nico <[email protected]>
Co-authored-by: Nico <[email protected]>
Co-authored-by: Nico <[email protected]>
This event will give people false belief that they are protected from cheaters. Cheater can just teleport X times by 49 units. Also,. take an account years of backlog where people teleporting players clientside what means they will get false positive detection. Refactoring may not be an option. If you want to protect your server from cheaters that using teleport hacks, calculate traveled distance over time and implement your "customSetElementPosition" that skips accumulation and use it only server side. Code will be look like: local playersTraveledDistance = {}
local function customSetElementPosition(element, x, y, z)
if isElement(element) and getElementType(element) == "player" then
local playerData = playersTraveledDistance[element]
if playerData then
playerData.lastPosition = { x, y, z }
end
setElementPosition(element, x, y, z)
end
end
setTimer(function()
for _, player in ipairs(getElementsByType("player")) do
if isElement(player) then
local x, y, z = getElementPosition(player)
if not playersTraveledDistance[player] then
playersTraveledDistance[player] = {
lastPosition = { x, y, z },
totalDistance = 0
}
end
local playerData = playersTraveledDistance[player]
local lastPos = playerData.lastPosition
local dx, dy, dz = x - lastPos[1], y - lastPos[2], z - lastPos[3]
local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
playerData.totalDistance = playerData.totalDistance + distance
playerData.lastPosition = { x, y, z }
end
end
end, 1000, 0) |
building project "Deathmatch.vcxproj" -- FAILED. pSourcePlayer->CallEvent("onPlayerTeleport"); |
Regarding the minimum value, I found it valid to change. As for altering the player's position on the client side, I believe that if someone truly wants to protect their server and avoid desynchronizations, they wouldn't use this approach. Furthermore, in larger servers, your example code wouldn't be optimized and would likely cause issues. I tested the first code version with a "hacker" colleague, and it worked very well. |
I would rather put it on server network level whenever the client sends a new position sync update and distance is greater than a server config var, trigger the event. That behaviour should also ignore sync updates done by server itself via setElementPosition or respawnPlayer or whatever. Also account for all client updates done in whatever way, in your example, what does the client stop from executing custom lua code with setElementPosition. |
But the code is doing exactly that. The |
I developed this event to detect players using teleport cheats. The
onPlayerTeleport
event will only be triggered when the player's position is significantly distant from the position registered on the server, and this change was not caused by thesetElementPosition
function. This implementation is based on the suggestion provided in the issue: #3293.