Game Development Community

Crosshair problem

by AIDan · in Torque Game Engine · 10/16/2001 (8:29 am) · 1 replies

//-----------------------------------------------------------------------------
// Weapon Class
//-----------------------------------------------------------------------------

function Weapon::onUse(%data,%obj)
{
// Default behavoir for all weapons is to mount it into the
// this object's weapon slot, which is currently assumed
// to be slot 0
%obj.mountImage(%data.image, $WeaponSlot);
EgoCrosshair.setbitmap(%data.crosshairFile);
EgoCrosshair.visible= true;
$EgoCrosshairVisibility= true;
}

When you use a weapon, it changes the crosshair to crosshairFile, stored in the weapon datablock.

All works fine.
When I try it on Multiplayer, it seems only to work on the "server player". The other thing is, when another player picks up a weapon, the "server player"'s crosshair changes to the weapon's, the other player picked up.

It seems like I have to include %obj in changing the crosshair.

greetings
Daniel

#1
10/16/2001 (2:48 pm)
The weapons scripts are only executed on the server, not the client. You cannot directly affect a client's interface. The only reason you're see anything is because your hosting the server :)

If you want to change the cursor on the client you would have to send a message to the client, something like this (just an example, may not work as is):
function Weapon::onUse(%data,%obj)
{
   ...
   if (%obj.client)
      commandToClient(%obj.client,'setCrossHair',%data.crossHairFile);
}
You'd have to have the client version of that declared in the client scripts:
function clientCmdSetCrossHair(%file)
{
   EgoCrossHair.setBitmap(%file);
}