Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
By SkyDangerous, 19 de jun. de 2012 in Mods, funções e outros
Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata

Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
é isso que eu vou por depois.
kk', pra nao ficar toda hora trocando.
info
Group: Herói
Joined: 25/10/11
Posts: 2.2k
Reputation: +862
Gender: Masculino
Tibia Character: Sociopata

e.e Muito Bom #@SkyDangerous ![]()
info
Group: Barão
Joined: 18/10/10
Posts: 246
Reputation: +89
Tibia Character: Elite Pamcadaum

Fico bacana Sky, Parabéns REP +;
Tipo, não usa FALSE nem TRUE cara, usa false e true, FALSE e TRUE são macros, não booleanos;
Poe ae um event onAttack também pra não poder atacar o cara, ai só vai previnir que o cara não tome o dano, e tipo a msg você poe só no onAttack, no onCombat não precisa porque se não vai ficar tipo, toda hora que o cara tentar hitar mandando a mensagem, mesmo se tiver sido um ataque em área!
info
Group: Herói
Joined: 20/05/10
Posts: 3.4k
Reputation: +1.5k
Gender: Masculino

fico bom, mas de vez de fazer por db, daria pra fazer por storage...
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata

e.e Muito Bom #@SkyDangerous
Vlw ![]()
Fico bacana Sky, Parabéns REP +;
Tipo, não usa FALSE nem TRUE cara, usa false e true, FALSE e TRUE são macros, não booleanos;
Poe ae um event onAttack também pra não poder atacar o cara, ai só vai previnir que o cara não tome o dano, e tipo a msg você poe só no onAttack, no onCombat não precisa porque se não vai ficar tipo, toda hora que o cara tentar hitar mandando a mensagem, mesmo se tiver sido um ataque em área!
Ok, irei modificar.
Vlw
fico bom, mas de vez de fazer por db, daria pra fazer por storage...
Sim, eu já fiz por storage.. é bem parecido ;D
info
Group: Cavaleiro
Joined: 19/06/11
Posts: 195
Reputation: +14
Tibia Character: Desconhecido

Teria como fazer pra um npc ativar e desativar o PVP? e assim que o player ativasse o PVP ele ganha uma skull amarela?
To com um erro aqui ao adicionar o código no SQL
Error while executing query: Cannot add a NOT NULL column with default value NULL
info
Group: Herói
Joined: 20/05/10
Posts: 3.4k
Reputation: +1.5k
Gender: Masculino

Se eu não me engano tem um bug, porque os dois jogadores tem que ta usando pra não poderem se atacar, ou seja se JOÃO tiver no modo seguro e MARIA não, MARIA ainda vai poder atacar o JOÃO... usa assim:
query:
ALTER TABLE `players` ADD `pvpmode` INT NOT NULL DEFAULT '0'
e script fiz em MODS
PvpMode.xml
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Pvp Mode" version="1.0" author="Gevox" contact="xtibia.com" enabled="yes">
<config name="pvpmode_func"><![CDATA[
function getPlayerPVPMode(cid)
local check = db.getResult("SELECT `pvpmode` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("pvpmode") <= 0 and 0 or check:getDataInt("pvpmode")
end
function setPlayerPVPMode(cid, value)
db.executeQuery("UPDATE `players` SET `pvpmode` = "..value.." WHERE `id` = "..getPlayerGUID(cid))
end
]]></config>
<talkaction words="/pvp;!pvp" event="buffer"><![CDATA[
domodlib('pvpmode_func')
if isPlayerPzLocked(cid) == FALSE and getCreatureSkullType(cid) == SKULL_NONE then
setPlayerPVPMode(cid, getPlayerPVPMode(cid) == 0 and 1 or 0)
doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to "..(getPlayerPVPMode(cid) == 0 and "off" or "on").."!")
else
doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.")
end
return true
]]></talkaction>
<event type="login" name="PvpModeRegister" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "pvpProtection")
return true
end]]></event>
<event type="combat" name="pvpProtection" event="script"><![CDATA[
domodlib('pvpmode_func')
if isPlayer(cid) and isPlayer(target) then
if getPlayerPVPMode(cid) == 1 or getPlayerPVPMode(target) == 1 then
doPlayerSendCancel(cid, "You may not attack this player.")
return false
end
end
return true
]]></event>
</mod>
obs: ainda prefiro fazer por storage
Edited Junho 20 by Vodkart
info
Group: Artesão
Joined: 25/03/12
Posts: 109
Reputation: +4
Tibia Character: Kimera DebochadoOo

