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

Solved getVocation

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello
It's possibly to covert this lua code to C++ code (I'm using sources to TFS 0.3.6pl1):

Code:
if getPlayerVocation(cid) = 9 then
.....
else
.....
end
I mean like this but i dont know that it will works:
Code:
if(getVocation(9))
{
....
}
else
{
....
}

Rep++ and Thx for help :thumbup:
 
Last edited:
But I mean that use function getPlayerVocation(cid) in C++ code.
Beacuse i want to make that only knight and elite knight will can use two weapons.
 
if(player->getVocation() == 9)
{

}

?
well, depends where are you're using this, so itcould be this->getVocation() or so
 
just:
Code:
if(player->getVocationId() == 4 || player->getVocationId() == 8)
{
}
or
Code:
switch(player->getVocationId())
{
	case 4:
	case 8:
		..
		break;
}
 
Something is wrong :( when i try to compile.
Code:
In member function 'virtual ReturnValue Player::__queryAdd(int32_t, const Thing*, uint32_t, uint32_t) const': 

'player' was not declared in this scope

*** [obj//player.o] Error 1

What I should to do??
 
Nope I what to make that for e.x knight will be can use two weapons (one weapon in one hand) and I need declarate knight vocationId or Name

Here is code which i want to change:

Code:
		case SLOT_RIGHT:
			if(item->getSlotPosition() & SLOTP_RIGHT)
			{
				//check if we already carry an item in the other hand
				if(item->getSlotPosition() & SLOTP_TWO_HAND)
				{
					if(inventory[SLOT_LEFT] && inventory[SLOT_LEFT] != item)
						ret = RET_BOTHHANDSNEEDTOBEFREE;
					else
						ret = RET_NOERROR;
				}
				else if(inventory[SLOT_LEFT])
				{
					const Item* leftItem = inventory[SLOT_LEFT];
					WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();
					if(leftItem->getSlotPosition() & SLOTP_TWO_HAND)
						ret = RET_DROPTWOHANDEDITEM;
					else if(item == leftItem && count == item->getItemCount())
						ret = RET_NOERROR;
					else if(leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
						ret = RET_CANONLYUSEONESHIELD;
					else if(!leftItem->isWeapon() || !item->isWeapon() ||
						leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO
						|| type == WEAPON_SHIELD || type == WEAPON_AMMO)
						ret = RET_NOERROR;
					[COLOR="Red"]else if(player->getVocationId() == 6 and !leftItem->isWeapon() && !item->isWeapon())
                                                ret = RET_NOERROR;[/COLOR]
					else
						ret = RET_CANONLYUSEONEWEAPON;
				}
				else
					ret = RET_NOERROR;
			}
			break;
		case SLOT_LEFT:
			if(item->getSlotPosition() & SLOTP_LEFT)
			{
				//check if we already carry an item in the other hand
				if(item->getSlotPosition() & SLOTP_TWO_HAND)
				{
					if(inventory[SLOT_RIGHT] && inventory[SLOT_RIGHT] != item)
						ret = RET_BOTHHANDSNEEDTOBEFREE;
					else
						ret = RET_NOERROR;
				}
				else if(inventory[SLOT_RIGHT])
				{
					const Item* rightItem = inventory[SLOT_RIGHT];
					WeaponType_t type = item->getWeaponType(), rightType = rightItem->getWeaponType();
					if(rightItem->getSlotPosition() & SLOTP_TWO_HAND)
						ret = RET_DROPTWOHANDEDITEM;
					else if(item == rightItem && count == item->getItemCount())
						ret = RET_NOERROR;
					else if(rightType == WEAPON_SHIELD && type == WEAPON_SHIELD)
						ret = RET_CANONLYUSEONESHIELD;
					else if(!rightItem->isWeapon() || !item->isWeapon() ||
						rightType == WEAPON_SHIELD || rightType == WEAPON_AMMO
						|| type == WEAPON_SHIELD || type == WEAPON_AMMO)
						ret = RET_NOERROR;
					[COLOR="Red"]else if(player->getVocationId() == 6 and !rightItem->isWeapon() && !item->isWeapon())
                                                ret = RET_NOERROR;[/COLOR]
					else
						ret = RET_CANONLYUSEONEWEAPON;
				}
				else
					ret = RET_NOERROR;
			}
			break;

That what it's red is added by me
 
Back
Top