Advertisement
7n6

PKO Anti Skill Cheat

7n6
Aug 16th, 2016
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.76 KB | None | 0 0
  1. --[[
  2.     Instructions:
  3.        
  4.         Edit AntiSkillCheat.SavePath to the folder you wish the saves to go to.
  5.         Edit AntiSkillCheat.PunishMap to be the map you are using as a prison (cheaters are sent here)
  6.         Edit AntiSkillCheat.InvalidSkills to be a table with the indexes being skillID, and the value being the max level.
  7.             Any skill not added to this table, the max level will be treated as 10.
  8.         Edit AntiSkillCheat.SkillRecored to be a table with the indexes being skillID, and the value being true or false.
  9.             All ID not listed are counted as false.
  10.             If set to true, the players skill level will be checked against a file. If it doesnt match, the player is sent to jail.
  11.             Only use this for skills the player can not manually level, eg RB skills, poss.
  12.            
  13.             You must edit your files to record the levels.
  14.             Find where the skill is added, and add:
  15.                 AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
  16.             Where skillID is the ID off the skill, lvl is the level added, and role is the player identifier.
  17.  
  18.  
  19.  
  20.  
  21. ]]
  22. AntiSkillCheat = {
  23.     Savepath = GetResPath('script/extension/data/anticheat/'),
  24.     PunishMap = 'Island Prison',
  25.     InvalidSkills = {
  26.         [271] = 0,--Crab binding max level is 0
  27.         [280] = 3,--Fairy Pos skill max level is 3
  28.         [453] = 3, --rb active skills
  29.         [454] = 3, --rb active skills
  30.         [455] = 3, --rb active skills
  31.         [456] = 3, --rb active skills
  32.         [457] = 3, --rb active skills
  33.         [458] = 3, --rb active skills
  34.         [459] = 3,--RB skill max level is 3
  35.     },--All other skills max level is 10, fill out with your skill IDs for other skills you want to limit.
  36.    
  37.     SkillRecorded = {--skills listed here will be checked against a file.
  38.         [453] = true,
  39.         [454] = true,
  40.         [455] = true,
  41.         [456] = true,
  42.         [457] = true,
  43.         [458] = true,
  44.         [459] = true,
  45.         [280] = true,
  46.     },
  47.     --for these skills, you must record using AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
  48.     --reccomended to use this for skills the player cant manually level
  49.     --eg RB skill, poss, etc
  50. }
  51.  
  52. function AntiSkillCheat.GetSavePath(role)
  53.     local path = string.format('%s%s.txt',AntiSkillCheat.Savepath,GetRoleID(role))
  54.     local Table = io.open(path,"r")
  55.     if Table~=nil then
  56.         io.close(Table)
  57.     else
  58.         table.save({},path,"w")
  59.     end
  60.     return path
  61. end
  62.  
  63. function AntiSkillCheat.PunishPlayer(role)
  64.     --Map names may be different, change to the names in your server files.
  65.     SystemNotice(role,"Cheat Skill Detected.")
  66.     MoveCity(role,AntiSkillCheat.PunishMap)
  67.     LG("AntiCheat",string.format("Player [%s] [%s] was caught with invalid skills.",GetRoleID(role),GetChaDefaultName(role)))
  68. end
  69.  
  70. function AntiSkillCheat.CreateHooks()
  71.     local skillFile = GetResPath("skillinfo.txt")
  72.     local OpenFile = io.open(skillFile)
  73.     while true do
  74.         local line = OpenFile:read()
  75.         if line == nil then
  76.             break
  77.         end
  78.         local strings = split(line,"\t")
  79.         if string.find(strings[1] ,"//") == nil and strings[1] ~= '' and strings[1] ~= nil  then --check for comments/blank lines
  80.             if strings[30] ~= "0" or strings[31] ~= "0"  then
  81.                 --create function to hook onto skill
  82.                 local func = function (ignore ,role , lvl2 ,lvl  )
  83.                     if Is_NormalMonster ( role ) ~= 1 then
  84.                         if lvl == nil then  
  85.                             if AntiSkillCheat.CheckRecordedSkill(role,strings[1],lvl2) == false then
  86.                                 AntiSkillCheat.PunishPlayer(role)
  87.                             elseif lvl2 > 10 or lvl2 > AntiSkillCheat.InvalidSkills[math.floor(strings[1])] then
  88.                                 AntiSkillCheat.PunishPlayer(role)
  89.                             end
  90.                         else
  91.                             if AntiSkillCheat.CheckRecordedSkill(role,strings[1],lvl) == false then
  92.                                 AntiSkillCheat.PunishPlayer(role)
  93.                             elseif lvl > 10 or lvl > AntiSkillCheat.InvalidSkills[math.floor(strings[1])] then
  94.                                 AntiSkillCheat.PunishPlayer(role)
  95.                             end
  96.                         end
  97.                     end
  98.                 end
  99.                 --end function
  100.                if strings[30] ~= "0" then
  101.                    Hook:AddPostHook(strings[30],func)  --create hooks
  102.                end                                    
  103.                if strings[31] ~= "0" then              
  104.                    Hook:AddPostHook(strings[31],func)  --create hooks
  105.                end
  106.            end
  107.         end
  108.     end    
  109.     OpenFile:close()
  110. end
  111. AntiSkillCheat.CreateHooks()
  112.  
  113. function AntiSkillCheat.CheckRecordedSkill(role,skillID,lvl)
  114.     local skillID  = math.floor(skillID)
  115.     if AntiSkillCheat.SkillRecorded[skillID] == true then  
  116.         RecordedSkills = table.load(AntiSkillCheat.GetSavePath(role),"r")
  117.         if RecordedSkills[skillID] == nil then
  118.              RecordedSkills[skillID] = 0
  119.         end
  120.         if lvl > RecordedSkills[skillID] then
  121.             return false
  122.         else
  123.             return true
  124.         end
  125.     end
  126. end
  127.  
  128. function AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
  129.     RecordedSkills = table.load(AntiSkillCheat.GetSavePath(role),"r")
  130.     RecordedSkills[skillID] = lvl
  131.     table.save(RecordedSkills,AntiSkillCheat.GetSavePath(role),"w")
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement