• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Hotkey] Spell rune and vials [Help]

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,782
Solutions
25
Reaction score
491
Location
Sweden
Hello! I have a problem...

I want, when shooting runes or using vials, the text that appears, to say

When runes: Using one of 100 spell runes
And when Vials (Mana fluids) Using one of 100 vials

Now I'm not able to fix this myself so I'm turning to you otfans community. Please help me!

In actions.cpp, the function:
PHP:
void Actions::showUseHotkeyMessage(Player* player, Item* item, uint32_t itemCount, uint8_t subType /*=-1*/)
{
	std::stringstream ss;
	std::string itemName;
	const ItemType& it = Item::items[item->getID()];
	
	if(it.isRune()){
		itemName = it.runeName;
	}
	else if(it.isFluidContainer()){
		if(subType != 0){
			if(itemCount == 1){
				itemName = it.name + " of " + Item::items[subType].name;
			}
			else{
				itemName = it.name + "s of " + Item::items[subType].name;
			}
		}
		else{
			itemName = "empty vial";
		}
	}
	else{
		itemName = it.name;
	}
		
	toLowerCaseString(itemName);
	
	if(itemCount != 1){
		if(it.isFluidContainer()){
			ss << "Using one of " << itemCount << " " << itemName << "...";
		}
		else{
			ss << "Using one of " << itemCount << " " << itemName << "s...";
		}
	}
	else{
		ss << "Using the last " << itemName << "...";
	}
	
	player->sendTextMessage(MSG_INFO_DESCR, ss.str());
}


And full function (if needed):
PHP:
bool Actions::useItemEx(Player* player, const Position& fromPos, const Position& toPos,
	const unsigned char toStackPos, Item* item, bool isHotkey)
{
	if(OTSYS_TIME() - player->getLastAction() < g_config.getNumber(ConfigManager::MIN_ACTIONTIME)){
		return false;
	}

	Action* action = getAction(item);
	
	if(!action){
		player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
		return false;
	}

	ReturnValue ret = action->canExecuteAction(player, toPos);
	if(ret != RET_NOERROR){
		player->sendCancelMessage(ret);
		return false;
	}

	int32_t fromStackPos = item->getParent()->__getIndexOfThing(item);
	PositionEx fromPosEx(fromPos, fromStackPos);
	PositionEx toPosEx(toPos, toStackPos);

	if(isHotkey){
		int32_t subType = -1;
		if(item->hasSubType() && !item->isRune()){
			subType = item->getSubType();
		}

		uint32_t itemCount = player->__getItemTypeCount(item->getID(), subType, false);
		if(!action->executeUse(player, item, fromPosEx, toPosEx, true)){
			player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
			return false;
		}

		showUseHotkeyMessage(player, item, itemCount, subType);
	}
	else{
		if(!action->executeUse(player, item, fromPosEx, toPosEx, true)){
			player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
			return false;
		}
	}

	player->setLastAction(OTSYS_TIME());
	return true;
}

void Actions::showUseHotkeyMessage(Player* player, Item* item, uint32_t itemCount, uint8_t subType /*=-1*/)
{
	std::stringstream ss;
	std::string itemName;
	const ItemType& it = Item::items[item->getID()];
	
	if(it.isRune()){
		itemName = it.runeName;
	}
	else if(it.isFluidContainer()){
		if(subType != 0){
			if(itemCount == 1){
				itemName = it.name + " of " + Item::items[subType].name;
			}
			else{
				itemName = it.name + "s of " + Item::items[subType].name;
			}
		}
		else{
			itemName = "empty vial";
		}
	}
	else{
		itemName = it.name;
	}
		
	toLowerCaseString(itemName);
	
	if(itemCount != 1){
		if(it.isFluidContainer()){
			ss << "Using one of " << itemCount << " " << itemName << "...";
		}
		else{
			ss << "Using one of " << itemCount << " " << itemName << "s...";
		}
	}
	else{
		ss << "Using the last " << itemName << "...";
	}
	
	player->sendTextMessage(MSG_INFO_DESCR, ss.str());
}

Thanks!
 
Why would I want to insert it? I need to edit it and I don't know how. And what do mean with "No otfans community?"
 
Back
Top