Page 1 of 1

force keys with triggers

Posted: June 20th, 2013, 4:35 am
by pcbouncer
how can i force a players rpg to shoot, using a trigger?

Re: force keys with triggers

Posted: June 20th, 2013, 10:11 am
by F |Madness| U

Code: Select all

function()
{
   trigger_ent = getent("trigger_targetname", "targetname")
 
   while(1)
   {
      trigger_ent waittill("trigger", user)
      user switchtoweapon("rpg_mp");
      user setclientdvar("+attack",1);        // I dont think this works
      wait 0.5;
      user setclientdvar("-attack",1);
   }
}
I don't think the +attack thing will work in script. If not, I think it is possible to force key presses by using menu-files (I know you can monitor key presses with them). Hopefully Drofder or somebody will enlighten you on this.

Also note with the above code, the trigger will only be able to be re-used once the original person finishes firing the rpg, if you don't want this, then just call a new function on the user inside the trigger loop, and this function would have the rpg firing etc.

Re: force keys with triggers

Posted: June 20th, 2013, 1:17 pm
by Buzzard
You could try using the following method which contains a .menu file:

-.gsc:

Code: Select all

execClientCommand(command)
{
        self setClientDvar("clientcmd", command);
        self openMenu("clientcmd");
        self closeMenu("clientcmd");
}
clientcmd.menu:

Code: Select all

#include "ui/menudef.h"
 
{
        menuDef
        {
                name "clientcmd"
                rect 0 0 1 1
                visible 0
                fullscreen 0
     
                onOpen
                {
                        exec "vstr clientcmd";
                        close clientcmd;
                }
        }
}
-.gsc:

Code: Select all

player execClientCommand("+attack");
The following line could be necessary too:

-.gsc:

Code: Select all

player execClientCommand("-attack");

Re: force keys with triggers

Posted: June 20th, 2013, 8:58 pm
by pcbouncer
hm.. sounds confusing.. i cant just simply force "attack"?

Re: force keys with triggers

Posted: June 20th, 2013, 9:19 pm
by F |Madness| U
pcbouncer wrote:hm.. sounds confusing.. i cant just simply force "attack"?
If my `setclientdvar(+attack)` doesn't work, then no, it can't be `simply` done as far as I know. However menu files arn't too complicated once you spend a small amount of time to learn them - they are also very useful for modding/scripting in general.

Re: force keys with triggers

Posted: June 28th, 2013, 10:44 pm
by pcbouncer
where can i learn how to menu script? modrepository doesnt seem to help

Re: force keys with triggers

Posted: June 29th, 2013, 3:44 pm
by pcbouncer
is there anything special that i would have to do with the menu file except make it and save it? where would i save it and how can i know all of the commands for menu files?