Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Instructions:
- Edit AntiSkillCheat.SavePath to the folder you wish the saves to go to.
- Edit AntiSkillCheat.PunishMap to be the map you are using as a prison (cheaters are sent here)
- Edit AntiSkillCheat.InvalidSkills to be a table with the indexes being skillID, and the value being the max level.
- Any skill not added to this table, the max level will be treated as 10.
- Edit AntiSkillCheat.SkillRecored to be a table with the indexes being skillID, and the value being true or false.
- All ID not listed are counted as false.
- If set to true, the players skill level will be checked against a file. If it doesnt match, the player is sent to jail.
- Only use this for skills the player can not manually level, eg RB skills, poss.
- You must edit your files to record the levels.
- Find where the skill is added, and add:
- AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
- Where skillID is the ID off the skill, lvl is the level added, and role is the player identifier.
- ]]
- AntiSkillCheat = {
- Savepath = GetResPath('script/extension/data/anticheat/'),
- PunishMap = 'Island Prison',
- InvalidSkills = {
- [271] = 0,--Crab binding max level is 0
- [280] = 3,--Fairy Pos skill max level is 3
- [453] = 3, --rb active skills
- [454] = 3, --rb active skills
- [455] = 3, --rb active skills
- [456] = 3, --rb active skills
- [457] = 3, --rb active skills
- [458] = 3, --rb active skills
- [459] = 3,--RB skill max level is 3
- },--All other skills max level is 10, fill out with your skill IDs for other skills you want to limit.
- SkillRecorded = {--skills listed here will be checked against a file.
- [453] = true,
- [454] = true,
- [455] = true,
- [456] = true,
- [457] = true,
- [458] = true,
- [459] = true,
- [280] = true,
- },
- --for these skills, you must record using AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
- --reccomended to use this for skills the player cant manually level
- --eg RB skill, poss, etc
- }
- function AntiSkillCheat.GetSavePath(role)
- local path = string.format('%s%s.txt',AntiSkillCheat.Savepath,GetRoleID(role))
- local Table = io.open(path,"r")
- if Table~=nil then
- io.close(Table)
- else
- table.save({},path,"w")
- end
- return path
- end
- function AntiSkillCheat.PunishPlayer(role)
- --Map names may be different, change to the names in your server files.
- SystemNotice(role,"Cheat Skill Detected.")
- MoveCity(role,AntiSkillCheat.PunishMap)
- LG("AntiCheat",string.format("Player [%s] [%s] was caught with invalid skills.",GetRoleID(role),GetChaDefaultName(role)))
- end
- function AntiSkillCheat.CreateHooks()
- local skillFile = GetResPath("skillinfo.txt")
- local OpenFile = io.open(skillFile)
- while true do
- local line = OpenFile:read()
- if line == nil then
- break
- end
- local strings = split(line,"\t")
- if string.find(strings[1] ,"//") == nil and strings[1] ~= '' and strings[1] ~= nil then --check for comments/blank lines
- if strings[30] ~= "0" or strings[31] ~= "0" then
- --create function to hook onto skill
- local func = function (ignore ,role , lvl2 ,lvl )
- if Is_NormalMonster ( role ) ~= 1 then
- if lvl == nil then
- if AntiSkillCheat.CheckRecordedSkill(role,strings[1],lvl2) == false then
- AntiSkillCheat.PunishPlayer(role)
- elseif lvl2 > 10 or lvl2 > AntiSkillCheat.InvalidSkills[math.floor(strings[1])] then
- AntiSkillCheat.PunishPlayer(role)
- end
- else
- if AntiSkillCheat.CheckRecordedSkill(role,strings[1],lvl) == false then
- AntiSkillCheat.PunishPlayer(role)
- elseif lvl > 10 or lvl > AntiSkillCheat.InvalidSkills[math.floor(strings[1])] then
- AntiSkillCheat.PunishPlayer(role)
- end
- end
- end
- end
- --end function
- if strings[30] ~= "0" then
- Hook:AddPostHook(strings[30],func) --create hooks
- end
- if strings[31] ~= "0" then
- Hook:AddPostHook(strings[31],func) --create hooks
- end
- end
- end
- end
- OpenFile:close()
- end
- AntiSkillCheat.CreateHooks()
- function AntiSkillCheat.CheckRecordedSkill(role,skillID,lvl)
- local skillID = math.floor(skillID)
- if AntiSkillCheat.SkillRecorded[skillID] == true then
- RecordedSkills = table.load(AntiSkillCheat.GetSavePath(role),"r")
- if RecordedSkills[skillID] == nil then
- RecordedSkills[skillID] = 0
- end
- if lvl > RecordedSkills[skillID] then
- return false
- else
- return true
- end
- end
- end
- function AntiSkillCheat.RecordPlayerSkill(role,skillID,lvl)
- RecordedSkills = table.load(AntiSkillCheat.GetSavePath(role),"r")
- RecordedSkills[skillID] = lvl
- table.save(RecordedSkills,AntiSkillCheat.GetSavePath(role),"w")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement