Author Topic: Activating with a Weapon  (Read 2436 times)

Is there a way to be able to Activate while holding a weapon? And you could bind a key to it (like +use in Source Engine). Please help me out with this, I think it would be really convenient.

so you could click and shoot at the same time, or with any tool out you could click instead of shoot?

I guess you could make a bind to unequip weapon, click, and then reequip weapon, but that could mess up with weapons that have some sort of onMount animation or warmup before being usable.

With a clientside bind and serverside script, you should be able to do it pretty easily, as long at Player::ActivateStuff doesn't have a check for equipped weapons, it should work.

So wait, how do I set Player::ActivateStuff to work with weapons?

No, you don't need to do anything with ActivateStuff, just make a serverCmd that calls it, and then a bind to the serverCmd.

No, you don't need to do anything with ActivateStuff, just make a serverCmd that calls it, and then a bind to the serverCmd.
why a server command? why not have it be clientsided?
also, i could make your way easily :D

why a server command? why not have it be clientsided?

I guess you could make a bind to unequip weapon, click, and then reequip weapon, but that could mess up with weapons that have some sort of onMount animation or warmup before being usable.

My solution to this problem was just adding onProjectileHit to the doors that does normal door activation. This, of course, assuming this is why you need this. Either way, adding onProjectileHit can also work.

Long range sniping doors open go!

Long range sniping doors open go!

Ah yes, I remember that accidentally happening when the spawn area for our team was behind some doors I added the event to. People kept trying to camp us and keep shooting the doors across the map, and it'd keep opening... Meh.

It's as simple as
Code: [Select]
// server.cs
function servercmduse(%client)
{
   // Obviously only argument is the client

   if(isObject(%client.player))
   {
      // Hey look something to call activateStuff() on! How exciting yaaaaaay
      %client.player.activateStuff();
   }
}

Code: [Select]
// client.cs
function activate(%a)
{
   if(%a)
   {
      // With keybind functions, the only argument is a boolean (0 or 1) telling if the key was pressed (1) or released (0).
      // We only want this to happen when the key is depressed, not both ways.
      commandToServer('use');
      // Not a big deal if you can send a command to the server without them having the addon, since it'll do nothing
   }
}
// Use AddBind resource by Randy, include it in the zip - download it off RTB
exec("./AddBind.cs");

// CHECK THESE ARGUMENTS. I'm not sure they're the right way round.
addBind("Action","Use","activate");

That's my good deed of the... year.

It's as simple as
Code: [Select]
// server.cs
function servercmduse(%client)
{
   // Obviously only argument is the client

   if(isObject(%client.player))
   {
      // Hey look something to call activateStuff() on! How exciting yaaaaaay
      %client.player.activateStuff();
   }
}

Code: [Select]
// client.cs
function activate(%a)
{
   if(%a)
   {
      // With keybind functions, the only argument is a boolean (0 or 1) telling if the key was pressed (1) or released (0).
      // We only want this to happen when the key is depressed, not both ways.
      commandToServer('use');
      // Not a big deal if you can send a command to the server without them having the addon, since it'll do nothing
   }
}
// Use AddBind resource by Randy, include it in the zip - download it off RTB
exec("./AddBind.cs");

// CHECK THESE ARGUMENTS. I'm not sure they're the right way round.
addBind("Action","Use","activate");

That's my good deed of the... year.
so that's what %on does :o
i thought it was something like that, also, why not just toggle tools, toggle mouse fire, toggle mousefire, toggle tools? then it would be all client sided

why not just toggle tools, toggle mouse fire, toggle mousefire, toggle tools? then it would be all client sided

For the third time:
that could mess up with weapons that have some sort of onMount animation or warmup before being usable.

For the third time:
yes, so? it will just cause it to redo the take out animation, so you couldn't shoot right after, but it's client sided at least :D

I guess you could make a bind to unequip weapon, click, and then reequip weapon, but that could mess up with weapons that have some sort of onMount animation or warmup before being usable.

With a clientside bind and serverside script, you should be able to do it pretty easily, as long at Player::ActivateStuff doesn't have a check for equipped weapons, it should work.
Anything that requires both client and server to have it installed never works very well, and generally gets underused and because activating stuff is actively used, it may actually give unfair advantages if the occurrence and popularity are low.

So wait, how do I set Player::ActivateStuff to work with weapons?
Using another function to call it.

why a server command? why not have it be clientsided?
also, i could make your way easily :D
That would screw over weapons that have a long readying time.


How about...
* Chrono gasps
PURE SERVER SIDED!?

Check this stuff out.
Code: [Select]
package activateWTools
{
function serverCmdCancelBrick(%c)
{
    if(isObject(%c.player))
        %c.player.activateStuff();
    parent::serverCmdCancelBrick(%c);
}
};
activatepackage(activateWTools);

The only problem I could see with this is canceling portals if you wanted to open a door/press a button.