• 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]

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,901
Reaction score
26
Location
Canada
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.
 

Attachments

  • Pvp Option Php Scripts.rar
    21.8 KB · Views: 131 · VirusTotal
Nice work! This scrip must taken a while for you to make.
 
You should inform us how to edit actual accountmanagement.php, because some of us has already modified it. Great script.
 
[Warning - Event::loadScript] Event onAttack not found (data/creaturescripts/scripts/pvp.lua)
 
in this case it's better to use a storage value rather than a sql value
less lag, i guess
 
storage values are stored in sql tables :p
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.
 
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.

and you can do that?
 
ofc, just gimme the PHP script
 
I use this same function, but just in-game. At the start players have to walk through a portal. But thanks for the awesome contribution!
 
Back
Top