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
ALTER TABLE `players` ADD `pvpmode` BOOL NOT NULL ;
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 end
data/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 end
talkactions.xml
<talkaction log="no" words="!pvp" access="0" event="script" value="pvpmode.lua">
login.lua
registerCreatureEvent(cid, "PVPMode")
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 end
creaturescripts.xml
<event type="combat" name="PVPMode" event="script" value="pvpProtection.lua">
</event></talkaction>
Credits
Gevox