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

TalkAction !pvp - own world type! : )

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
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
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")
and add new script in data/creaturescripts/scripts/pvpProtection.lua
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
now in creaturescripts.xml add:
PHP:
<event type="combat" name="PVPMode" event="script" value="pvpProtection.lua" />

and last step... :D
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:
Area spells will affect characters with pvp mode off?
 
Hoho nice work. This script is very usefull... Idea like wow ; ]
Azi... good work. We waiting for more sexy scripts; ]
 
Nice script!
And by the way, you've written "next step is in login.php" i
think it's supposed to bee "next step is in login.lua"
 
Its possible you edit for remove one item? exemple, one player buy item in shop, and go in-game and say !pvp, if player don't have item, say msg i'm sorry, you cant use this command, because you don't have necessary item.
 
Azi, it didnt work on my ot (0.3.4) for some reason. Like i got no errors in the console, but it just didnt work in-game.
 
question does the one that have pvp on get a yellow skull?
It would be good if that is possible (it is possible have heard that talaturen has that for his war system) so if you set your pvp mode on then you get a yellow skull and only players whit pvp mode on should see it
 
Its possible you edit for remove one item? exemple, one player buy item in shop, and go in-game and say !pvp, if player don't have item, say msg i'm sorry, you cant use this command, because you don't have necessary item.

yes.
just added: doPlayerRemoveItem(cid, item, 1)

Lua:
local itemid = 7832

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
        if doPlayerRemoveItem(cid, itemid, 1) == TRUE 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 need a " .. getItemNameById(itemid) .. ".")
        end 		
    else
        doPlayerSendCancel(cid, "You cannot use this command, you don\'t have necessary item OR when you\'re with PZ-Locked.")
    end
    return TRUE
end


EDIT: i still want to know why player can't logout when they have PVP-ON, lawl..
EDIT2: i've fixed the script (onLogout)
 
Last edited:
Back
Top