function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2283 then
access = getPlayerAccess(cid)
targetis = topos
targetis.stackpos = 253
target = getThingfromPos(targetis)
if access >= 3 then
slots = {
{y=64, z=0, time=900},
{y=64, z=1, time=1800},
{y=64, z=2, time=3600},
{y=64, z=3, time=7200},
{y=64, z=4, time=14400},
{y=64, z=5, time=21600},
{y=64, z=6, time=32400},
{y=64, z=7, time=43200},
{y=64, z=8, time=57600},
{y=64, z=9, time=72000},
{y=64, z=10, time=86400},
{y=64, z=11, time=129600},
{y=64, z=12, time=172800},
{y=64, z=13, time=259200},
{y=64, z=14, time=345600},
{y=64, z=15, time=432000},
{y=64, z=16, time=604800},
{y=64, z=17, time=864000},
{y=64, z=18, time=1209600},
{y=64, z=19, time=1814400},
{y=10, z=0, time=1}}
jailstatus = getPlayerStorageValue(target.uid,666)
if jailstatus == 1 or jailstatus == -1 then
if getPlayerAccess(target.uid) <= 2 and getPlayerAccess(target.uid) >= 0 then
for i, a in ipairs(slots) do
if (frompos.y == a.y or frompos.y >= 64) and frompos.z == a.z and frompos.x == 65535 then
currenttime = os.time() + (3600 * 6)
outtime = currenttime + a.time
date = os.date("*t",outtime)
name = getPlayerName(target.uid)
jailer = getPlayerName(cid)
doPlayerSendTextMessage(target.uid,22,"You were jailed by "..jailer.." and can leave jail "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.." (CET) by pulling the lever.")
jail = {x=350, y=300, z=7}
doTeleportThing(target.uid,jail)
doSendMagicEffect(topos,14)
doSendMagicEffect(topos,13)
doSendMagicEffect(topos,12)
doSendMagicEffect(topos,11)
doSendMagicEffect(topos,10)
doSendMagicEffect(topos,9)
doSendMagicEffect(topos,8)
doSendMagicEffect(topos,7)
doSendMagicEffect(topos,6)
doSendMagicEffect(topos,5)
doSendMagicEffect(topos,4)
doSendMagicEffect(topos,3)
doSendMagicEffect(topos,2)
doSendMagicEffect(topos,1)
doSendMagicEffect(topos,15)
doPlayerSetMasterPos(target.uid,jail)
setPlayerStorageValue(target.uid,666,2)
setPlayerStorageValue(target.uid,667,outtime)
doPlayerSendTextMessage(cid,22,"You jailed "..name.." and he/she can leave jail "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.." (CET).")
-- Start log
jaillog = "./data/jaillog.txt"
f = assert(io.open(jaillog,"a+"))
datenow = os.date("*t")
newline = "\n"..datenow.day.."."..datenow.month.."."..datenow.year.." "..datenow.hour..":"..datenow.min..":"..datenow.sec.." : "..jailer.." jailed "..name.." and he can leave jail "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.."."
f:write(newline)
f:close(jaillog)
-- End log
end
end
else
doPlayerSendCancel(cid,"You can't jail yourself or anyone else with a higher access.")
end
elseif jailstatus == 2 then
for i, a in ipairs(slots) do
if (frompos.y == a.y or frompos.y >= 64) and frompos.z == a.z and frompos.x == 65535 then
currenttime = os.time() + (3600 * 6)
outtime = currenttime + a.time
date = os.date("*t",outtime)
name = getPlayerName(target.uid)
jailer = getPlayerName(cid)
doPlayerSendTextMessage(target.uid,22,"Your jailtime was changed by "..jailer.." and you can now leave jail "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.." (CET) by pulling the lever.")
setPlayerStorageValue(target.uid,667,outtime)
doPlayerSendTextMessage(cid,22,"You changed/resetted "..name.."'s unjailtime to "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.." (CET).")
-- Start log
jaillogupdate = "./data/jaillogupdate.txt"
f = assert(io.open(jaillogupdate,"a+"))
datenow = os.date("*t")
newline = "\n"..datenow.day.."."..datenow.month.."."..datenow.year.." "..datenow.hour..":"..datenow.min..":"..datenow.sec.." : "..jailer.." changed "..name.."'s jailtime and he can now leave jail "..date.day.."."..date.month.."."..date.year.." at "..date.hour..":"..date.min..":"..date.sec.."."
f:write(newline)
f:close(jaillogupdate)
-- End log
end
end
end
elseif access <= 2 then
doPlayerSendTextMessage(cid,22,"This is a restricted rune.")
doRemoveItem(item.uid,255)
doSendMagicEffect(cid,2)
end
elseif item.uid == 7149 then
jailstatus = getPlayerStorageValue(cid,666)
if jailstatus == 2 then
outdate = getPlayerStorageValue(cid,667)
if outdate ~= nil then
timeleft = outdate - (os.time() + (3600 * 6))
if timeleft < 0 then
home = {x=33, y=100, z=7}
doTeleportThing(cid,home)
doPlayerSendTextMessage(cid,22,"You left jail.")
setPlayerStorageValue(cid,666,1)
setPlayerStorageValue(cid,667,0)
elseif timeleft > 0 then
time = os.date("*t",outdate)
doPlayerSendTextMessage(cid,22,"You can leave jail "..time.day.."."..time.month.."."..time.year.." at "..time.hour..":"..time.min..":"..time.sec.." (CET).")
end
else
doPlayerSendTextMessage(cid,22,"Message a tutor or GM/God to set a jailtime on you.")
end
elseif jailstatus == 1 or jailstatus == -1 then
doPlayerSendTextMessage(cid,22,"Havin' fun?")
end
if item.itemid == 1945 then
doTransformItem(item.uid,item.itemid+1)
elseif item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
end
else
return 0
end
return 1
end