local unjailableGroup = 3
local jailStorage = 100000
local jailTime = 5 -- Minutes, this time will be added upon each jail time e.g player jailed fourth time will have to wait two times longer than the one jailed for the second time.
local teleportTo = { x = 48, y = 48, z = 7 }
local teleportBack = { x = 50, y = 50, z = 7 }
local jailCounter = {
[1] = "first", [2] = "second", [3] = "third", [4] = "fourth",
[5] = "fifth", [6] = "sixth", [7] = "seventh", [8] = "eighth",
[9] = "ninth", [10] = "tenth", [11] = "eleventh", [12] = "twelveth"
}
local function jailPlayer(cid, pos)
pos.stackpos = 255
local target = getThingfromPos(pos)
local pPos = getCreaturePosition(cid)
if isPlayer(target.uid) == TRUE then
if getPlayerGroupId(target.uid) < unjailableGroup then
local function teleportBackF(cid)
return doTeleportThing(target.uid, teleportBack, 0)
end
addEvent(teleportBackF, jailTime * 60000 * getPlayerStorageValue(target.uid, jailStorage), target.uid)
setPlayerStorageValue(target.uid, jailStorage, getPlayerStorageValue(target.uid, jailStorage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getCreatureName(target.uid).." has been jailed for the "..jailCounter[getPlayerStorageValue(target.uid, jailStorage)].." time and will remain in prison for ".. jailTime * getPlayerStorageValue(target.uid, jailStorage) .." minutes.")
doTeleportThing(target.uid, teleportTo, 0)
return LUA_NO_ERROR
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You may not jail this player!")
return LUA_ERROR
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You may jail only players.")
return LUA_ERROR
end
end
function onCastSpell(cid, var)
local pos = variantToPosition(var)
if(pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0) then
return jailPlayer(cid, pos)
end
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return LUA_ERROR
end