Postado Agosto 11, 2018 6 anos Autor Em 07/08/2018 em 21:27, luangop disse: Não chego nem perto do nível do @Dwarfer pra bolar uma função como aquela mathtime(table)... Mas apenas teste minha versão e me diga se funciona, to só praticando: Mostrar conteúdo oculto local grouprequired = 3 local jailedstoragevalue_time = 1338 local jailedstoragevalue_bool = 9222222 local jailpos = { [1] = {x = 1294, y = 1207, z =5}, [2] = {x = 1294, y = 1216, z =5}, [3] = {x = 1298, y = 1216, z =5}, [4] = {x = 1302, y = 1216, z =5}, [5] = {x = 1306, y = 1207, z =5}, [6] = {x = 1310, y = 1207, z =5}, [7] = {x = 1306, y = 1216, z =5}, [8] = {x = 1310, y = 1216, z =5}, } local unjailpos = { x = 1050, y = 1052, z =7 } jail_list = {} jail_list_work = 0 function checkJailList(param) addEvent(checkJailList, 1000, {}) for targetID,player in ipairs(jail_list) do if isPlayer(player) == TRUE then if getPlayerStorageValue(player, jailedstoragevalue_time) < os.time() then doTeleportThing(player, unjailpos, TRUE) setPlayerStorageValue(player, jailedstoragevalue_time, 0) setPlayerStorageValue(player, jailedstoragevalue_bool, 0) table.remove(jail_list,targetID) doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você saiu da cadeia, tente não fazer coisas malvadas da próxima vez para não ser preso novamente. Cuide-se amigo.') end else table.remove(jail_list,targetID) end end end function onSay(cid, words, param, channel) local t = string.explode(param, ",") if(param == '') or (t[2] == '') or (t[3] == '') or (t[2] and t[2] ~= ("sec" or "min" or "hour" or "day")) or (t[3] and not tonumber(t[3])) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Modo de usar:\n /prender Nick, (sec, min, hour, day), numero\nEx: /prender Fulano, hour, 2\nVai prender por 2 horas.") return true end if jail_list_work == 0 then jail_list_work = addEvent(checkJailList, 1000, {}) end local jail_time = tonumber(t[3]) if t[2] == "sec" then jail_time = jail_time end if t[2] == "min" then jail_time = jail_time*60 end if t[2] == "hour" then jail_time = (jail_time*60)*60 end if t[2] == "day" then jail_time = ((jail_time*60)*60)*24 end local isplayer = getPlayerByName(t[1]) if isPlayer(isplayer) ~= TRUE then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+1)) if isPlayer(isplayer) ~= TRUE then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+2)) if isPlayer(isplayer) ~= TRUE then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+3)) end end end if (words == '!prender' or words == '/prender') then if getPlayerGroupId(cid) >= grouprequired then if isPlayer(isplayer) == TRUE then doTeleportThing(isplayer, jailpos[math.random(#jailpos)], TRUE) setPlayerStorageValue(isplayer, jailedstoragevalue_time, os.time()+jail_time) setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 1) table.insert(jail_list,isplayer) doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você prendeu o player: '.. getCreatureName(isplayer) ..' ate ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (agora é: ' .. os.date("%H:%M:%S", os.time()) .. ').') doPlayerSendTextMessage (isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'Voce foi preso por '.. getCreatureName(cid) ..' ate ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (agora é: ' .. os.date("%H:%M:%S", os.time()) .. ').') else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não existe ou esta offline.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não tem permissão para prender players.") end elseif (words == '!desprender' or words == '/desprender') then if getPlayerGroupId(cid) >= grouprequired then if isPlayer(isplayer) == TRUE then if getPlayerStorageValue(isplayer, jailedstoragevalue_bool) == 1 then doTeleportThing(isplayer, unjailpos, TRUE) setPlayerStorageValue(isplayer, jailedstoragevalue_time, 0) setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 0) table.remove(jail_list,targetID) doPlayerSendTextMessage(isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'O player '.. getCreatureName(cid) ..' te tirou da prisão. Te vejo em breve!!!') doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você tirou da prisão o player: '.. getCreatureName(isplayer) ..'.') else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não está preso.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não existe ou esta offline.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não tem permissão para prender players.") end end return true end Vai usar da seguinte forma: /prender Nick, (sec, min, hour ou day), numero Por exemplo: /prender Fulano, hour, 3 Vai prender o player Fulano por 3 horas. Bom so em segundos que ta funcionado quando tento em minutos ou em horas ou em dias aparece isso aki. https://prnt.sc/kh98de
Postado Agosto 11, 2018 6 anos Em 06/08/2018 em 14:03, Dwarfer disse: Ocultar conteúdo local unit = "min" -- "sec", "min", "hour", "day" grouprequired = 3 jailedstoragevalue_time = 1338 jailedstoragevalue_bool = 9222222 local jailpos = { [1] = {x = 1294, y = 1207, z =5}, [2] = {x = 1294, y = 1216, z =5}, [3] = {x = 1298, y = 1216, z =5}, [4] = {x = 1302, y = 1216, z =5}, [5] = {x = 1306, y = 1207, z =5}, [6] = {x = 1310, y = 1207, z =5}, [7] = {x = 1306, y = 1216, z =5}, [8] = {x = 1310, y = 1216, z =5}, } local unjailpos = { x = 1050, y = 1052, z =7 } jail_list = {} jail_list_work = 0 function checkJailList(param) addEvent(checkJailList, 1000, {}) for targetID, player in ipairs(jail_list) do if isPlayer(player) then if getPlayerStorageValue(player, jailedstoragevalue_time) < os.time() then doTeleportThing(player, unjailpos, TRUE) setPlayerStorageValue(player, jailedstoragevalue_time, 0) setPlayerStorageValue(player, jailedstoragevalue_bool, 0) table.remove(jail_list,targetID) doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você saiu da cadeia, tente não fazer coisas malvadas da próxima vez para não ser preso novamente. Cuide-se amigo.') end else table.remove(jail_list,targetID) end end end function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.") return true end local t = string.explode(param, ",") if jail_list_work == 0 then jail_list_work = addEvent(checkJailList, 1000, {}) end local jail_time = -1 for word in string.gmatch(tostring(t[1]), "(%w+)") do if tostring(tonumber(word)) == word then jail_time = tonumber(word) end end local isplayer = getPlayerByName(t[1]) if not isPlayer(isplayer) then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+1)) if not isPlayer(isplayer) then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+2)) if not isPlayer(isplayer) then isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+3)) end end end local default_jail = unit == "sec" and 30 or 1 if(t[2]) then default_jail = t[2] end if jail_time ~= -1 then jail_time = mathtime({jail_time, unit}) else jail_time = mathtime({default_jail, unit}) end if (words == '!prender' or words == '/prender') then if getPlayerGroupId(cid) >= grouprequired then if isPlayer(isplayer) then doTeleportThing(isplayer, jailpos[math.random(#jailpos)], TRUE) setPlayerStorageValue(isplayer, jailedstoragevalue_time, os.time()+jail_time) setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 1) table.insert(jail_list,isplayer) doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você prendeu o player: '.. getCreatureName(isplayer) ..' ate ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (agora é: ' .. os.date("%H:%M:%S", os.time()) .. ').') doPlayerSendTextMessage (isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'Voce foi preso por '.. getCreatureName(cid) ..' ate ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (agora é: ' .. os.date("%H:%M:%S", os.time()) .. ').') else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não existe ou esta offline.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não tem permissão para prender players.") end elseif (words == '!desprender' or words == '/desprender') then if getPlayerGroupId(cid) >= grouprequired then if isPlayer(isplayer) then if getPlayerStorageValue(isplayer, jailedstoragevalue_bool) == 1 then doTeleportThing(isplayer, unjailpos, TRUE) setPlayerStorageValue(isplayer, jailedstoragevalue_time, 0) setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 0) table.remove(jail_list,targetID) doPlayerSendTextMessage(isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'O player '.. getCreatureName(cid) ..' te tirou da prisão. Te vejo em breve!!!') doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Você tirou da prisão o player: '.. getCreatureName(isplayer) ..'.') else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não está preso.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Este jogador não existe ou esta offline.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não tem permissão para prender players.") end end return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end Edite a unidade do tempo nessa linha como desejar: local unit = "min" -- "sec", "min", "hour", "day" esse seu deu certo , porem pra prender por hora tem que usar /prender nick do player,60 = ai seria 1hora , invez de usar /prender nick , hora,1 um exemplo .. Mais ta file se nao conseguir desse jeito ai , o seu ja deu certo, funciona , minuto , hora, segundo heh
Postado Agosto 11, 2018 6 anos Solução 14 horas atrás, iury alves potter disse: Bom so em segundos que ta funcionado quando tento em minutos ou em horas ou em dias aparece isso aki. https://prnt.sc/kh98de E como exatamente vc ta digitando? pq essa mensagem deve aparecer quando digita errado o comando.. Te ajudei? Clique em Gostei ! ²²²d¬¬b²²² "She's got a smile that it seems to me...." ♪♪
Postado Agosto 11, 2018 6 anos Autor 2 horas atrás, luangop disse: E como exatamente vc ta digitando? pq essa mensagem deve aparecer quando digita errado o comando.. Ja resolvi vlw ai ?
Postado Agosto 14, 2018 6 anos @luangop Em 11/08/2018 em 11:56, luangop disse: E como exatamente vc ta digitando? pq essa mensagem deve aparecer quando digita errado o comando.. mesmo digitando corretamente aparecia aquilo la
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.