Page 1 of 1

Binding buttons to script commands?

Posted: Mon May 30, 2005 9:30 pm
by Master-Of-Fungus-Foo-D
How would i bind buttons to script commands.... not using a cvar but, for example, if the player is in a trigger i want him to be able to push a button like 'b' and the script would execute a thread like shooting a nearby cannon...

any help?

Posted: Tue May 31, 2005 11:11 am
by bdbodger
You can't not exactly you can use fireheld or useheld for example for a trigger you can do this

main:
$mytrigger thread check_player
end

check_player:

while(1)
{
self waittill trigger
local.player = parm.other
if(local.player.useheld == 1)// or while(local.player.useheld == 1)
{
do stuff here
}
waitframe
}
end

you can do the same thing useing fireheld . There is a flakfire script at my site if you want to look at how that one was done .

Posted: Tue May 31, 2005 12:20 pm
by Rookie One.pl
All the input you can get from a player is the movement - forward/backward/strafing/jumping/crouching etc. (via state files),
fire ($player.fireheld by script or specifically primary and secondary attack via state files), reloading (via state files) and useheld. These apply for both MP & SP. In SP you can also pass commands via cvars - for more info look into Lizard's squad command script (I suggested this solution :P).

Posted: Tue May 31, 2005 7:10 pm
by Master-Of-Fungus-Foo-D
so there is no way to use a key (on default settings) like m to fire a trigger?

Posted: Wed Jun 01, 2005 12:18 am
by lizardkid
yes actually there is, i used cvars in my squad script (yay! i got referenced!), making binds to them in a custom.cfg (such as bind END setcvar mycvar "MUAHAHA!") and checking the cvars with a while loop.

keys

Posted: Wed Jun 01, 2005 10:33 am
by tltrude
Master-Of-Fungus-Foo-D - The players can set up their keys as they wish, so you can't use B or M because they may have already set them to some other function. Instead, you just flash a message on the screen that tells them to press, or hold, their "Use" key to fire the gun.

If you want to have a lot of gun buttons, have a look at my Test_Pointer tutorial map.

Posted: Wed Jun 01, 2005 11:51 am
by Elgan
lizardkid wrote:yes actually there is, i used cvars in my squad script (yay! i got referenced!), making binds to them in a custom.cfg (such as bind END setcvar mycvar "MUAHAHA!") and checking the cvars with a while loop.


Why not just use a trigger use?

Posted: Wed Jun 01, 2005 11:23 pm
by Master-Of-Fungus-Foo-D
to give more than one use to an item being triggered...

thx tom, didnt think about your test_pointer :)

yeh the cvar thing... ill try that :)

thx everyone

Posted: Thu Jun 02, 2005 3:18 am
by lizardkid
Elgan wrote:
lizardkid wrote:yes actually there is, i used cvars in my squad script (yay! i got referenced!), making binds to them in a custom.cfg (such as bind END setcvar mycvar "MUAHAHA!") and checking the cvars with a while loop.


Why not just use a trigger use?
not possible, my design was to have a bunch of different commands, like regroup, move there, fire there, follow me, etc. i couldn't have done it with a trigger use.

at the very least, it was simplest to make five command buttons.

Posted: Thu Jun 02, 2005 12:07 pm
by Elgan
i emant Master-Of-Fungus-Foo-D

and surly Master-Of-Fungus-Foo-D cant use cvars in MP

Re: Binding buttons to script commands?

Posted: Thu Jun 02, 2005 6:32 pm
by lizardkid
Master-Of-Fungus-Foo-D wrote:How would i bind buttons to script commands.... not using a cvar but, for example, if the player is in a trigger i want him to be able to push a button like 'b' and the script would execute a thread like shooting a nearby cannon...

any help?
i didn't see anything here that said MP...

but if it is probably best to go with useheld or fireheld.

Posted: Thu Jun 02, 2005 8:48 pm
by Master-Of-Fungus-Foo-D
yeh i meant MP.. sry

Posted: Fri Jun 03, 2005 8:46 am
by bdbodger
When I wrote that scirpt originally I use a trigger_multiple that when triggered checked to see if the player was useing his fire key and if so fire the flak . I later changed it to the use key . Had I started out doing it for the use key I would have spawned a trigger_use in the script instead that ran the thread to fire the flak . It is only a small script easy to change to your likeing or use in a different mod . If this is for a single player map you can just make a trigger_use even a menu would work to set a cvar but the server can't read cvars on the client so that won't work for MP .

Posted: Fri Jun 03, 2005 10:40 pm
by Master-Of-Fungus-Foo-D
ok so basically thats a no...

thx you guys..

yeh there was a thing on mods-r-us about a menu thing... ill look into it...