• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Optional Pvp Script[s]

I know THAT
but I said it because it gives less lag to the OT because there will not be LIVE queries each time(many times) a player is attacked. You know that many SQL queries can lag the ot. But with storage is different. The data is already loaded, so there won't be live queries with getPlayerStorageValue, unless I'm wrong. I know that because I tested it with global storage values.

In all honesty, Its not like it causes SUPERMONSTEROUS lag anyways, I have an OT with 180 players regularly (mainly war server) and it doesnt lag due to the sql querys.
 
Now you just have to make a function that allows players with PvP mode to walk through Non-PvPers

Ain't there already something existing allowing players to walk through players below protection level? Shouldn't be hard to edit it to fit these scripts! :D
 
Error:
the following errors have occurred:
Please select valid town.
this error fixed but:


edit: on tfs 0.4
[Warning - Event::loadScript] Event onAttack not found (data/creaturescripts/scripts/pvp.lua)
 
Last edited:
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.

2uqk851.jpg


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.

Very nice but
Creaturescripts.xml
Code:
<event type="attack" name="PvP" event="script" value="pvp.lua"/>
should be:
Code:
<event type="combat" name="PvP" event="script" value="pvp.lua"/>
huh? :p
 
SQL Query:
Code:
ALTER TABLE players ADD pvp int(11) NOT NULL

It should be:
Code:
ALTER TABLE players ADD pvpmode int(11) NOT NULL
 
i have error:
Code:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\accountmanagement.php on line 791
 
[28/06/2010 01:12:55] [Warning - Event::loadScript] Event onAttack not found (data/creaturescripts/scripts/pvp.lua)
 
Back
Top