local CATEGORY_NAME = "Chat" 

local lickdelay = 60
local chanceForEffect = 40 // has to be higher than 4 higher = less chance
local maxHeal = 50
local maxDamage = 50
local maxIgniteDuration = 2
local minHeal = 1
local minDamage = 1
local minIgniteDuration = 1


function ulx.lick( calling_ply, target_plys )
local callply = calling_ply
local affected_plys = {}

if (callply.NextLick and callply.NextLick > CurTime()) then

local unroundedtime = callply.NextLick - CurTime()
local timeleft = math.Round(unroundedtime)
ULib.tsayError(callply,"You have to wait "..timeleft.." seconds before licking again!",false)
else

callply.NextLick = CurTime()+lickdelay

for i=1, #target_plys do
local v = target_plys[ i ]

local chances = math.random(0,chanceForEffect)



if chances == 2 then
v:SetVelocity(Vector(0,0,250))
local hp = v:Health()
local heal = math.random(minHeal,maxHeal)
v:SetHealth(hp+heal)
table.insert( affected_plys, v )
ulx.fancyLogAdmin( calling_ply, "#A healed #T by #s with a green tounge",affected_plys, heal)

elseif chances == 3 then
v:SetVelocity(Vector(0,0,250))
local hp = v:Health()
local dam = math.random(minDamage,maxDamage)
v:SetHealth(hp-dam)
table.insert( affected_plys, v )
ulx.fancyLogAdmin( calling_ply, "#A hurt #T by #s whilst licking him/her", affected_plys, dam)

elseif chances == 4 then
v:SetVelocity(Vector(0,0,500))
timeburn = math.random(minIgniteDuration,maxIgniteDuration)
v:Ignite(timeburn,0)
table.insert(affected_plys, v)
ulx.fancyLogAdmin(calling_ply, "#A set #T on fire for #s seconds whilst licking him",affected_plys,timeburn)

else

v:SetVelocity(Vector(0,0,250))
table.insert( affected_plys, v )
ulx.fancyLogAdmin( calling_ply, "#A normally licked #T", affected_plys)
end
end
end
end

local lick = ulx.command( CATEGORY_NAME, "ulx lick", ulx.lick, "!lick" )
lick:addParam{ type=ULib.cmds.PlayersArg, target="!*^" }
lick:addParam{ type=ULib.cmds.BoolArg, invisible=true }
lick:defaultAccess( ULib.ACCESS_ALL )
lick:help( "Licks target(s)." )

