• 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!

Lua PRISION SYSTEM OT 12.91

nilvagner

Long live the otland.net
Joined
May 3, 2010
Messages
118
Reaction score
3
Location
Brazil
Please! I am in need of a PRISION SYSTEM.
  • With configurable time!
  • With payment of fee to leave

How should it work?
The player kills a creature: CAT or DOG anywhere on the map, then he is trapped for a certain time in THAIS prison.

Thais Prison: 32320 x 32280 x 8

Can you help me?
I thank!
I'm using Canary 12.91
 
Remember to register in creaturescripts

Lua:
local monster = {"dog", "cat"}
local townid = 2 -- Thais?
local time = 60 -- in seconds
local function setMeFree(playerid)
    local player = Player(playerid)
    if not player then
        return print("Prison - Player ".. player:getName() .." is not Online. Skipping exit prison.")
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL,  "You are free!")
    player:teleportTo(Town(townid):getTemplePosition())
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

   return true
end


function onKill(player, target)
    if not isInArray(monster, target:getName():lower()) then
        return true
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL, "This is your prison now and I'll close the portal to no human comes to the spirit world!")
    player:teleportTo(Position(32320, 32280, 8))
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    addEvent(setMeFree, time * 1000, player:getId())

    return true
end

I don't know if the code works well, never tested, but the problem is if the player in prision logout then they cannot be set free, maybe if you set with mapediror the area from prison to no logout area, even if they exit they will be teleported to town after the time

The other option is to use a npc to do the exit system, add a storage in player and after that time, they can exit
 
Last edited:
Thanks for the support! In which canary folder should I put it?

C:\CANARY\data-otservbr-global\scripts\movements

?
I'll try!
 
Não consegui amigo, acho que instalei algo errado. No login.lua não sei o que adicionar
 

Attachments

Last edited:
Não consegui amigo, acho que instalei algo errado. No login.lua não sei o que adicionar
No arquivo XML
XML:
<event type="onkill" name="PlayerPrision" script="prision.lua" />

Cria um arquivo chamado ou renomeia para prision.lua o arquivo com o script já existente.

Em login.lua poem

Lua:
player:registerEvent("PlayerPrision")
 
boa noite!
Então.... essa linha eu adiciono onde?
<event type="onkill" name="PlayerPrision" script="prision.lua" />

* Não tem mais xml, no creaturescripts
 
Last edited:
@nilvagner
Data/scripts/creaturescripts cria um arquivo qualquer .lua e adiciona o código abaixo, depois só testar

/told where to put the script and converted to revscript

*can do a login check to set player free from prison using this script preventing player to be stuck in prision if logout

'Storage < time.os()'

Lua:
local monster = {"dog", "cat"}
local townid = 2 -- Thais?
local time = 60 -- in seconds
local function setMeFree(playerid)
    local player = Player(playerid)
    if not player then
        return print("Prison - Player ".. player:getName() .." is not Online. Skipping exit prison.")
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are free!")
    player:teleportTo(Town(townid):getTemplePosition())
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

   return true
end

local prisonTeleport = CreatureEvent("PrisonTeleport")
function prisonTeleport.onKill(player, target)
    if not isInArray(monster, target:getName():lower()) then
        return true
    end

    player:sendTextMessage(MESSAGE_STATUS_SMALL, "This is your prison now and I'll close the portal to no human comes to the spirit world!")
    player:teleportTo(Position(32320, 32280, 8))
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    addEvent(setMeFree, time * 1000, player:getId())

    return true
end
prisonTeleport:register()


local loginPrison = CreatureEvent("LoginPrison")
function loginPrison.onLogin(player)
    player:registerEvent("PrisonTeleport")
    return true
end
loginPrison:register()
 
Last edited:
Thanks my dear!

I did it like this:

1 - added in: \login_events.lua
"PlayerPrision",

2 - added in: \creaturescripts
the file: prison.lua

Lua:
local monster = {"dog", "cat"}
local townid = 8 -- Thais
local time = 60 -- in seconds
local function setMeFree(playerid)
    local player = Player(playerid)
    if not player then
        return print("Prison - Player ".. player:getName() .." is not Online. Skipping exit prison.")
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Now you are free. Remember, don't kill domestic animals!")
    player:teleportTo(Town(townid):getTemplePosition())
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

   return true
end

local prisonTeleport = CreatureEvent("PrisonTeleport")
function prisonTeleport.onKill(player, target)
    if not isInArray(monster, target:getName():lower()) then
        return true
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This is your prison now, for your violence against domestic animals!")
    player:teleportTo(Position(32320, 32280, 8))
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    addEvent(setMeFree, time * 1000, player:getId())

    return true
end
prisonTeleport:register()


local loginPrison = CreatureEvent("LoginPrison")
function loginPrison.onLogin(player)
    player:registerEvent("PrisonTeleport")
    return true
end
loginPrison:register()


Details:

These messages worked:

"This is your prison now, for your violence against domestic animals!"
"Now you are free. Remember, don't kill domestic animals!"

This message was not shown:

"Prison - Player ".. player:getName() .." is not Online. Skipping exit prison."

Thank you for everything!
mano368
 
Thanks my dear!

I did it like this:

1 - added in: \login_events.lua
"PlayerPrision",

2 - added in: \creaturescripts
the file: prison.lua

Lua:
local monster = {"dog", "cat"}
local townid = 8 -- Thais
local time = 60 -- in seconds
local function setMeFree(playerid)
    local player = Player(playerid)
    if not player then
        return print("Prison - Player ".. player:getName() .." is not Online. Skipping exit prison.")
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Now you are free. Remember, don't kill domestic animals!")
    player:teleportTo(Town(townid):getTemplePosition())
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

   return true
end

local prisonTeleport = CreatureEvent("PrisonTeleport")
function prisonTeleport.onKill(player, target)
    if not isInArray(monster, target:getName():lower()) then
        return true
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This is your prison now, for your violence against domestic animals!")
    player:teleportTo(Position(32320, 32280, 8))
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    addEvent(setMeFree, time * 1000, player:getId())

    return true
end
prisonTeleport:register()


local loginPrison = CreatureEvent("LoginPrison")
function loginPrison.onLogin(player)
    player:registerEvent("PrisonTeleport")
    return true
end
loginPrison:register()


Details:

These messages worked:

"This is your prison now, for your violence against domestic animals!"
"Now you are free. Remember, don't kill domestic animals!"

This message was not shown:

"Prison - Player ".. player:getName() .." is not Online. Skipping exit prison."

Thank you for everything!
mano368
The last msg is a warning to you that the player is not Online, msg show in the server log, I only add that to u know that player has logout in the prison and u need to remove him by yourself

To prevent player to logout, use mapeditor and add flag in the area to "no logout area", that will prevent player to logout(even if exit client) and be stuck in prison.

Also, remove from login_events what have you done, the script that I give you, already register the event on login in line 34
 
Back
Top