RO
sistema

[PVP-System] Changer 1.0

Por Roksas, 25 de set. de 2013 em Mods, funções e outros

otserv
tibia
script
5.0 (1)
10
2.9k
RoksasR
25 de setembro de 2013 às 22:32

[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.

 

 

2vkaz2e.jpg

Editado Abril 8 por CyberBot

heviton2H
25 de setembro de 2013 às 22:44

muito bom testando

AlexclusiveA
25 de setembro de 2013 às 23:34

Parabéns Roksas, ótimo script meu jovem!! happy.png

Junior001J
25 de setembro de 2013 às 23:41

Muito Bom mesmo em parabéns.

RoksasR
26 de setembro de 2013 às 12:42

Obrigado galera, gostaria que usassem-o ;d

netoviana1N
28 de setembro de 2013 às 03:58

Cara como faz para desligar o pvp? (desligar)

RoksasR
28 de setembro de 2013 às 10:54

 

/pvp guild, off
/pvp level, 0
VincV
28 de setembro de 2013 às 12:20

só coloca uma linha pro login.lua, se n vai da erro se o cara tenta attacka e nunca tiver usado a talk(o storage vai ser nil)

Editado Setembro 28 por lordbug99

2 meses depois...
LumusL
15 de novembro de 2013 às 23:19

Tem um erro, ao atacar monstros, veja isso aí.

2 anos depois...
19 de julho de 2016 às 20:05

Outro erro, se o player atica o PVP GUILD ON, ele não ataca os players da guild. Até ai tudo nos conformes. Mas também não ataca nenhum outro player, independente do PVP LEVEL estar em 0.

 

Mais uma coisa. Se o player está com o PVP GUILD ativado, e PVP LEVEL em 0, além de ele não atacar NENHUM outro player em TARGET somente, ele pega skull se da uma magia de área, entretanto, sem dar dano a nenhum player em volta.