Game Development Community

New weapon pick up problem with dedicated server

by Kenan Chabuk · in Torque 3D Professional · 07/30/2010 (8:32 pm) · 7 replies

Torque 1.1 beta 1
I'm having a problem with the player not being able to use weapons. I set the load out so that the player doesn't start with any weapons and added the rocket launcher item to a map. With a dedicated server instance running, if the player runs over the item, the server and client both register the collision, have the item disappear, but the player/client can not equip/use it. When I press 1 (or any number) nothing happens on the client, though in the server console I do get the use command from the client.
It all works fine when not running a dedicated server.

Does anyone else have this problem? Is this a stock problem?

As far as I can tell, the only time the client is told it successfully picks up a weapon is in scripts/server/item.cs , itemData::OnPickup when it messages the client, but that's not an RPC. Maybe the client is supposed to be running the datablock functions of the item pertaining to inventory, but the scripts for them are located only sever side. I did a simple echo test in the itemData pickup function and confirmed it only gets called on the server.

#1
08/02/2010 (11:36 am)
Does the player have the right to use the weapon?

In your player.cs file (game/art/datablocks) under PlayerData(DefaultPlayerData)

Do you have something like...

// Allowable Inventory Items

maxInv[RocketLauncher] = 1;
maxInv[RocketLauncherAmmo] = 20;
maxInv[GrenadeLauncher] = 1;
maxInv[GrenadeLauncherAmmo] = 20;

and have you set this up for any new weapons added?
#2
08/02/2010 (6:41 pm)
Yes, I'm using the RocketLauncher, I have added other weapons also with the necessary additions to the player's datablock. The key here is that I commented out in scripts/server/gameCore.cs under Gamecore::loadout where the server gives a new player starting equipment so that a new player has no starting equipment. The player instead has to go pick up a weapon in the mission, not just ammo.

It works if run not as a dedicated server and client.
#3
08/03/2010 (6:15 pm)
hmmm, not sure... When I get a mo I'll check it out with a fresh build. I currently have a custom player and weapon selection GUI at the start.
#4
10/02/2010 (11:52 am)
Yup, no weapon switching for clients connected to dedicated in 1.1B 2&3 AFAIK. :/
#5
10/03/2010 (9:04 pm)
**Updated after I got home and could look at the script

scripts/server/inventory.cs,
In the function ShapeBase::use,
Line 49 in stock B3,

if ($ZoomOn $= false)
First, $ZoomOn doesn't exist on the server, second you can't be using a global variable for this on the server anyway, and third I don't think there's anything correct about using $= (string ==) for a true/false check. Because it's doing a string check, this will fail if $ZoomOn simply doesn't exist, or in any case other than it having been manually set to 'false'.

You can change it to:
if (!$ZoomOn)
which will allow it to continue doing what it does in singleplayer but effectively remove it from play in multiplayer, or you can remove this if statement entirely since it really isn't appropriate code for multiplayer to begin with.

A more thorough solution would require replacing $ZoomOn with a server-side per-player (or client) variable, but that's a bit excessive for this topic.
#6
10/07/2010 (7:30 pm)
thank you, commenting out the ZoomOn check fixed it!
#7
10/08/2010 (7:07 am)
reported this as a bug here: http://www.torquepowered.com/community/forums/viewthread/121325