Tentarei criar o seguinte comando então:
/jail nome,tempo
/unjail nome
Outra coisa, o PVP será aberto na prisão?
Fiz aqui rapidinho sendo que a prisão não é PVP.
Em talkactions, crie um arquivo lua com o nome jail.lua
local posPrison = Position(x,y,z)
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local split = param:split(",")
local preso = (split[1])
local tempo = (split[2])
tempo = tempo * 60 * 24
if not preso then
player:sendCancelMessage("A player with that name is not online.")
return false
end
if not tempo then
player:sendCancelMessage("Insufficient parameters.")
return false
end
if preso:getStorageValue(41234) > os.time() then
player:sendCancelMessage("The player ".. preso .." is already arrested.")
return false
end
if preso and tempo then
preso:setStorageValue(41234, (tempo) + os.time())
preso:getPosition():sendMagicEffect(11)
preso:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You were arrested until ".. tempo .." days.")
preso:teleportTo(posPrison)
posPrison:sendMagicEffect(11)
else
player:sendCancelMessage("You need to inform the player and the time (in days) he will be stuck.")
end
return true
end
Em talkactions, crie um arquivo lua com o nome unjail.lua
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local targetPlayer = Player(param)
if targetPlayer == nil then
return false
end
if not targetPlayer then
player:sendCancelMessage("Insufficient parameters.")
return false
end
if targetPlayer:getStorageValue(41234) <= os.time() then
player:sendCancelMessage("The player ".. targetPlayer .." is already free.")
return false
end
local town = targetPlayer:getTown():getTemplePosition()
if targetPlayer then
targetPlayer:setStorageValue(41234, 0)
targetPlayer:getPosition():sendMagicEffect(11)
targetPlayer:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Congratulations ".. targetPlayer ..", now you are free.")
targetPlayer:teleportTo(town)
else
player:sendCancelMessage("The player is offline.")
end
return true
end
Em talkactions.xml adicione as seguintes tags
<talkaction words="/jail" separator=" " script="jail.lua" />
<talkaction words="/unjail" script="unjail.lua" />
Agora em creaturescript, crie um arquivo chamado unjail.lua
function onLogin(player)
player:registerEvent("unjailLogin")
player:registerEvent("unjailThink")
local town = player:getTown():getTemplePosition()
if player:getStorageValue(41234) > 0 then
player:teleportTo(town)
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Congratulations ".. player ..", now you are free.")
player:getPosition():sendMagicEffect(11)
end
end
function OnThink(creature, interval)
local player = creature:getPlayer()
local town = player:getTown():getTemplePosition()
if player:getStorageValue(41234) > 0 then
player:teleportTo(town)
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Congratulations ".. player ..", now you are free.")
player:getPosition():sendMagicEffect(11)
end
end
Em creaturescript.xml adicione as seguintes tags
<event type="login" name="unjailLogin" script="unjail_creature.lua"/>
<event type="think" name="unjailThink" interval="60" script="unjail_creature.lua"/>
Não é necessário registrar no login.lua
Qualquer erro me avisa aqui que eu tento arrumar pra você.