Postado Maio 17, 2019 6 anos Autor Em 15/05/2019 em 16:46, Dwarfer disse: Primeiramente, tente sempre deixar claro qual a versão da sua distro nos seus tópicos. Espero que a versão que chutei ser a do seu servidor seja a correta. Não estava em casa, então não tive como testar exatamente nada, qualquer problema é só falar. Em data/lib crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto PVP_SYS = { time_pvp_on = {30, "min"}, -- tempo que o player não poderá desativar o comando assim que ativá-lo add_time_by_kill = {20, "min"}, -- tempo adicionado ao matar outro player cost = { to_turn_off = {enabled = true, item = {itemid = 2160, count = 10}}, -- custo para desativar o pvp: enabled = 'true' caso queira cobrar, 'false' para caso não queira cobrar -- itemid -> id do item, count -> quantidade to_turn_on = {enabled = false, item = {itemid = 2160, count = 10}}, -- custo para ativar o pvp, mesma coisa do anterior }, skulls_to_blockoff = {SKULL_WHITE, SKULL_RED, SKULL_BLACK}, -- caso o player esteja com uma dessas skulls, não será permitido desativar o pvp storages = { -- só modifique se necessário pvp_status = 89542, pvp_time = 89543 } } 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end function getPlayerPvpStatus(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) end function isPlayerPvpON(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 2 end function isPlayerPvpOFF(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 1 end Os campos que têm tempo você pode configurá-los como quiser. Os valores possíveis seguem os exemplos abaixo: Ex.: {40, "sec"}, {10, "min"}, {2, "hour"}, {1, "day"} Em data/talkactions/scripts crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto function onSay(cid, words, param) local param = param:lower() if not isInArray({"on", "off"}, param) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid command: Use !pvp on or !pvp off") return true end local status = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 1 and "off" or "on" if param == status then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your PvP status is already " .. status:upper() .. ".") return true end if status == "on" then if isInArray(PVP_SYS.skulls_to_blockoff, getCreatureSkullType(cid)) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not turn your PvP off while having a skull.") return true end local check_time = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_time) if check_time > os.time() then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can turn your PvP off only at ".. os.date("%d %B %Y %X", check_time) ..".") return true end local x = PVP_SYS.cost.to_turn_off if x.enabled then if getPlayerItemCount(cid, x.item.itemid) < x.item.count then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. x.item.count .. "x " .. getItemNameById(x.item.itemid) .. " to turn off your PvP status.") return true end doPlayerRemoveItem(cid, x.item.itemid, x.item.count) end doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your PvP status is now OFF!") setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 1) elseif status == "off" then local x = PVP_SYS.cost.to_turn_on if x.enabled then if getPlayerItemCount(cid, x.item.itemid) < x.item.count then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. x.item.count .. "x " .. getItemNameById(x.item.itemid) .. " to turn your PvP status on.") return true end doPlayerRemoveItem(cid, x.item.itemid, x.item.count) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your PvP status is now ON!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your PvP status will remain activated during ".. getStrTime(PVP_SYS.time_pvp_on) ..".") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 2) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_time, mathtime(PVP_SYS.time_pvp_on) + os.time()) end return true end No talkactions.xml, adicione a tag: <talkaction words="!pvp" event="script" value="NOMEDOSEUARQUIVO.lua"/> Em data/creaturescripts/scripts crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto function onLogin(cid) registerCreatureEvent(cid, "PvpSysCombat") registerCreatureEvent(cid, "PvpSysTarget") registerCreatureEvent(cid, "PvpSysLook") registerCreatureEvent(cid, "PvpSysKill") if getPlayerPvpStatus(cid) == -1 then setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 1) end return true end function onCombat(cid, target) if isPlayer(cid) and isPlayer(target) then if isPlayerPvpON(cid) and isPlayerPvpON(target) then return true end return false end return true end function onTarget(cid, target) if isPlayer(cid) and isPlayer(target) then if isPlayerPvpON(cid) and isPlayerPvpON(target) then return true end return false end return true end function onLook(cid, thing, position, lookDistance) if thing.uid == cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'PvP Mode: '.. (isPlayerPvpON(cid) and "[ON]" or "[OFF]")) elseif isPlayer(thing.uid) then doPlayerSetSpecialDescription(thing.uid, '.\nPvP Mode: '.. (isPlayerPvpON(thing.uid) and "[ON]" or "[OFF]")) end return true end function onKill(cid, target) if not isPlayer(cid) or not isPlayer(target) then return true end if isPlayerPvpON(cid) then local current_time = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_time) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_time, mathtime(PVP_SYS.add_time_by_kill) + current_time) end return true end No creaturescripts.xml, adicione as linhas: <event type="target" name="PvpSysTarget" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="combat" name="PvpSysCombat" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="login" name="PvpSysLogin" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="look" name="PvpSysLook" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="kill" name="PvpSysKill" event="script" value="NOMEDOSEUARQUIVO.lua"/> Deixe o servidor como pvp no config.lua. Os comandos para ativar e desativar o pvp são, respectivamente, !pvp on e !pvp off eu não tive tempo de ler tudo ainda, devido a trabalho, no fim de semana eu vou ler a ideia seria tfs1.2 ou OTX, mais a do malucooo não tenho acesso então vamos fazer para distro mais comuns, Dwarfer , inicialmente obrigado e vamos aos trabalhos olhei o código que fez, ficou lindo sim porem pode ser que funcione na distro mais antigas, a funcion OnCombat, onTarget entre outras não estão presente na creaturescripts tentei mudar colocando no EVENTS-PLAYER.LUA onde ela tem porem obtive o resultado estranhos um deles foi a formação do look, o modo pvp nao testei se tava 100% pq tava solo no servidor estou usando a TFS1.2 Editado Maio 18, 2019 6 anos por granoob (veja o histórico de edições)
Postado Fevereiro 2, 2023 2 anos Em 17/05/2019 em 07:12, granoob disse: eu não tive tempo de ler tudo ainda, devido a trabalho, no fim de semana eu vou ler a ideia seria tfs1.2 ou OTX, mais a do malucooo não tenho acesso então vamos fazer para distro mais comuns, Dwarfer , inicialmente obrigado e vamos aos trabalhos olhei o código que fez, ficou lindo sim porem pode ser que funcione na distro mais antigas, a funcion OnCombat, onTarget entre outras não estão presente na creaturescripts tentei mudar colocando no EVENTS-PLAYER.LUA onde ela tem porem obtive o resultado estranhos um deles foi a formação do look, o modo pvp nao testei se tava 100% pq tava solo no servidor estou usando a TFS1.2 Em 15/05/2019 em 16:46, Dwarfer disse: Primeiramente, tente sempre deixar claro qual a versão da sua distro nos seus tópicos. Espero que a versão que chutei ser a do seu servidor seja a correta. Não estava em casa, então não tive como testar exatamente nada, qualquer problema é só falar. Em data/lib crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto PVP_SYS = { time_pvp_on = {30, "min"}, -- tempo que o player não poderá desativar o comando assim que ativá-lo add_time_by_kill = {20, "min"}, -- tempo adicionado ao matar outro player cost = { to_turn_off = {enabled = true, item = {itemid = 2160, count = 10}}, -- custo para desativar o pvp: enabled = 'true' caso queira cobrar, 'false' para caso não queira cobrar -- itemid -> id do item, count -> quantidade to_turn_on = {enabled = false, item = {itemid = 2160, count = 10}}, -- custo para ativar o pvp, mesma coisa do anterior }, skulls_to_blockoff = {SKULL_WHITE, SKULL_RED, SKULL_BLACK}, -- caso o player esteja com uma dessas skulls, não será permitido desativar o pvp storages = { -- só modifique se necessário pvp_status = 89542, pvp_time = 89543 } } 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end function getPlayerPvpStatus(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) end function isPlayerPvpON(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 2 end function isPlayerPvpOFF(cid) return getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 1 end Os campos que têm tempo você pode configurá-los como quiser. Os valores possíveis seguem os exemplos abaixo: Ex.: {40, "sec"}, {10, "min"}, {2, "hour"}, {1, "day"} Em data/talkactions/scripts crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto function onSay(cid, words, param) local param = param:lower() if not isInArray({"on", "off"}, param) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid command: Use !pvp on or !pvp off") return true end local status = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_status) == 1 and "off" or "on" if param == status then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your PvP status is already " .. status:upper() .. ".") return true end if status == "on" then if isInArray(PVP_SYS.skulls_to_blockoff, getCreatureSkullType(cid)) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not turn your PvP off while having a skull.") return true end local check_time = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_time) if check_time > os.time() then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can turn your PvP off only at ".. os.date("%d %B %Y %X", check_time) ..".") return true end local x = PVP_SYS.cost.to_turn_off if x.enabled then if getPlayerItemCount(cid, x.item.itemid) < x.item.count then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. x.item.count .. "x " .. getItemNameById(x.item.itemid) .. " to turn off your PvP status.") return true end doPlayerRemoveItem(cid, x.item.itemid, x.item.count) end doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your PvP status is now OFF!") setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 1) elseif status == "off" then local x = PVP_SYS.cost.to_turn_on if x.enabled then if getPlayerItemCount(cid, x.item.itemid) < x.item.count then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. x.item.count .. "x " .. getItemNameById(x.item.itemid) .. " to turn your PvP status on.") return true end doPlayerRemoveItem(cid, x.item.itemid, x.item.count) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your PvP status is now ON!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your PvP status will remain activated during ".. getStrTime(PVP_SYS.time_pvp_on) ..".") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 2) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_time, mathtime(PVP_SYS.time_pvp_on) + os.time()) end return true end No talkactions.xml, adicione a tag: <talkaction words="!pvp" event="script" value="NOMEDOSEUARQUIVO.lua"/> Em data/creaturescripts/scripts crie um arquivo.lua e cole isto dentro: Mostrar conteúdo oculto function onLogin(cid) registerCreatureEvent(cid, "PvpSysCombat") registerCreatureEvent(cid, "PvpSysTarget") registerCreatureEvent(cid, "PvpSysLook") registerCreatureEvent(cid, "PvpSysKill") if getPlayerPvpStatus(cid) == -1 then setPlayerStorageValue(cid, PVP_SYS.storages.pvp_status, 1) end return true end function onCombat(cid, target) if isPlayer(cid) and isPlayer(target) then if isPlayerPvpON(cid) and isPlayerPvpON(target) then return true end return false end return true end function onTarget(cid, target) if isPlayer(cid) and isPlayer(target) then if isPlayerPvpON(cid) and isPlayerPvpON(target) then return true end return false end return true end function onLook(cid, thing, position, lookDistance) if thing.uid == cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'PvP Mode: '.. (isPlayerPvpON(cid) and "[ON]" or "[OFF]")) elseif isPlayer(thing.uid) then doPlayerSetSpecialDescription(thing.uid, '.\nPvP Mode: '.. (isPlayerPvpON(thing.uid) and "[ON]" or "[OFF]")) end return true end function onKill(cid, target) if not isPlayer(cid) or not isPlayer(target) then return true end if isPlayerPvpON(cid) then local current_time = getPlayerStorageValue(cid, PVP_SYS.storages.pvp_time) setPlayerStorageValue(cid, PVP_SYS.storages.pvp_time, mathtime(PVP_SYS.add_time_by_kill) + current_time) end return true end No creaturescripts.xml, adicione as linhas: <event type="target" name="PvpSysTarget" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="combat" name="PvpSysCombat" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="login" name="PvpSysLogin" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="look" name="PvpSysLook" event="script" value="NOMEDOSEUARQUIVO.lua"/> <event type="kill" name="PvpSysKill" event="script" value="NOMEDOSEUARQUIVO.lua"/> Deixe o servidor como pvp no config.lua. Os comandos para ativar e desativar o pvp são, respectivamente, !pvp on e !pvp off boa noite meu garoto, primeiramente o script ta lindo demais, se não for pedir muito teria como vc passar ele pra revscripts? e que fosse um npc que fizesse a troca de preferencia, e algum escudo que indicasse que o player estivesse pvp, obrigadooo.
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.