[PVP-System] Changer 1.0
Versão testada: 8.60 e 9.60 Distro utilizado: TFS 0.4 e TFS 0.2 Comandos: /pvp guild, on/off e /pvp level, 300
Saudações marmanjada, firmeza na tereza? Vim apresentar hoje á vocês um sistema criado por mim, uma ideia bem legal, que seria o jogador escolher quem ele pode atacar, isso por guild e/ou level. Uma solução muito prática para quem não quer atacar amigos ou newbies na war
Vá em (data/talkactions/scripts), crie um arquivo cujo nome seja pvpSys.lua e adicione dentro:
--[[ PVP-System Changer 1.0, criado por Roksas! Acesse já XTIBIA.COM ]]-- function onSay(cid, words, param) local s = string.explode(param, ",") if not s[1] then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Acesso negado. É necessário que informe o tipo de PVP.") and true end --//--// if s[1] == "guild" then if not s[2] then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Acesso negado. Favor informar os parâmetros {on} ou {off}.") and true end if (getPlayerGuildId(cid) < 1) or (not getPlayerGuildId(cid)) then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Acesso negado. Você não pode utilizar este comando, pois não percente á nenhuma guild.") and true end if s[2] == "on" then if getPlayerStorageValue(cid, 21400) >= 1 then return doPlayerSendCancel(cid, "[PVP-System] Acesso negado. Já está ativado o seu Guild PVP.") and true end setPlayerStorageValue(cid, 21400, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Você ativou o Guild PVP, agora não pode atacar players da sua guild.") elseif s[2] == "off" then if getPlayerStorageValue(cid, 21400) < 1 then return doPlayerSendCancel(cid, "[PVP-System] Acesso negado. Já está desativado o seu Guild PVP.") and true end setPlayerStorageValue(cid, 21400, -1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Você desativou o Guild PVP, pode atacar os players de sua guild.") return true end return true end --//--// if s[1] == "level" then if not s[2] then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Acesso negado. Favor informar o level mínimo para atacar.") and true end if tonumber(s[2]) > getPlayerLevel(cid) then return doPlayerSendCancel(cid, "[PVP-System] Acesso negado. Você não pode determinar leveis maiores que o seu.") and true end if getPlayerStorageValue(cid, 21401) == tonumber(s[2]) then return doPlayerSendCancel(cid, "[PVP-System] Acesso negado. Este level já foi determinado antes.") and true end setPlayerStorageValue(cid, 21401, tonumber(s[2])) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[PVP-System] Acesso negado. Você determinou o level mínimo para atacar ["..s[2].."].") return true end --//--// return true end
No arquivo talkactions.xml da pasta (data/talkactions), você deve adicionar a seguinte tag:
<talkaction words="/pvp" event="script" value="pvpSys.lua"/>
Muito bem, esta parte foi a instalação do comando utilizado, agora iremos adicionar ao nosso servidor a parte de hits e target.
Em (creaturescripts/scripts), devemos criar um arquivo com o mesmo nome, no caso, pvpSys.lua e nele, adicionar isto dentro:
function onTarget(cid, target) --//--// if getPlayerStorageValue(cid, 21400) >= 1 then if getPlayerGuildId(cid) == getPlayerGuildId(target) then return doPlayerSendCancel(cid, "[PVP-System] Você não pode atacar jogadores da mesma guild com este PVP ativado.") and false end return false end --//--// if getPlayerStorageValue(cid, 21401) >= getPlayerLevel(target) then return doPlayerSendCancel(cid, "[PVP-System] Acesso negado. Não é possível atacar jogadores com level menor que ["..getPlayerStorageValue(cid, 21401).."].") and false end return true end --//--// function onStatsChange(cid, attacker, type, combat, value) --//--// if type == STATSCHANGE_HEALTHLOSS then if getPlayerStorageValue(attacker, 21400) >= 1 then if getPlayerGuildId(attacker) == getPlayerGuildId(cid) then return false end return false end --//--// if getPlayerStorageValue(attacker, 21401) >= getPlayerLevel(cid) then return false end end return true end --//--//
Na mesma pasta, podemos encontrar o arquivo login.lua, no qual adicionamos estas linhas:
registerCreatureEvent(cid, "pvpAtt") registerCreatureEvent(cid, "pvpStats")
Voltando uma pasta (data/creaturescripts), abriremos o arquivo creaturescripts.xml com algum editor de texto e dentro coloquemos estas tags:
<event type="target" name="pvpAtt" event="script" value="pvpSys.lua"/> <event type="statschange" name="pvpStats" event="script" value="pvpSys.lua"/>
É isto aêe galerinha, espero que tenham gostado e que funcione, qualquer dúvida estou aqui para respondê-los haha.
#Perfect, #GoodLuck.