Well with some help from syntax and the base code from Azi, I've put together some scripts that will allow you to chose whether you want to be involved in Pvp or Not on one game world.
Functions:
SQL Query:
Creaturescripts.xml
Login.lua
pvp.lua
And you can download the website codes below as the Code was to long to paste here.
Functions:
Lua:
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
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
SQL Query:
Code:
ALTER TABLE players ADD pvp int(11) NOT NULL
Creaturescripts.xml
Code:
<event type="attack" name="PvP" event="script" value="pvp.lua"/>
Login.lua
Lua:
registerCreatureEvent(cid, "PvP")
pvp.lua
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
And you can download the website codes below as the Code was to long to paste here.
Attachments
-
Pvp Option Php Scripts.rar21.8 KB · Views: 131 · VirusTotal