Advertisement
7n6

PKO set maps

7n6
Aug 8th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. MapSets = {
  2.     Maps = { --Maps is the table of maps
  3.         ['map1'] = {
  4.             Fusable = true,
  5.             KickToMap = 'garner',
  6.             Equips = {
  7.                 Head = nil,
  8.                 Armour = {2549,192,2920},
  9.                 Gloves = {2550,1234,678},
  10.                 Boots = {2551},
  11.                 LeftHand = nil,
  12.                 RightHand = nil,
  13.                 LeftRing = {82},
  14.                 RightRing = nil,
  15.                 Necklace =nil,
  16.             }
  17.         },
  18.    
  19.         ['map2'] = {
  20.             Fusable = false,
  21.             KickToMap = 'garner',
  22.             Equips = {
  23.                 Head = nil,
  24.                 Armour = {2549},
  25.                 Gloves = {2550,999},
  26.                 Boots = {2551},
  27.                 LeftHand = nil,
  28.                 RightHand = nil,
  29.                 LeftRing = nil,
  30.                 RightRing = nil,
  31.                 Necklace =nil,
  32.             }
  33.         },
  34.     }
  35. }
  36.  
  37. function MapSets.CheckSet(role,mapname)
  38.     local Equips,Fused = MapSets.GetEquips(role)
  39.     for i,v in pairs(MapSets.Maps[mapname].Equips) do
  40.         if MapSets.InArray(v,Equips[i]) == false and (MapSets.Maps[mapname].Fusable == false or MapSets.InArray(v,Fused[i]) == false )
  41.             return false
  42.         end
  43.     end
  44.     return true
  45. end
  46.  
  47. function MapSets.KickCheater (role)
  48.     local mapname = GetChaMapName(role)
  49.     if MapSets.Maps[mapname] ~= nil then
  50.         if MapSets.CheckSet(role,mapname) == false then
  51.             MoveCity(role,MapSets.Maps[mapname].KickToMap)
  52.             BickerNotice(role,'Do not try to cheat.')
  53.         end
  54.     end
  55. end
  56.  
  57.  
  58. function  MapSets.GetEquips(role)
  59.     return {
  60.         Head = GetItemID(GetEquipItemP(role,0)),
  61.         Armour = GetItemID(GetEquipItemP(role, 2)),
  62.         Gloves = GetItemID(GetEquipItemP(role,3)),
  63.         Boots = GetItemID(GetEquipItemP(role,4)),
  64.         Necklace = GetItemID(GetEquipItemP(role,5)),
  65.         LeftHand = GetItemID(GetEquipItemP(role,6)),
  66.         LeftRing = GetItemID(GetEquipItemP(role,7)),
  67.         RightRing = GetItemID(GetEquipItemP(role,8)),
  68.         RightHand = GetItemID(GetEquipItemP(role,9)),
  69.     },{
  70.         Head = GlowEffects.VerifyApparel(role, 0),
  71.         Armour = GlowEffects.VerifyApparel(role, 2),
  72.         Gloves = GlowEffects.VerifyApparel(role, 3),
  73.         Boots = GlowEffects.VerifyApparel(role, 4),
  74.         Necklace = GlowEffects.VerifyApparel(role, 5),
  75.         LeftHand = GlowEffects.VerifyApparel(role, 6),
  76.         LeftRing = GlowEffects.VerifyApparel(role, 7),
  77.         RightRing = GlowEffects.VerifyApparel(role, 8),
  78.         RightHand = GlowEffects.VerifyApparel(role, 9),
  79.     }
  80. end
  81.  
  82. function MapSets.VerifyApparel(role, slot)
  83.     if GetItemID(GetEquipItemP(role,slot)) == 0 then
  84.         return 0
  85.     else
  86.         return GetItemAttr(GetEquipItemP(role,slot), ITEMATTR_VAL_FUSIONID)
  87.     end
  88. end
  89.  
  90. function MapSets.InArray(array,str)
  91.     for i,v in pairs(array) do
  92.         if v == str then
  93.             return true
  94.         end
  95.     end
  96.     return false
  97. end
  98.  
  99. function MapSets.CreateHooks()
  100.     for i,v in pairs(MapSets.Maps) do
  101.         local oldcheck = _G[string.format("check_can_enter_%s",i)]
  102.         Hook:AddPreHook(string.format("check_can_enter_%s",i),
  103.             function (role, copy_mgr)
  104.                 if oldcheck(role,copy_mgr) ~= 1 or MapSets.CheckSet(role,i) ~= true then
  105.                     SystemNotice(role,'Can not enter the map in those equips.')
  106.                     return 0
  107.                 end
  108.                 return 1
  109.             end
  110.         )
  111.     end
  112.     Hook:AddPreHook("AttrRecheck",MapSets.KickCheater )
  113. end
  114. MapSets.CreateHooks()
  115.  
  116. --MapSet.Maps table contains the info about what equips can be used in what map. Example given is for map1 and map2. Requies Hook. Is untested
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement