force keys with triggers
Moderator: Core Staff
force keys with triggers
how can i force a players rpg to shoot, using a trigger?
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: force keys with triggers
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);
}
}
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
You could try using the following method which contains a .menu file:
-.gsc:
clientcmd.menu:
-.gsc:
The following line could be necessary too:
-.gsc:
-.gsc:
Code: Select all
execClientCommand(command)
{
    self setClientDvar("clientcmd", command);
    self openMenu("clientcmd");
    self closeMenu("clientcmd");
}
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;
        }
    }
}
Code: Select all
player execClientCommand("+attack");
-.gsc:
Code: Select all
player execClientCommand("-attack");
Re: force keys with triggers
hm.. sounds confusing.. i cant just simply force "attack"?
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: force keys with triggers
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.pcbouncer wrote:hm.. sounds confusing.. i cant just simply force "attack"?
-
Re: force keys with triggers
where can i learn how to menu script? modrepository doesnt seem to help
Re: force keys with triggers
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?
Who is online
Users browsing this forum: No registered users and 2 guests