Advertisement
zSatan

PK Mode - HandleChat

Mar 13th, 2018
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. --[[
  2.  
  3.     Requeriments:
  4.         1) GameServer.exe with HandleChat(role, message)
  5.         2) Serialize.lua
  6.  
  7.     Installation:
  8.         1) skilleff.txt
  9.             ### PK Mode -1  0   State_None_Add  State_None_Rem  1   0   1   1   1   1   1   1   1   1   1   1   1   1   0   0   0   -1  0   0   0   ### 1   0   0
  10.        
  11.         2) sceneeffectinfo.txt
  12.             ### ispkmod.par PK Mode Sea Wave    0   0   0   -1  0   1.0 0.0 -1.0
  13.            
  14.         3) Change directory parent on path to your desired folder
  15.        
  16.         4) Change state to the skilleff line id
  17. --]]
  18.  
  19. --*-----------------------------------------*--
  20. --* dir parent  : Addon                     *--
  21. --* File name   : PKMode.lua                *--
  22. --* Created by  : Eviles                    *--
  23. --* Discord     : #2759                     *--
  24. --*-----------------------------------------*--
  25. print('* Loading <PKMode> init.lua')
  26.  
  27. pk_mode                     = {}
  28.     pk_mode.conf            = {
  29.         path                = GetResPath('script/addon/ClientInfo/PKMode/'),
  30.         hook                = is_friend,
  31.         timer               = cha_timer,
  32.         maps                = {'garner','magicsea','darkblue'},                    
  33.         state               = 8,                                                   
  34.         on                  = 0,
  35.         off                 = 1
  36.     }
  37.    
  38. is_friend = function(c, t)
  39.     pk_mode.conf['hook'](c, t)
  40.     local cMap,tMap         = GetChaMapName(c),GetChaMapName(t)
  41.     local cPk,tPk           = CheckChaPKState(c),CheckChaPKState(t)
  42.     local cRole,tRole       = CheckChaRole(c),CheckChaRole(t)
  43.     for i,v in pairs(pk_mode.conf['maps']) do
  44.         if cMap == v and tMap == v then
  45.             if cRole == 1 and tRole == 1 then
  46.                 if cPk == 0 or tPk == 0 then
  47.                     return pk_mode.conf['off']
  48.                 else
  49.                     return pk_mode.conf['on']
  50.                 end
  51.             else
  52.                 if cRole == 1 and tRole == 0 then
  53.                     return pk_mode.conf['on']
  54.                 elseif cRole == 0 and tRole == 1 then
  55.                     return pk_mode.conf['on']
  56.                 end
  57.             end
  58.         end
  59.     end
  60.     return pk_mode.conf['off']         
  61. end
  62.  
  63. cha_timer = function(r, f, t)
  64.     pk_mode.conf['timer'](r, f, t)
  65.     local PID               = GetCharID(r)
  66.     local retState          = CheckChaPKState(r)
  67.     if (file_exists(pk_mode.conf['path']..PID..'.txt') == true) then
  68.         if retState == 0 then
  69.             SetPkState(r, pk_mode.conf['off'])     
  70.             AddState(r, r, pk_mode.conf['state'], 1, 3600)
  71.         end
  72.     else
  73.         if GetChaStateLv(r, pk_mode.conf['state']) ~= 0 then
  74.             SetPkState(r, pk_mode.conf['on'])
  75.             RemoveState(r, pk_mode.conf['state'])
  76.         end
  77.     end
  78. end
  79.  
  80. cmd.list['pkon'] = function(r, p)
  81.     local PID               = GetCharID(r)
  82.     if (file_exists(pk_mode.conf['path']..PID..'.txt') == false) then  
  83.         table.save({}, pk_mode.conf['path']..PID..'.txt', 'w')
  84.     else
  85.         BickerNotice(r, 'PK Mode arealdy activated. Use /pkoff to disable it!')
  86.         return
  87.     end
  88. end
  89.  
  90. cmd.list['pkoff'] = function(r, p)
  91.     local PID               = GetCharID(r)
  92.     if (file_exists(pk_mode.conf['path']..PID..'.txt') == true) then   
  93.         os.remove(pk_mode.conf['path']..PID..".txt")
  94.     else
  95.         BickerNotice(r, 'PK Mode arealdy disabled. Use /pkon to enable it!')
  96.         return
  97.     end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement