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

This script is really cool but i don't see any use in this since if players want to BOT they just need to set PVP OFF and their free to bot without any1 killin them xd so i'll not use this. Anyway thanks for uploading ; )
 
Lua:
 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
Freeing after return probably won't work.

Lua:
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")
        result:free()
        return mode
    end
    return FALSE
end
 
Wow, this works so awesome. I love it =) I don't like PVP so my server was NO-PVP but some players wanted PVP. Adding this system fixed the problem.

++Rep
 
[01/07/2009 21:12:47] mysql_real_query(): SELECT `pvpmode` FROM `players` WHERE `name` ='Death's Touch' LIMIT 1; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Touch' LIMIT 1' at line 1 (1064)


Happens when players have a ' in their name. Not sure how to fix this?
 
what if you are in battle and you see that you get owned can you then just do !pvp and it goes off?
 
[01/07/2009 21:12:47] mysql_real_query(): SELECT `pvpmode` FROM `players` WHERE `name` ='Death's Touch' LIMIT 1; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Touch' LIMIT 1' at line 1 (1064)


Happens when players have a ' in their name. Not sure how to fix this?

You have to use escapeString() for name.
 
Using TFS 0.3.4 PL2, I had to change my creaturescripts\scripts\pvpProtection.lua to:

Code:
function onCombat(cid, target)
    if isMonster(target) == TRUE then
        return TRUE
    elseif (getPlayerPVPMode(cid) == 1 and getPlayerPVPMode(target) == 1) or isPlayer(target) == FALSE then
        return TRUE
    else
        doPlayerSendCancel(cid, "You cannot attack players who have PVP mode turned off.")
        return FALSE
    end
end

otherwise, every time a player tried to attack a monster with PVP mode turned on, it would say "Sorry, not possible."

I also changed my functions to:
Code:
function getPlayerPVPMode(uid)
	local result = db.getResult("SELECT `pvpmode` FROM `players` WHERE `id` = " .. getPlayerGUID(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 `id` = " .. getPlayerGUID(uid) .. "  LIMIT 1;")
			return TRUE
		else
			return FALSE
		end
	else
		return FALSE
	end
end
so it will get/set based on the players GUID instead of their name. This prevents my previously posted error message in the console and also I think more error proof (maybe?). Anyways, script works fine after these 2 changes on tfs 0.3.4 pl2
 
I just wonder why u had to use a database to set the PVP mode, can't you use storages??
 
oO I dont know much about scripting, I only know how to read it and understand xD
 
So, how can edit to when a player change to NO-PVP cannot go PVP again?

e.g = player select no-pvp, hunting 3-5h up 20 lvls, change pvp kill some ppl, loss fight, select no-pvp and hunt again...
 
why u using table in db? It can working with storage.. (getPlayerStorageValue(x, y)) ....

Sorry for my bad english
 
someone can make the! pvp when you have a blokeo use for 3 days and so to prevent abuse of the command
 
UPDATE `players` SET `pvpmode` = 1 WHERE `name`='You're Gay' LIMIT 1;

Lua:
function getPlayerPVPMode(cid) return getPlayerStorageValue(cid, 2062) end

function setPlayerPVPMode(cid, value) return setPlayerStorageValue(cid, 2062, tonumber(value)) end
 
Last edited:
Upgrade to 1.x?
Also how about timed effect by using a item?

Use the item and switch to non-pvp mode or enforced/hardcore mode but only for certain time with a script to check the time left
 
Back
Top