TalkAction !pvp - own world type! : )

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
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:

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
Area spells will affect characters with pvp mode off?
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
it's onCombat, spells too included. ;D
 

darex11

Own Big Server
Joined
Aug 21, 2007
Messages
219
Best answers
0
Reaction score
0
Location
Poland
Hoho nice work. This script is very usefull... Idea like wow ; ]
Azi... good work. We waiting for more sexy scripts; ]
 

Swij

Active Member
Joined
Mar 2, 2009
Messages
120
Best answers
0
Reaction score
28
Location
Sweden, Jönköping
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"
 

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
Hey, make also onLook with "PvP: ON/OFF" tag.
 

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,091
Best answers
0
Reaction score
234
oh my god, no way... you actually made the script ive dreamed about for so long!!!
 

xTremoxx

domasturb(cid, genital)
Joined
Aug 11, 2007
Messages
389
Best answers
0
Reaction score
4
Location
Brazil
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.
 
OP
Azi

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
#up
hehe : P
 
Last edited:

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,091
Best answers
0
Reaction score
234
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.
 

STiX

Intermediate OT User
Joined
Aug 22, 2007
Messages
437
Best answers
0
Reaction score
105
Location
Western Australia
Personally, I'd set some form of exhaust on it.
But nice job regardless.
 

Mummrik

Hey!
Joined
Oct 22, 2007
Messages
680
Best answers
25
Reaction score
108
Location
Sweden
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
 

josejunior23

read&read&read
Joined
Apr 13, 2008
Messages
698
Best answers
0
Reaction score
14
Location
Portugal
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:
Top