I had forgotten this was about the carry capacity. That means Pertex's idea will only work if you have no locked doors in your games, as this needs to work in any room. Try this instead:
if (GetBoolean (player, "immobilized")) {
if (HasString(player, "immobilizedmessage")) {
msg (player.immobilizedmessage)
}
else {
msg ("<br/>You cannot move! <br/>")
}
}
else if (player.maxvolume < ListCount(GetDirectChildren(player))) {
msg ("<br/>{random:You're carrying too much to move!:You're juggling too many items!:You cannot move, things are literally dropping out of your arms with every motion you make!} {once:You'll need to find a container or to drop some of your current items.} <br/>")
}
else if (exit.locked) {
msg (exit.lockmessage)
}
else if (HasScript(exit, "script")) {
do (exit, "script")
}
else {
if (exit.lookonly) {
msg ("You can't go there.")
}
else {
player.parent = exit.to
}
}
The important line is this:
else if (player.maxvolume < ListCount(GetDirectChildren(player))) {
It uses the number of direct children, so will include the backpack, but not anything in the backpack. It will also include anything worn. What you could do is create a new function, say called
IsOverLaden, which returns a boolean, true if the player is carrying too much, false otherwise. That line then becomes:
else if (IsOverLaden()) {
You can then fine tune the function how you like. For example, this will include the backpack if it is not worn, but not itf it is, nor anything else worn:
count = 0
foreach (o, GetDirectChildren(player)) {
if (not GetBoolean(o, "worn")) {
count = count + 1
}
}
return (count > player.maxvolume)