Author Topic: Telling a client to select a different item in the tool hud  (Read 718 times)

You can change what tool a client is using just as if they had selected it themselves via calling serverCmdUseTool(), however the client still does not change what tool is shown as being selected in the tool gui.

For example, say I have the wrench selected, and I press my "Inventory Up" remap, I get the following:


But if I have the wrench selected and I call serverCmdUseTool(myClient, 0) I get the following (item selected in the gui not matching the mounted image):


Is there any way to tell the client to update the tool selected in the gui?

I don't know if this will help, but the propane tank forces you to have it wielded.

I don't know if this will help, but the propane tank forces you to have it wielded.
Code: [Select]
function PropaneTankItem::onPickup(%this, %obj, %player)
{
%player.hasepropane = 1;
%player.propanenumtank = %obj.spawnbrick;
ItemData::onPickup(%this, %obj, %player);
for(%i=0;%i<5;%i++)
{
%toolDB = %player.tool[%i];
if(%toolDB $= %this.getID())
{
servercmdUseTool(%player.client,%i);
break;
}
}
}
This forces you to use it when you pick it up, however this still just mounts the image, and doesn't change what is selected in the gui on the client.

Code: [Select]
function PropaneTankImage::onFire(%this, %obj, %slot)
{
if(%obj.client.minigame == 0 || %obj.client.minigame == -1){
return;
}
%obj.client.haspropaneactive = 1;
%obj.playThread(2, shiftdown);
for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i];
if(%toolDB $= %this.item.getID())
{
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
%obj.sourcerotation = %obj.gettransform();

%item = new WheeledVehicle(PropaneTank)
{
rotation = getwords(%obj.sourcerotation,3,6);
datablock  = PropaneTankCol;
creator = %obj.client.player;
};
schedule(60000,%item,delaydelete,%item);
%item.startfade(5000,55000,1);
%item.sourceobject = %obj;
%item.setnodecolor("ALL", "0.471 0.471 0.471 1.000");
%second= getwords(%obj.gettransform(),3,6);
//%item.settransform(%first SPC %second);
%item.settransform(vectoradd(getwords(vectoradd(%obj.gettransform(),%obj.getforwardvector()),0,2),"0 0 1") SPC %second);
%item.setvelocity(Vectoradd(vectorscale(%obj.getforwardvector(),2),%obj.getvelocity()));
//}
}
I'm sorry, but I don't see any checks for what you are holding.