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

[C++] Hotkey Equip

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,318
Solutions
35
Reaction score
435
Hey Guys,

Completely lost in C++, can anyone help me out with the source changes needed to enable the Hotkey Equip function?

Thanks for your help!

Engine: TFS 1.1
 
Last edited:
Do you already have the sendPlayerInventory functionallity in your sources? otherwise you'll need that too or the client wont even send the request to equip the items at all.
 
Do you already have the sendPlayerInventory functionallity in your sources? otherwise you'll need that too or the client wont even send the request to equip the items at all.

I only found this in protocolgame.h, not sure if it's what you were referring to exactly.
Code:
//inventory
void sendInventoryItem(slots_t slot, const Item* item);

And then I found it being used in protocolgame.cpp
Code:
sendInventoryItem(CONST_SLOT_HEAD, player->getInventoryItem(CONST_SLOT_HEAD));
sendInventoryItem(CONST_SLOT_NECKLACE, player->getInventoryItem(CONST_SLOT_NECKLACE));
sendInventoryItem(CONST_SLOT_BACKPACK, player->getInventoryItem(CONST_SLOT_BACKPACK));
sendInventoryItem(CONST_SLOT_ARMOR, player->getInventoryItem(CONST_SLOT_ARMOR));
sendInventoryItem(CONST_SLOT_RIGHT, player->getInventoryItem(CONST_SLOT_RIGHT));
sendInventoryItem(CONST_SLOT_LEFT, player->getInventoryItem(CONST_SLOT_LEFT));
sendInventoryItem(CONST_SLOT_LEGS, player->getInventoryItem(CONST_SLOT_LEGS));
sendInventoryItem(CONST_SLOT_FEET, player->getInventoryItem(CONST_SLOT_FEET));
sendInventoryItem(CONST_SLOT_RING, player->getInventoryItem(CONST_SLOT_RING));
sendInventoryItem(CONST_SLOT_AMMO, player->getInventoryItem(CONST_SLOT_AMMO));
 
I'll try to explain it again. There is a packet that gets sent from the server to the client upon login, and every time you make a change to your inventory (e.g, dropping/picking up an item, using an item, moving an item, etc.) This packet contains every item that your player is carrying (equipment and container items), and how many of each object you are carrying.* This packet allows the client to know what items, and how many of said item, your character is carrying so that hotkey equipping can function properly. Without sending this packet to the client, the client will never send anything to the server when you press an equip hotkey because it thinks you're carrying nothing. So, once you get that packet sent to the client you can start receiving hotkey equip packets from the client. The packet only contains the ID of the item to be equipped. It is up to you to code the function(s) in the server that determines whether to equip the item, unequip it, if it's stackable how many of that item to move, etc.

I hope that helps.

*I don't understand why CipSoft doesn't send this packet once upon login, then keep track of your player's items and item counts within the client without the need for this packet to be resent to the client over-and-over, but it is CipSoft and that's how they choose to do it.
 
I'll try to explain it again. There is a packet that gets sent from the server to the client upon login, and every time you make a change to your inventory (e.g, dropping/picking up an item, using an item, moving an item, etc.) This packet contains every item that your player is carrying (equipment and container items), and how many of each object you are carrying.* This packet allows the client to know what items, and how many of said item, your character is carrying so that hotkey equipping can function properly. Without sending this packet to the client, the client will never send anything to the server when you press an equip hotkey because it thinks you're carrying nothing. So, once you get that packet sent to the client you can start receiving hotkey equip packets from the client. The packet only contains the ID of the item to be equipped. It is up to you to code the function(s) in the server that determines whether to equip the item, unequip it, if it's stackable how many of that item to move, etc.

I hope that helps.

*I don't understand why CipSoft doesn't send this packet once upon login, then keep track of your player's items and item counts within the client without the need for this packet to be resent to the client over-and-over, but it is CipSoft and that's how they choose to do it.

I think I understand what you're saying. The reason why I'm struggling however is because I've never written anything in C++ before.
I've only ever made small edits in the sources.

It's like you're explaining something in English but I'm suppose to write and read it in Chinese (c++), that's where my troubles lay at the moment.
So right now I'm spending my time trying to understand exactly what's going in game.cpp, I'm asking myself:
How are the other functions written?
What's happening in this function vs that function?
etc etc

I know being a teacher can be frustrating but bear with me I'll keep trying and I really appreciate the help! :oops:
 
Back
Top