alkaiq 说:
I just started modding and I have been trying to figure out how to find out the correct <slot_no> of multiplayer players' equipement.
E.g. we all have 4 inventory slots for melee/ranged items. How do I know what is the <slot_no> of a particular item (for example, the most top slot)?
If you are trying to change player equipment while they are spawned into the scene, you need to change the agent's equipment, not the player's: the player object is created when they join the server, and remains to store related data until they disconnect, but the agent object is created only when the visible character is spawned, and is destroyed soon after the character dies (about 30 seconds). To change what the player will have instantly, you need to use the agent_equip_item and agent_unequip_item operations: note that the optional third parameter to the operations (slot number) when equipping weapon items uses different values to the ek_item_* constants noted above, slots 1 - 4 rather than 0 - 3; and armor items are automatically put in the correct slot, but only the stats for combat calculations on the server is updated automatically, so you need to manually send messages to all connected clients to run agent_equip_item to update the visible armor mesh. From memory, I think that if an agent equip slot already has a weapon in it, trying to equip another one on top might do nothing, so you have to unequip it first to replace it.
To make items equipped with agent_equip_item persist into the next round correctly with multiplayer game modes, you would need to carefully check all the scripts and mission template triggers that use player_add_spawn_item to ensure the correct items are kept; I would guess items equipped to the agent would work like for weapons picked up during the round. To get the agent id from the player id, use player_get_agent_id, and then check with agent_is_active to ensure the player is not spectating or just joined (which could cause errors with operations on the returned agent id, if so).