Faaala galera!!! Bom, vamos lá a mais um script que eu fiz agora a tarde.
Antes de vocês falarem que já existe, eu quero dizer que eu fiz esse script agora a tarde sem nem olhar para os scripts de cadeia já existentes e que só fiz este script, porque um cara da seção de pedidos me pediu ajuda. O script que eu fiz é diferente dos já existentes, porque é possível especificar o tempo e o motivo pelo próprio comando.
Primeira Versão:
Como funciona:
!jail ou /jail: É o comando para prender alguém, deve-se usar nesta sintaxe: !jail Demonbholder, 300, Uso de bot
!unjail ou /unjail: É o comando para soltar alguém já preso, deve-se usar nesta sintaxe: !unjail Demonbholder
/tempo: É o comando para verificar quanto tempo falta para sair da cadeia. Deve-se usar nesta sintaxe: /tempo
Opcional:
!out: É o comando para sair da cadeia quando seu tempo acabar. É opcional pois pode-se usar uma porta para sair. A sintaxe é: !out
Certo, vamos aos scripts.
Talkaction:
saida = "yes" templepos = {x=152, y=50, z=7} jailpos = {x=160, y=50, z=7} function onSay(cid, words, param) if words == "!jail" or words == "/jail" then if getPlayerAccess(cid) > 3 then local par = string.explode(param, ", ") if type(par[1]) == "string" and type(tonumber(par[2])) == "number" and type(par[3]) == "string" then local creat = getCreatureByName(par[1]) if isPlayer(creat) then if getPlayerStorageValue(creat, 17900) - os.time() < 0 then doJail(creat, par[2], jailpos) doPlayerSendTextMessage(creat, 4, "Você foi preso por ".. getCreatureName(cid) ..". Motivo: ".. par[3] .. ".") doPlayerSendTextMessage(cid, 22, "Você prendeu ".. par[1] .. " por ".. par[2] .. " segundos.") doBroadcastMessage("O jogador ".. par[1] .. " foi preso por ".. getCreatureName(cid).. ". Motivo: ".. par[3] .. ".", BroadCast_Type) else doPlayerSendCancel(cid, "Este jogador já esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "São necesários três parâmetros.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não pode executar este comando.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!unjail" or words == "/unjail" then if getPlayerAccess(cid) > 3 then local create = getCreatureByName(param) if isPlayer(create) then if getPlayerStorageValue(create, 17900) - os.time() > 0 then doUnjail(create, templepos) doPlayerSendTextMessage(create, 4, "Você foi solto por ".. getCreatureName(cid) .. ".") doPlayerSendTextMessage(cid, 22, "Você soltou ".. param .. ".") else doPlayerSendCancel(cid, "Este jogador não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não pode executar este comando.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!out" and saida == "yes" then if getPlayerStorageValue(cid, 17900) - os.time() < 1 and getPlayerStorageValue(cid, 17900) ~= -1 then doTeleportThing(cid, templepos) setPlayerStorageValue(cid, 17900, -1) doSendMagicEffect(getCreaturePosition(cid), 49) else doPlayerSendCancel(cid, "Você não está preso ou seu periodo na cadeia ainda não acabou.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "/tempo" then if getPlayerStorageValue(cid, 17900) - os.time() > 0 then doShowTextDialog(cid, 2160, "Faltam ".. os.date("%M", math.floor(getPlayerStorageValue(cid, 17900) - os.time())) .. ":" .. os.date("%S", math.floor(getPlayerStorageValue(cid, 17900) - os.time())) .. " segundos para você sair da cadeia.") else doPlayerSendCancel(cid, "Você não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end end return TRUE end
Configure templepos, jailpos e saida. Deixe yes na saida para deixar usável o comando de !out
OBS: Aconselho não colocar mais de uma hora de prisão, pois eu adicionei uma nova função no comando de /tempo, assim, o comando não funcionará corretamente, pois não retornará o tempo certo. Caso for necessário colocar mais de uma hora, pode colocar, somente o comando que retorna quanto tempo falta para sair da prisão que não retorna um valor correto.
Tag:
<talkaction words="!jail;/jail;!unjail;/unjail;!out;/tempo" script="NomeDoArquivo.lua" />
Opcional: Action door
function onUse(cid, item) local position = {x=156, y=50, z=7} if getPlayerStorageValue(cid, 17900) - os.time() < 1 and getPlayerStorageValue(cid, 17900) ~= -1 then doTeleportThing(cid, position) setPlayerStorageValue(cid, 17900, -1) doSendMagicEffect(getCreaturePosition(cid), 49) else doPlayerSendCancel(cid, "Seu tempo de cadeia ainda não acabou.") doSendMagicEffect(getCreaturePosition(cid), 2) end end
Configure a position que será para onde o player ira quando usar a porta.
Tag:
<action uniqueid="UID" script="NomeDoArquivo.lua" />
OBS: Para adicionar uma porta, adicione ela no map editor e coloque um uniqueid nela. Este uniqueid será o número que deve substituir a palavra UID na tag.
Funções:
function doJail(cid, time, posi) doTeleportThing(cid, posi) doSendMagicEffect(getCreaturePosition(cid), 65) setPlayerStorageValue(cid, 17900, time + os.time()) end function doUnjail(cid, posa) doTeleportThing(cid, posa) doSendMagicEffect(getCreaturePosition(cid), 49) setPlayerStorageValue(cid, 17900, -1) end
Adicione isto em data/lib/functions
Segunda Versão: Fase de Testes
Como funciona:
!jail ou /jail: É o comando para prender alguém e adicionar um valor de fiança para o jogador, deve-se usar nesta sintaxe: !jail Demonbholder, 1000, Uso de bot
!unjail ou /unjail: É o comando para soltar alguém já preso e zerar sua fiança deve-se usar nesta sintaxe: !unjail Demonbholder
!bail ou /bail: Comando para pagar a fiança de alguém. Deve se usar nesta sintaxe: !bail Demonbholder
!pay ou /pay: Comando para pagar sua própria fiança. Deve se usar nesta sintaxe: !pay
!check ou /check: Comando para checar quanto esta sua fiança. Deve se usar nesta sintaxe: !check
!addtime ou /addtime: Comando para adicionar mais ainda na fiança de um jogador. Deve se usar nesta sintaxe: !addtime Demonbholder, 1000
OBS: O comando !addtime só funcionará se este jogador já estiver preso e não tive pago sua fiança ainda.
Opcional:
!out: É o comando para sair da cadeia quando sua fiança for paga. É opcional pois pode-se usar uma porta para sair. A sintaxe é: !out
Talkaction:
saida = "yes" templepos = {x=152, y=50, z=7} jailpos = {x=160, y=50, z=7} function onSay(cid, words, param) if words == "!jail" or words == "/jail" then if getPlayerAccess(cid) > 3 then local par = string.explode(param, ", ") if type(par[1]) == "string" and type(tonumber(par[2])) == "number" and type(par[3]) == "string" then local creat = getCreatureByName(par[1]) if isPlayer(creat) then if getPlayerStorageValue(creat, 17900) <= 0 then doTeleportThing(creat, jailpos) setPlayerStorageValue(creat, 17900, par[2]) doSendMagicEffect(getCreaturePosition(creat), 65) doPlayerSendTextMessage(creat, 4, "Você foi preso por ".. getCreatureName(cid) ..". Motivo: ".. par[3] .. ".") doPlayerSendTextMessage(cid, 22, "Você prendeu ".. par[1] .. ". Valor de finça: ".. par[2] .. ".") doBroadcastMessage("O jogador ".. par[1] .. " foi preso por ".. getCreatureName(cid).. ". Motivo: ".. par[3] .. ".", BroadCast_Type) else doPlayerSendCancel(cid, "Este jogador ainda não pagou sua fiança.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "São necesários três parâmetros.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não pode executar este comando.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!unjail" or words == "/unjail" then if getPlayerAccess(cid) > 3 then local create = getCreatureByName(param) if isPlayer(create) then if getPlayerStorageValue(create, 17900) > 0 then setPlayerStorageValue(create, 17900, 0) doPlayerSendTextMessage(create, 4, "Você foi solto por ".. getCreatureName(cid) .. ".") doPlayerSendTextMessage(cid, 22, "Você soltou ".. param .. ".") else doPlayerSendCancel(cid, "Este jogador não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não pode executar este comando.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!out" and saida == "yes" then if getPlayerStorageValue(cid, 17900) == 0 then setPlayerStorageValue(cid, 17900, -1) doTeleportThing(cid, templepos) doSendMagicEffect(getCreaturePosition(cid), 49) else doPlayerSendCancel(cid, "Você não está preso ou seu periodo na cadeia ainda não acabou.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!bail" or words == "/bail" then local creatu = getCreatureByName(param) if isPlayer(creatu) then if getPlayerStorageValue(creatu, 17900) > 0 then if getPlayerMoney(cid) >= getPlayerStorageValue(creatu, 17900) then doPlayerRemoveMoney(cid, getPlayerStorageValue(creatu, 17900)) setPlayerStorageValue(creatu, 17900, 0) doSendAnimatedText(getCreaturePosition(cid), "Bail pay!", 130) else doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar a fiança deste jogador.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!pay" or words == "/pay" then if getPlayerStorageValue(cid, 17900) > 0 then if getPlayerMoney(cid) >= getPlayerStorageValue(cid, 17900) then doPlayerRemoveMoney(cid, getPlayerStorageValue(cid, 17900)) setPlayerStorageValue(cid, 17900, 0) doSendAnimatedText(getCreaturePosition(cid), "Bail pay!", 130) else doPlayerSendCancel(cid, "Você não tem dinheiro suficiente.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!check" or words == "/check" then if getPlayerStorageValue(cid, 17900) > 0 then doShowTextDialog(cid, 2160, "Sua fiança é ".. getPlayerStorageValue(cid, 17900) ..". ") else doPlayerSendCancel(cid, "Você não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end end if words == "!addtime" or words == "/addtime" then if getPlayerAccess(cid) > 3 then local para = string.explode(param, ", ") if type(para[1]) == "string" and type(tonumber(para[2])) == "number" then local ture = getCreatureByName(para[1]) if isPlayer(ture) then if getPlayerStorageValue(ture, 17900) > 0 then setPlayerStorageValue(ture, 17900, getPlayerStorageValue(ture, 17900) + para[2]) doPlayerSendTextMessage(cid, 22, "Você aumentou a fiança de ".. para[1] .. ".") doPlayerSendTextMessage(ture, 4, "Sua fiança foi aumentada em ".. para[2] .. ".") doSendMagicEffect(getCreaturePosition(ture), 65) else doPlayerSendCancel(cid, "Este jogador não esta preso.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Este jogador não esta online.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "São necessários dois parâmetros.") doSendMagicEffect(getCreaturePosition(cid), 2) end else doPlayerSendCancel(cid, "Você não pode executar este comando.") doSendMagicEffect(getCreaturePosition(cid), 2) end end return TRUE end
Configure templepos, jailpos e saida. Deixe yes na saida para deixar usável o comando de !out
Tag:
<talkaction words="!addtime;/addtime;!jail;/jail;!unjail;/unjail;!out;/tempo;/bail;!bail;!pay;/pay;!check;/check" script="NomeDoArquivo.lua" />
Opcional: Action door
function onUse(cid, item) local position = {x=156, y=50, z=7} if getPlayerStorageValue(cid, 17900) == 0 then doTeleportThing(cid, position) setPlayerStorageValue(cid, 17900, -1) doSendMagicEffect(getCreaturePosition(cid), 49) else doPlayerSendCancel(cid, "Seu tempo de cadeia ainda não acabou.") doSendMagicEffect(getCreaturePosition(cid), 2) end end
Tag:
<action uniqueid="UID" script="NomeDoArquivo.lua" />
OBS: Para adicionar uma porta, adicione ela no map editor e coloque um uniqueid nela. Este uniqueid será o número que deve substituir a palavra UID na tag.
O que mudou:
Na primeira versão a cadeia é por tempo, e você configura o tempo no próprio comando da talkaction. Na segunda versão a cadeia é por fiança, você estipula um valor de fiança e o jogador não pode sair de lá até ter sua fiança paga, ou ele mesmo pagar sua própria fiança.
Mais algumas informações de rotina:
Servidor Testado: New Styller Yourots 0.7.5
Acho que é isso, se tiver algum erro se manifestem, até mais.