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

Nice idea for protection system. Will it work?

Erevius

It Was A Good Day
Joined
Feb 12, 2010
Messages
157
Reaction score
7
Location
Poland/Olsztyn
Hello. I have an interesting idea of a script for low-leveled characters protection.
I want to make (fe.) that a player between 8 and 13lvl, can only attack/be attacked by 8 and 13lvls. When player advance to 14lvl, he can attack/be attacked only by players with lvl from 14 to 20 etc. Please tell me, is that possible to make something like this with creature scripts(or other lua)? Maybe someone would like to write a script like it?
 
This isn't a great script I just wrote it after I read your thread, not tested and its free so be happy :)
There's alot of comments in the script, you can get someone to help you to install it or something if you don't know how.
There's one thing that I thought of after I finished but I'm bout to make hamburgers, you might need to check for summon's AOE.
It's not a huge deal since they can't even target the players but FE's might do some small damage with their AOE.
This also prevents healing out of your threshold, if you need me to I can disable that. Have fun.

LUA:
--LEVEL_THRESHOLD is how many levels your victim can be away from your own level--Example: Threshold of 10 means a player with level 100 can people at level 90 to level 110
local LEVEL_THRESHOLD = 10


local function isPlayerAboveThreshold(cid, target)


	-- This makes sure we are only processing statchanges made by PvP
	if(isPlayer(target))then


		-- We need to get the players levels of course
		local attackerLvl, targetLvl = getPlayerLevel(cid), getPlayerLevel(target)
		
		-- Now we shall check the actual threshold vs. the ideal one
		if(math.abs(attackerLvl - targetLvl) > LEVEL_THRESHOLD)then
		
			-- OMG it's above the limit! We shall report back with what we found!
			return true
			
		end
	end
	
	-- At least one condition was not met. We shall say false!
	return false
end




function onStatsChange(cid, attacker, type, combat, value)
	if(isPlayerAboveThreshold(attacker, cid))then
		return false
	end
	return true
end


function onTarget(cid, target)
	if(isPlayerAboveThreshold(cid, target))then
		return false
	end
	return true
end
 
Back
Top