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

Feature Level Diference Protection PVP

ravockz

New Member
Joined
Jan 23, 2009
Messages
19
Reaction score
0
Well, its like if i'm 20 lvls different from ya, you can't attack me, it used to exist, since i have a pvp-e i needed it so i make this one, here it goes:

in configmanager.cpp, below:
Code:
m_confNumber[MAX_PLAYER_SUMMONS] = getGlobalNumber(L, "maxPlayerSummons", 2);

add:
Code:
m_confNumber[PROTECT_LEVEL] = getGlobalNumber(L, "leveldiffallowattack", 0);

in configmanager.h, below:
Code:
MAX_PLAYER_SUMMONS,

add:
Code:
PROTECT_LEVEL,

in combat.cpp, below:
Code:
checkZones = true;
			if((g_game.getWorldType() == WORLD_TYPE_NO_PVP && !Combat::isInPvpZone(attacker, target)) ||
				isProtected(const_cast<Player*>(attackerPlayer), const_cast<Player*>(targetPlayer)))
				return RET_YOUMAYNOTATTACKTHISPLAYER;

add:
Code:
//level dif protection by ravock.
		uint32_t plvl = g_config.getNumber(ConfigManager::PROTECT_LEVEL);
		if(plvl != 0)
		{
		if((attackerPlayer->getLevel()) > ((targetPlayer->getLevel()) + (plvl)) || (attackerPlayer->getLevel()) < ((targetPlayer->getLevel()) - (plvl)))
		return RET_YOUMAYNOTATTACKTHISPLAYER;
                 }

c++ part done :thumbup:

now in config.lua anywhere just add:
Code:
	leveldiffallowattack = 0

0 = deactiaved
, and the number you put there will be the difference of lvls to the protection get activated.
Like, if u put 30, a lvl 100 can't attack a lvl 70
^^

cya, i made it in my TFS 0.3b3 sources...
 
Last edited:
yea haha, but i'm tottaly unskilled with lua... i'm old school dude, 7.1 times :D

took me like 1 week to get a dam simple anti-mc code to work on lua, on c++ i did it like 1 day...so i rather stayin on C++ :S
thanks!
 
kool, u even can select pure level diff, and percent diff ^^, i was lookin here, lol i would never do that on lua :p
 
but if I will make it in lua, it will be no possible to attack, but still will be possible to kill with runes? isn't?
 
hello i have problem with one line if((attackerPlayer->getLevel()) > ((targetPlayer->getLevel()) + (plvl)) || (attackerPlayer->getLevel()) < ((targetPlayer->getLevel()) - (plvl)))
Dev-C++ have 3 problems or errors i don't know because i start with c++ features. Kompilator: Default compiler
Building Makefile: "E:\OTS DBM\Osdbo Source\Osdbo 8,54\dev-cpp\Makefile.win"
Wykonywanie make...
make.exe -f "E:\OTS DBM\Osdbo Source\Osdbo 8,54\dev-cpp\Makefile.win" all
g++.exe -c ../combat.cpp -o obj//combat.o -I"C:/The Forgotten Dev-Cpp/include" -D__USE_MYSQL__ -D__USE_SQLITE__ -D__ENABLE_SERVER_DIAGNOSTIC__ -fexpensive-optimizations -O1

../combat.cpp: In static member function `static ReturnValue Combat::canDoCombat(const Creature*, const Creature*)':
../combat.cpp:291: error: `attackerPlayer' was not declared in this scope
../combat.cpp:291: error: `targetPlayer' was not declared in this scope

make.exe: *** [obj//combat.o] Error 1

Wykonanie zakończone
 
Back
Top