Advertisement
Guest User

Untitled

a guest
Jan 8th, 2025
26
0
116 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.08 KB | None | 0 0
  1. -- support pastern
  2.  
  3. --[[
  4. Welcome to Knighmare Anti-Cheat Service
  5. Code Author Contact (KnightMB)
  6. https://devforum.roblox.com/u/knightmb1
  7. -----------------------------------------------------------------------------------
  8. -----------------------------------------------------------------------------------
  9. --                  CONFIGURATION SECTION START
  10. -----------------------------------------------------------------------------------
  11. -----------------------------------------------------------------------------------
  12. -- PLAYER MOVEMENT SPEED ANTI-CHEAT
  13. --
  14. If you want to ignore a certain player for Speed Cheat Detection, then
  15. set an attribute called "KM_IGNORE_PLAYER_SPEED_CHEAT" to true on that specific player
  16. object. This can be used to create exceptions when needed if the anti-cheat service is causing
  17. issues with specific parts of your game.
  18. If you need to teleport a player and only need a temporary exception, then set this
  19. attribute to true on the player instead, "KM_SPEED_TEMPORARY_EXCEPTION" This will be removed
  20. after a speed cheat is detected one time.
  21.  
  22. Set this to false if you want to turn off all Speed Cheat Detection Server Wide
  23. Default = true
  24. --]]
  25. speedCheatDetectionEnabled = true
  26.  
  27. --[[
  28. Set this to true if you want the server to output Debug info for Speed Cheat Detection.
  29. This is helpful when trying to fine tune settings for your game through testing.
  30. Default = false
  31. --]]
  32. debugSpeedCheatDetection = true
  33.  
  34. --[[
  35. Max Speed Player Can Move Period. This will set a "speed limit" on the player
  36. that when exceeded, will increment a counter of how many times the player is moving
  37. faster than what should be allowed in your game.
  38. Every player will have an attribute set on the player object as "KM_MAX_PLAYER_SPEED"
  39. This means you can change the max speed on the specific player anytime you want to, such
  40. as using powerups or abilities or just running as an example. The anti-cheat
  41. service will re-calibrate to the new speed limit.
  42. Default = 16
  43. --]]
  44. maxPlayerSpeed = 0
  45.  
  46. --[[
  47. What percentage of the speed reading can be above the Max Player Speed and not
  48. trigger a speed cheat detection.
  49. 0.20 is a 20% margin of error on the speed readings due to different client devices
  50. or Internet latency that can make the measured speed a little higher than normal.
  51. You can tweak this number if false detections are an issue in game by using a higher
  52. number to allow more flexibility.
  53. Default = 0.20 percent
  54. --]]
  55. clientPredictionFudge = 0.20
  56.  
  57. --[[
  58. If you have no "falling" in your game, you can turn off this additional check.
  59. Default = false
  60. --]]
  61. ignoreFreeFalling = true
  62.  
  63. --[[
  64. Normally speed is checked in 3 dimensions, so running up stairs is faster than running
  65. along a flat path distance wise. If your game is having a lot of false detections because of
  66. really long stairs or hills, disable this to use only the X and Z dimensions speed for checking by
  67. setting this value to true. Basically ignoring the Y dimension of the player moving up or down.
  68. Default = false
  69. --]]
  70. excludeYDimension = true
  71.  
  72. --[[
  73. How long to ignore Free Fall in seconds when ignoreFreeFalling is set to false above.
  74. Once the timer expires, the speed will be tracked again to check for speed cheat
  75. detections even when falling.
  76. Default = 2.0 seconds
  77. --]]
  78. maxFreeFallTime = 2.0
  79.  
  80. --[[
  81. How many bunny hops can a player make when ignoreFreeFalling is set to false above.
  82. A speed cheater might try to bunny hop and speed cheat when the service is ignoring
  83. free fall time. This will help stop that.
  84. Default = 1
  85. --]]
  86. maxBunnyHops = 1
  87.  
  88. --[[
  89. If a player is bunny hoping too much, how long do they need to stop before the max
  90. bunny hops are reset.
  91. Default = 2.0 seconds
  92. --]]
  93. maxBunnyHopTimeout = 2.0
  94.  
  95. --[[
  96. The number of times the speed limit can be broken before acting on the player.
  97. When a player is not speed cheating, this number will increment back down to zero.
  98. The player is scanned 5 times per second, so the default gives them about 2 seconds
  99. to stop cheating before the penalty is applied.
  100. Because of Internet latency, it is recommended not to set this number too low
  101. or you'll end up getting false detections on a player with a slow device or lag.
  102. Default = 10
  103. --]]
  104. maxSpeedCheatDetects = 5
  105.  
  106. --[[
  107. This will send the Speed Cheater Back to their Last Location before the Speed Cheating
  108. max threshold was reached. Set this to false if you want to implement your own form of punishment :)
  109. Look in the "KnightmareCustomPunishment" file to find the proper section related to this cheat.
  110. If you want both soft punishment and custom punishment, this is possible by setting this option
  111. to "both" using full quotation marks.
  112. Default = true
  113. --]]
  114. sendSpeedCheaterBack = true
  115.  
  116. -- PLAYER MOVEMENT SPEED ANTI-CHEAT
  117. -----------------------------------------------------------------------------------
  118. -----------------------------------------------------------------------------------
  119. -- PLAYER FLYING ANTI-CHEAT
  120. --[[
  121. If you want to ignore a certain player for Fly Cheat Detection, then
  122. set an attribute called "KM_IGNORE_PLAYER_FLY_CHEAT" to true on that specific player
  123. object. This can be used to create exceptions when needed if the anti-cheat service is causing
  124. issues with specific parts of your game.
  125.  
  126. Set this to false if you want to turn off all Fly Cheat Detection Server Wide
  127. Default = true
  128. --]]
  129. flyCheatDetectionEnabled = true
  130.  
  131. --[[
  132. Set this to true if you want the server to output Debug info for Fly Cheat Detection.
  133. This is helpful when trying to fine tune settings for your game through testing.
  134. Default = false
  135. --]]
  136. debugFlyCheatDetection = true
  137.  
  138. --[[
  139. If you have no "climbing" in your game, you can turn off this additional check.
  140. Default = false
  141. --]]
  142. ignoreClimbing = false
  143.  
  144. --[[
  145. If you have no "swimming" in your game, you can turn off this additional check.
  146. Default = false
  147. --]]
  148. ignoreSwimming = false
  149.  
  150. --[[
  151. When ray casting from the player legs, how far down to look for a
  152. solid object to be standing on.
  153. Default = 1.5 studs
  154. --]]
  155. maxGroundDistance = 1.5
  156.  
  157. --[[
  158. When radius casting from the player legs, how far to look in a sphere for a
  159. solid object to be standing on sideways.
  160. Default = 1.0 studs
  161. --]]
  162. maxRadiusToObjectDistance = 1.0
  163.  
  164. --[[
  165. When a player is floating, this will boost the scan distance to help find
  166. a collideable object underneath in case they are riding down a falling
  167. object at the same rate that the object is falling. Lag can make this
  168. appear to float to the anti-cheat and cause false detections.
  169. Default = 1.5 studs
  170. --]]
  171. boostFloatingDistanceScan = 1.5
  172.  
  173. --[[
  174. If the player IS moving and nothing is under the player that keeps them
  175. from falling, how long can they be in this state?
  176. Default = 3.0 seconds
  177. --]]
  178. maxMovingFloatTime = 3.0
  179.  
  180. --[[
  181. Which way is down?
  182. Default = Y axis
  183. --]]
  184. iDownDirection = "Y"
  185.  
  186. --[[
  187. If a player is not standing on an object or slope, they might be
  188. falling or jumping. If they are floating in the air via hacks, they will
  189. have no linear velocity. If they are using a gravity cheat, this can also be detected.
  190. Default = 7.0
  191. --]]
  192. minimumLinearVelocity = 7.0
  193.  
  194. --[[
  195. The number of times the fly cheat can be broken before acting on the player.
  196. When a player is not fly cheating, this number will increment back down to zero.
  197. The player is scanned 5 times per second, so the default gives them about 2 seconds
  198. to stop cheating before the penalty is applied.
  199. Because of Internet latency, it is recommended not to set this number too low
  200. or you'll end up getting false detections on a player with a slow device or lag.
  201. Default = 10
  202. --]]
  203. maxFlyCheatDetects = 10
  204.  
  205. --[[
  206. This records where the player was last standing on a solid object before the next scan
  207. determined the player was in the air. This will be used by the soft punishment to send the
  208. player back to the last ground position instead of straight down to the solid object underneath
  209. when enabled. This will also be passed to the custom punishment file if enabled.
  210. Change this setting to true if you want to use this configuration option.
  211. Default = false
  212. --]]
  213. recordFlyGroundPosition = false
  214.  
  215. --[[
  216. This will send the Fly Cheater down to the ground when the maxFlyCheatDetects threshold
  217. is reached. Set this to false if you want to implement your own form of punishment :)
  218. Look in the "KnightmareCustomPunishment" file to find the proper section related to this cheat.
  219. If you want both soft punishment and custom punishment, this is possible by setting this option
  220. to "both" using full quotation marks.
  221. Default = true
  222. --]]
  223. sendFlyCheaterToGround = true
  224.  
  225. -- PLAYER FLYING ANTI-CHEAT
  226. -----------------------------------------------------------------------------------
  227. -----------------------------------------------------------------------------------
  228. -- PLAYER TELEPORT ANTI-CHEAT
  229. --[[
  230. If you want to ignore a certain player for Teleport Cheat Detection, then
  231. set an attribute called "KM_IGNORE_PLAYER_TELEPORT_CHEAT" to true on that specific player
  232. object. This can be used to create exceptions when needed if the anti-cheat service is causing
  233. issues with specific parts of your game.
  234. If you need to teleport a player and only need a temporary exception, then set this
  235. attribute to true on the player instead, "KM_TELEPORT_TEMPORARY_EXCEPTION" This will be removed
  236. after a teleport cheat is detected one time.
  237. Set this to false if you want to turn off all Teleport Cheat Detection Server Wide
  238. Default = true
  239. --]]
  240. teleportCheatDetectionEnabled = true
  241.  
  242. --[[
  243. Set this to true if you want the server to output Debug info for Teleport Cheat Detection.
  244. This is helpful when trying to fine tune settings for your game through testing.
  245. Default = false
  246. --]]
  247. debugTeleportCheatDetection = true
  248.  
  249. --[[
  250. Maximum distance that no player could ever cover in 0.2 seconds and considered
  251. an automatic cheat and punishment. Helps with blatant teleport cheating.
  252. Default = 50 studs
  253. --]]
  254. maxLongRangeTeleport = 100
  255.  
  256. --[[
  257. Maximum distance a player can push through any solid object within a 0.2 seconds
  258. time frame. If your walls or doors are smaller than this, you can tune this setting.
  259. Default = 1 stud
  260. --]]
  261. maxShortRangeTeleport = 80
  262.  
  263. --[[
  264. Ignore teleport detection through other players. If your game allows players to walk
  265. through each other, it can set off false teleport detections. Enable this with a true
  266. setting and anything on the player model will be ignored when moving through another
  267. player.
  268. Default = false
  269. --]]
  270. ignoreTeleportOtherPlayers = true
  271.  
  272. --[[
  273. Ignore teleport detection through specific models chosen by the developer. This will ignore
  274. all descendant parts of this model. The model needs the attribute "KM_TELEPORT_IGNORE_MODEL"
  275. set to true. This can be assigned in Studio via a boolean attribute or manually during run-time
  276. with a script if preferred.
  277. Default = false
  278. --]]
  279. ignoreTeleportExceptionModels = true
  280.  
  281. --[[
  282. This will send the Teleport Cheater Back to their Last Location before the Teleport Cheating
  283. threshold was reached. Set this to false if you want to implement your own form of punishment :)
  284. Look in the "KnightmareCustomPunishment" file to find the proper section related to this cheat.
  285. If you want both soft punishment and custom punishment, this is possible by setting this option
  286. to "both" using full quotation marks.
  287. Default = true
  288. --]]
  289. sendTeleportCheaterBack = true
  290.  
  291. -- PLAYER TELEPORT ANTI-CHEAT
  292. -----------------------------------------------------------------------------------
  293. -----------------------------------------------------------------------------------
  294. -- PLAYER JUMP ANTI-CHEAT
  295. --[[
  296. If you want to ignore a certain player for Jump Cheat Detection, then
  297. set an attribute called "KM_IGNORE_PLAYER_JUMP_CHEAT" to true on that specific player
  298. object. This can be used to create exceptions when needed if the anti-cheat service is causing
  299. issues with specific parts of your game.
  300. If you need a temporary exception, then set this attribute to true on the player
  301. instead, "KM_JUMP_TEMPORARY_EXCEPTION" This will be removed after a jump cheat is detected one time.
  302. Set this to false if you want to turn off all Jump Cheat Detection Server Wide
  303. Default = true
  304. --]]
  305. jumpCheatDetectionEnabled = true
  306.  
  307. --[[
  308. Set this to true if you want the server to output Debug info for Jump Cheat Detection.
  309. This is helpful when trying to fine tune settings for your game through testing.
  310. Default = false
  311. --]]
  312. debugJumpCheatDetection = false
  313.  
  314. --[[
  315. Which way is down?
  316. Default = Y axis
  317. --]]
  318. iJumpDownDirection = "Y"
  319.  
  320. --[[
  321. Which way is jump movement? Usually Positive Numbers, but in case you
  322. have a different type of game world.
  323. P = Positive
  324. N = Negative
  325. Default = P
  326. --]]
  327. iJumpMovement = "P"
  328.  
  329. --[[
  330. Max Player Jump Power. This will be the "jump power" limit on the player that
  331. when exceeded will act on the player.
  332. Every player will have an attribute set on the player object as "KM_MAX_JUMP_POWER"
  333. This means you can change the max jump power of a specific player anytime you want,
  334. such as using power-ups or abilities. The anti-cheat service will re-calibrate to the
  335. new jump power limit.
  336. Default = 13
  337. --]]
  338. maxPlayerJumpPower = 0
  339.  
  340. --[[
  341. When ray casting from the player legs, how far down to look for a
  342. solid object to be standing on.
  343. Default = 1.5 studs
  344. --]]
  345. maxJumpGroundDistance = 1.5
  346.  
  347. --[[
  348. If you have no "climbing" in your game, you can turn off this additional check.
  349. Default = false
  350. --]]
  351. ignoreJumpClimbing = false
  352.  
  353. --[[
  354. If you have no "swimming" in your game, you can turn off this additional check.
  355. Default = false
  356. --]]
  357. ignoreJumpSwimming = false
  358.  
  359. --[[
  360. This will stop the player in mid-air by resetting their Jump velocity back to 0 so they fall
  361. back down to the ground. Set this to false if you want to implement your own form of punishment :)
  362. Look in the "KnightmareCustomPunishment" file to find the proper section related to this cheat.
  363. If you want both soft punishment and custom punishment, this is possible by setting this option
  364. to "both" using full quotation marks.
  365. Default = true
  366. --]]
  367. stopJumpCheater = true
  368.  
  369. -- PLAYER JUMP ANTI-CHEAT
  370. -----------------------------------------------------------------------------------
  371. -----------------------------------------------------------------------------------
  372. -- GLOBAL SETTINGS
  373. --[[
  374. Set Text Color in the Debug GUI.
  375. Default = Color3.fromRGB(170, 255, 255)
  376. --]]
  377. debugGUITextColor = Color3.fromRGB(170, 255, 255)
  378.  
  379. --[[
  380. Set Text Size of the Debug GUI
  381. Default = 14
  382. --]]
  383. debugGUITextSize = 14
  384.  
  385. --[[
  386. Set Horizontal Size Percentage of the Debug GUI relative to your Screen size
  387. Default = 0.35 -> 35%
  388. --]]
  389. debugGUISizeX = 0.35
  390.  
  391. --[[
  392. Set Vertical Size Percentage of the Debug GUI relative to your Screen size
  393. Default = 0.35 -> 35%
  394. --]]
  395. debugGUISizeY = 0.35
  396.  
  397. -- GLOBAL SETTINGS
  398. -----------------------------------------------------------------------------------
  399. -----------------------------------------------------------------------------------
  400. --                  CONFIGURATION SECTION END
  401. -----------------------------------------------------------------------------------
  402. -----------------------------------------------------------------------------------
  403. -----------------------------------------------------------------------------------
  404. -- SETUP MAIN ANTI-CHEAT SERVICE - DO NOT MODIFY CODE BELOW THIS
  405. -----------------------------------------------------------------------------------
  406. -----------------------------------------------------------------------------------
  407. -- Does Knightmare Anti-Cheat Service From Network Update Exist?
  408. local oCopy = game:GetService("ServerScriptService"):FindFirstChild("KnightmareAntiCheatService")
  409.  
  410. if not oCopy then
  411.     -- Network Update Failed, Use Local Copy
  412.     oCopy = script.Parent:FindFirstChild("KnightmareAntiCheatService")
  413.  
  414.     if oCopy then
  415.         -- Local Copy Exist, Use That Instead
  416.         oCopy = oCopy:Clone()
  417.         oCopy.Parent = game:GetService("ServerScriptService")
  418.         print("Loading Local Copy of Knightmare Anti-Cheat Service")
  419.     else
  420.         -- Could Not Find Local Copy of Service to Start
  421.         warn("Knightmare Anti-Cheat Service Failed to Load Neither Network nor Local Code!!")
  422.         return
  423.     end
  424. end
  425.  
  426. -- Move Custom Punishments to Server Storage to Access Later
  427. script.Parent.KnightmareCustomPunishment.Parent = game:GetService("ServerStorage")
  428. task.wait()
  429.  
  430. -- Copy Variable to Knightmare Anti-Cheat Service From This Configuration File
  431. oCopy:SetAttribute("speedCheatDetectionEnabled", speedCheatDetectionEnabled)
  432. oCopy:SetAttribute("debugSpeedCheatDetection", debugSpeedCheatDetection)
  433. oCopy:SetAttribute("maxPlayerSpeed", maxPlayerSpeed)
  434. oCopy:SetAttribute("clientPredictionFudge", clientPredictionFudge)
  435. oCopy:SetAttribute("ignoreFreeFalling", ignoreFreeFalling)
  436. oCopy:SetAttribute("excludeYDimension", excludeYDimension)
  437. oCopy:SetAttribute("maxFreeFallTime", maxFreeFallTime)
  438. oCopy:SetAttribute("maxBunnyHops", maxBunnyHops)
  439. oCopy:SetAttribute("maxBunnyHopTimeout", maxBunnyHopTimeout)
  440. oCopy:SetAttribute("maxSpeedCheatDetects", maxSpeedCheatDetects)
  441. oCopy:SetAttribute("sendSpeedCheaterBack", sendSpeedCheaterBack)
  442. oCopy:SetAttribute("flyCheatDetectionEnabled", flyCheatDetectionEnabled)
  443. oCopy:SetAttribute("debugFlyCheatDetection", debugFlyCheatDetection)
  444. oCopy:SetAttribute("ignoreClimbing", ignoreClimbing)
  445. oCopy:SetAttribute("ignoreSwimming", ignoreSwimming)
  446. oCopy:SetAttribute("maxGroundDistance", maxGroundDistance)
  447. oCopy:SetAttribute("maxRadiusToObjectDistance", maxRadiusToObjectDistance)
  448. oCopy:SetAttribute("boostFloatingDistanceScan", boostFloatingDistanceScan)
  449. oCopy:SetAttribute("maxMovingFloatTime", maxMovingFloatTime)
  450. oCopy:SetAttribute("iDownDirection", iDownDirection)
  451. oCopy:SetAttribute("minimumLinearVelocity", minimumLinearVelocity)
  452. oCopy:SetAttribute("maxFlyCheatDetects", maxFlyCheatDetects)
  453. oCopy:SetAttribute("recordFlyGroundPosition", recordFlyGroundPosition)
  454. oCopy:SetAttribute("sendFlyCheaterToGround", sendFlyCheaterToGround)
  455. oCopy:SetAttribute("teleportCheatDetectionEnabled", teleportCheatDetectionEnabled)
  456. oCopy:SetAttribute("debugTeleportCheatDetection", debugTeleportCheatDetection)
  457. oCopy:SetAttribute("maxLongRangeTeleport", maxLongRangeTeleport)
  458. oCopy:SetAttribute("maxShortRangeTeleport", maxShortRangeTeleport)
  459. oCopy:SetAttribute("ignoreTeleportOtherPlayers", ignoreTeleportOtherPlayers)
  460. oCopy:SetAttribute("ignoreTeleportExceptionModels", ignoreTeleportExceptionModels)
  461. oCopy:SetAttribute("sendTeleportCheaterBack", sendTeleportCheaterBack)
  462. oCopy:SetAttribute("jumpCheatDetectionEnabled", jumpCheatDetectionEnabled)
  463. oCopy:SetAttribute("debugJumpCheatDetection", debugJumpCheatDetection)
  464. oCopy:SetAttribute("iJumpDownDirection", iJumpDownDirection)
  465. oCopy:SetAttribute("iJumpMovement", iJumpMovement)
  466. oCopy:SetAttribute("maxPlayerJumpPower", maxPlayerJumpPower)
  467. oCopy:SetAttribute("maxJumpGroundDistance", maxJumpGroundDistance)
  468. oCopy:SetAttribute("ignoreJumpClimbing", ignoreJumpClimbing)
  469. oCopy:SetAttribute("ignoreJumpSwimming", ignoreJumpSwimming)
  470. oCopy:SetAttribute("stopJumpCheater", stopJumpCheater)
  471. oCopy:SetAttribute("debugGUITextColor", debugGUITextColor)
  472. oCopy:SetAttribute("debugGUITextSize", debugGUITextSize)
  473. oCopy:SetAttribute("debugGUISizeX", debugGUISizeX)
  474. oCopy:SetAttribute("debugGUISizeY", debugGUISizeY)
  475. task.wait()
  476.  
  477. -- Enable Service
  478. oCopy.Enabled = true
  479. task.wait()
  480.  
  481. -- Remove This Setup Object From Memory, We Are Done :)
  482. script.Parent:Destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement