is_friend = function(c, t)
pk_mode.conf['hook'](c, t)
local cMap,tMap = GetChaMapName(c),GetChaMapName(t)
local cRole,tRole = CheckChaRole(c),CheckChaRole(t)
local cEffect,tEffect = GetChaStateLv ( c , pk_mode.conf['state']),GetChaStateLv ( t , pk_mode.conf['state'] )
local Teammate = is_teammate(c,t)
local cID,tID = GetCharID(c),GetCharID(t)
for i,v in pairs(pk_mode.conf['maps']) do
if cMap == v and tMap == v then
if cRole == 1 and tRole == 1 then
if cEffect == 1 and tEffect == 1 and Teammate == 0 and cID ~= tID then
return pk_mode.conf['on']
else
return pk_mode.conf['off']
end
end
end
end
end
cha_timer = function(r, f, t)
pk_mode.conf['timer'](r, f, t)
local PID = GetCharID(r)
if (file_exists(pk_mode.conf['path']..PID..'.txt') == true) then
AddState(r, r, pk_mode.conf['state'], 1, 3600)
else
if GetChaStateLv(r, pk_mode.conf['state']) ~= 0 then
RemoveState(r, pk_mode.conf['state'])
end
end
end
-- prevents self attack, party attack and reflectin' with main is_friend script.
Handlechat()
cmd.list['pk'] = function(role, param)
if param.n ~= 1 then
BickerNotice(role, 'This command requires an option "ON" OR "OFF"')
return
end
param[1] = tostring(param[1])
param[1] = string.upper(param[1])
if (param[1]) == 'ON' then
local PID = GetCharID(role)
if (file_exists(pk_mode.conf['path']..PID..'.txt') == false) then
BickerNotice(role, 'PK Mode: activated.')
table.save({}, pk_mode.conf['path']..PID..'.txt', 'w')
else
BickerNotice(role, 'PK Mode already activated.')
return
end
elseif (param[1]) == 'OFF' then
local PID = GetCharID(role)
if (file_exists(pk_mode.conf['path']..PID..'.txt') == true) then
BickerNotice(role, 'PK Mode: deactivated.')
os.remove(pk_mode.conf['path']..PID..".txt")
else
BickerNotice(role, 'PK Mode already disabled.')
return
end
else
BickerNotice(role, 'There are TWO options for this command "ON" OR "OFF"!')
return
end
end