O nosso querido jhon992 fez um pra min com stogare como disse o Vodkart eu achei mais pratico.
info
Group: Cavaleiro
Joined: 19/06/11
Posts: 195
Reputation: +14
Tibia Character: Desconhecido

Funcinou tem como assim que o player ativar o PVP ele ganhar uma Yellow Skull?
info
Group: Herói
Joined: 20/05/10
Posts: 3.4k
Reputation: +1.5k
Gender: Masculino

Funcinou tem como assim que o player ativar o PVP ele ganhar uma Yellow Skull?
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Pvp Mode" version="1.0" author="Gevox" contact="xtibia.com" enabled="yes">
<config name="pvpmode_func"><![CDATA[
function getPlayerPVPMode(cid)
local check = db.getResult("SELECT `pvpmode` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("pvpmode") <= 0 and 0 or check:getDataInt("pvpmode")
end
function setPlayerPVPMode(cid, value)
db.executeQuery("UPDATE `players` SET `pvpmode` = "..value.." WHERE `id` = "..getPlayerGUID(cid))
end
]]></config>
<talkaction words="/pvp;!pvp" event="buffer"><![CDATA[
domodlib('pvpmode_func')
if isPlayerPzLocked(cid) == FALSE and isInArray({SKULL_NONE,SKULL_YELLOW}, getCreatureSkullType(cid)) then
setPlayerPVPMode(cid, getPlayerPVPMode(cid) == 0 and 1 or 0)
doCreatureSetSkullType(cid, getPlayerPVPMode(cid) == 1 and 1 or 0)
doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to "..(getPlayerPVPMode(cid) == 0 and "off" or "on").."!")
else
doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.")
end
return true
]]></talkaction>
<event type="login" name="PvpModeRegister" event="script"><![CDATA[
domodlib('pvpmode_func')
function onLogin(cid)
registerCreatureEvent(cid, "pvpProtection")
if getPlayerPVPMode(cid) == 1 then doCreatureSetSkullType(cid, 1) end
return true
end]]></event>
<event type="combat" name="pvpProtection" event="script"><![CDATA[
domodlib('pvpmode_func')
if isPlayer(cid) and isPlayer(target) then
if getPlayerPVPMode(cid) == 1 or getPlayerPVPMode(target) == 1 then
doPlayerSendCancel(cid, "You may not attack this player.")
return false
end
end
return true
]]></event>
</mod>
Edited Junho 20 by Vodkart
info
Group: Cavaleiro
Joined: 19/06/11
Posts: 195
Reputation: +14
Tibia Character: Desconhecido

Outra pergunta tem como fazer isso so que por NPC?
info
Group: Herói
Joined: 20/05/10
Posts: 3.4k
Reputation: +1.5k
Gender: Masculino

óbvio que tem, você diz trocar a talk por npc né.
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata
Função:
Você pode alterar o seu tipo de pvp, utilizando o comando !pvp on, para conseguirem te atacar e !pvp off para não te atacarem
SQL QUERY
em data/lib/function.lua
function getPlayerPVPMode(uid) local result = db.getResult("SELECT `pvpmode` FROM `players` WHERE `name` = '" .. getPlayerName(uid) .. "' LIMIT 1;") if(result:getID() ~= -1) then local mode = result:getDataInt("pvpmode") return mode else return FALSE end result:free() end function setPlayerPVPMode(uid, value) if (value >= 0 and value <= 1) then if isPlayer(uid) == TRUE then db.executeQuery("UPDATE `players` SET `pvpmode` = " .. value .. " WHERE `name`='" .. getPlayerName(uid) .. "' LIMIT 1;") return TRUE else return FALSE end else return FALSE end enddata/talkactions/scripts/pvpmode.lua
function onSay(cid, words, param) local mode = getPlayerPVPMode(cid) if mode == 1 then setMode = 0 else setMode = 1 end if isPlayerPzLocked(cid) == FALSE and getCreatureSkullType(cid) == SKULL_NONE then setPlayerPVPMode(cid, setMode) if setMode == 1 then doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to on!") else doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to off!") end else doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.") end return TRUE endtalkactions.xml
login.lua
data/creaturescripts/scripts/pvpProtection.lua
function onCombat(cid, target) if (getPlayerPVPMode(cid) == 1 and getPlayerPVPMode(target) == 1) or isPlayer(target) == FALSE then return TRUE else doPlayerSendCancel(cid, "You cannot attack players which pvp mode is off.") return FALSE end endcreaturescripts.xml
</event></talkaction>
Credits
Gevox
Edited Junho 19 by SkyDangerous