• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent [BEST] Jail system ! [0.3.6]

Erexo

Kage
Premium User
Joined
Mar 27, 2010
Messages
741
Solutions
5
Reaction score
193
Location
Pr0land
GitHub
Erexo
Hello,
I've made a jail system:

~When you get a RS you go to the jail
~When RS over, you are teleported to the temple
~Thanks to Renusek for help :*

So:

Creaturescripts.xml
XML:
	<event type="think" name="JailByErexo" event="script" value="jail.lua"/>
	<event type="think" name="JailByErexon" event="script" value="jailn.lua"/>



login.lua
Lua:
	registerCreatureEvent(cid, "JailByErexo")
	registerCreatureEvent(cid, "JailByErexon")



jail.lua
Lua:
function onThink(cid, interval)
				rand = math.random(1,4)
		if getCreatureSkullType(cid) == SKULL_RED then
			  if not isInRange(getThingPos(cid), {x = 1102, y = 824, z = 7}, {x = 1151, y= 874, z = 7}) then -- Jail
				if rand == 1 then
                 doTeleportThing(cid, {x = 1143, y = 836, z = 7}, true)  -- First cell
				elseif rand == 2 then
                 doTeleportThing(cid, {x = 1147, y = 851, z = 7}, true) -- Second cell
				elseif rand == 3 then
                 doTeleportThing(cid, {x = 1119, y = 851, z = 7}, true) -- Third cell
				elseif rand == 4 then
                 doTeleportThing(cid, {x = 1132, y = 867, z = 7}, true) -- Fourth cell
				end
			  end
		end
return TRUE
end


jailn.lua
Lua:
function onThink(cid, interval)
	if getPlayerGroupId(cid) <= 2 then  -- GM can "visit" a jail
		if getCreatureSkullType(cid) == SKULL_NONE then
			  if isInRange(getThingPos(cid), {x = 1102, y = 824, z = 7}, {x = 1151, y= 874, z = 7}) then  -- Jail
                 doTeleportThing(cid, {x = 1018, y = 478, z = 6}, true) -- Pos to tel after RS remove
			  end
		end
	end
return TRUE
end


Greetings :)
 
Last edited:
jail.lua
Lua:
local range = { --Jail
    [1] = {x = 1102, y = 824, z = 7},
    [2] = {x = 1151, y= 874, z = 7}
}

local cell = { --Cells
    [1] = {x = 1143, y = 836, z = 7},
    [2] = {x = 1143, y = 836, z = 7},
    [3] = {x = 1119, y = 851, z = 7},
    [4] = {x = 1132, y = 867, z = 7},
}

function onThink(cid, interval)
    local rand = math.random(#cell)
    if getCreatureSkullType(cid) == SKULL_RED then
        if not isInRange(getThingPos(cid), range[1], range[2]) then
            doTeleportThing(cid, cell[rand], true)
        end
    end
    return 1
end
 
Why would you save the red skull player by sending it to jail? Then everyone would make red skull with their players to make sure they are safe. Red skull is there as punishment already as you loose all your equipments when dying - with or without any aol or bless.
 
Can we edit this a bit?
I want if player gets notated, he automatically be teleported to the Jail and to lose 100% experience for this notation, 200% experience for his second notation, and etc..

Jail time is like a few hours.
 
I originally made a post asking for help to get it working in 1.X. In the end I was able to solve it by myself. here the result

Updated for +1.X revscript. I don't know if it is the best way to encode but it is functional


Lua:
local globalEvent = GlobalEvent("jail")

-- Creditos Erexo, hodleo,  https://otland.net/threads/best-jail-system-0-3-6.127751/

local wait_room = {from = Position(54, 178, 8), to = Position(64, 187, 8)}
local cell = { --Cells
    [1] = {x = 56, y = 179, z = 8},
    [2] = {x = 62, y = 179, z = 8},
    [3] = {x = 56, y = 186, z = 8},
    [4] = {x = 62, y = 186, z = 8},
}


function globalEvent.onThink(interval)
for _, player in pairs(Game.getPlayers()) do
if not player then
        return false
    end

local skullTime = player:getSkullTime()
local fragTime = configManager.getNumber(configKeys.FRAG_TIME)
local kills = math.ceil(skullTime / fragTime)

    local rand = math.random(#cell)
    if kills == 21 then
        if not player:getPosition():isInRange(wait_room.from, wait_room.to) then
            player:teleportTo(cell[rand], true)
        end
    end
    return 1
end
end

globalEvent:interval(10000)
globalEvent:register()
 
Last edited:
Back
Top