• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature PvP Enabled/Disabled

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Reaction score
7
Location
London, Ontario
Well, this is just a very simple code I implemented to my server a while back and I no longer use. Before everyone says anything, I got the idea from Unline but made it after I realized Azi's did not show it on the characters name. Uhm, alright, here goes:

Note: Make sure you are not using storage value 2000

Combat.cpp:
Under -
Code:
	if(target->getLevel() < protectionLevel || attacker->getLevel() < protectionLevel)
		return true;

Add -
Code:
	std::string tar;
        target->getStorage(2000, tar);
        int32_t targ = atoi(tar.c_str());

        std::string at; 
        attacker->getStorage(2000, at);
        int32_t att = atoi(at.c_str());
 
	if(targ == 1 || att == 1)
                return true;

Player.cpp:
Under -
Code:
	if(guildId)
	{
		if(lookDistance == -1)
			s << " You are ";
		else
			s << " " << (sex % 2 ? "He" : "She") << " is ";

		s << (rankName.empty() ? "a member" : rankName)<< " of the " << guildName;
		if(!guildNick.empty())
			s << " (" << guildNick << ")";

		s << ".";
	}

Add -
Code:
	if(!hasCustomFlag(PlayerCustomFlag_HideLevel))
	{                                          
		std::string strValue;
		getStorage(2000, strValue);
		int32_t value = atoi(strValue.c_str());
		s << (value == 2 ? " (PvP Enabled)" : " (PvP Disabled)");
	}

Basically this shows on the persons name (PvP Disabled) or (PvP Enabled) and it works in game with the storage value 2000

2000 - 1 Disabled
2000 - 2 Enabled

Credits:
Coding - Me
Idea - Unline and Azi
 
hmm what returns getStorage when storage is empty?
if it works like in lua(it have to because lua function is based on this one xd) anything other than 1 will allow to fight right?

btw nice, maybe I'll use it, I'm not sure
 
hmm what returns getStorage when storage is empty?
if it works like in lua(it have to because lua function is based on this one xd) anything other than 1 will allow to fight right?

btw nice, maybe I'll use it, I'm not sure

If the value is 2, it can fight, if the value is: -1, 0, 1 or anything above 2 it will mark them as PvP-Disabled
 
displaying part for sure, but this
Code:
if(targ == 1 || att == 1)
                return true;
looks like you will be able to fight if value differ from 1, have to check I think(but it HAVE to work this way or I'm total dumb)
If I'm right you should change displaying part to if !=1 instead of ==2
 
displaying part for sure, but this
Code:
if(targ == 1 || att == 1)
                return true;
looks like you will be able to fight if value differ from 1, have to check I think(but it HAVE to work this way or I'm total dumb)
If I'm right you should change displaying part to if !=1 instead of ==2

Nah, I have been using it for over a year now. the targ == 1 || att == 1 is for protection, not for attacking.
 
Wait, explain a little lol.What will be wrong with the summons? Can they atk a player? if he is disabled? Or what? Explain please.
 
Wait, explain a little lol.What will be wrong with the summons? Can they atk a player? if he is disabled? Or what? Explain please.

No the summon will not be able to hurt the player. It basically works the exact same way that the protection level works, it is just a variable of it's own where if the protection level is 50, and the persons level is 150 and they have Pvp disabled, then they will count as though they were in the protection level.
 
well, actually special description is reserved for such a things I think so you can use it
 
it's possible by Lua, I'm using commercial version by Azi, and have many useable functions. : )
 
Last edited:
i'm trying to make a convertion for 0.4; also i need to change it a bit, after changes the code become like that
[CPP]uint32_t protectionLevel = g_config.getNumber(ConfigManager::pROTECTION_LEVEL);
if(target->getLevel() < protectionLevel || attacker->getLevel() < protectionLevel)
return true;

std::string tar;
target->getStorage(50001, tar);
int32_t targ = atoi(tar.c_str());

std::string at;
attacker->getStorage(50001, at);
int32_t att = atoi(at.c_str());

if(targ != att != 7)
return true; [/CPP]

using this one i get this errors compiling;

++.exe -c ../combat.cpp -o obj//combat.o -I"C:/Stian's Repack Dev-Cpp 0.2, 64bit/include" -D__USE_MYSQL__ -D__USE_SQLITE__ -D__ENABLE_SERVER_DIAGNOSTIC__ -O2 -fexpensive-optimizations -O1

../combat.cpp: In static member function 'static bool Combat::isProtected(Player*, Player*)':
../combat.cpp:392: error: invalid conversion from 'int' to 'const char*'

../combat.cpp:392: error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
../combat.cpp:396: error: invalid conversion from 'int' to 'const char*'
../combat.cpp:396: error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'

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

Execution terminated
 
Back
Top