hiho all! : )
It's command !pvp to set own world type, if pvp mode is on - players with pvp mode on can attack you, and you can attack players with pvp mode on, but you cannot attack, and players cannot attack you which have pvp mode set off. ; )
You cannot set pvp off if you have red skull or if be in fight.
Commands:
•!pvp -- set own world type.
first step - add in data/lib/function.lua
second step... ; d - in data/talkactions/scripts/pvpmode.lua past:
and in talkactions.xml add:
But it isn't all... : )
next step is in login.lua
before "return TRUE" add :
and add new script in data/creaturescripts/scripts/pvpProtection.lua
now in creaturescripts.xml add:
and last step...
go to phpmyadmin on localhost, select otserv database and go to tab "SQL" and past in text area:
now restart your OTS, and have fun with new function!
regards,
ersiu.
It's command !pvp to set own world type, if pvp mode is on - players with pvp mode on can attack you, and you can attack players with pvp mode on, but you cannot attack, and players cannot attack you which have pvp mode set off. ; )
You cannot set pvp off if you have red skull or if be in fight.
Commands:
•!pvp -- set own world type.
first step - add in data/lib/function.lua
PHP:
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
second step... ; d - in data/talkactions/scripts/pvpmode.lua past:
PHP:
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
and in talkactions.xml add:
PHP:
<talkaction log="no" words="!pvp" access="0" event="script" value="pvpmode.lua"/>
But it isn't all... : )
next step is in login.lua
before "return TRUE" add :
PHP:
registerCreatureEvent(cid, "PVPMode")
PHP:
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
PHP:
<event type="combat" name="PVPMode" event="script" value="pvpProtection.lua" />
and last step...
go to phpmyadmin on localhost, select otserv database and go to tab "SQL" and past in text area:
PHP:
ALTER TABLE `players` ADD `pvpmode` BOOL NOT NULL ;
now restart your OTS, and have fun with new function!
regards,
ersiu.
Last edited: