Binding buttons to script commands?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Binding buttons to script commands?

Post 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?
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post 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).
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

so there is no way to use a key (on default settings) like m to fire a trigger?
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

keys

Post 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.
Tom Trude,

Image
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post 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?
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post 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
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

i emant Master-Of-Fungus-Foo-D

and surly Master-Of-Fungus-Foo-D cant use cvars in MP
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Re: Binding buttons to script commands?

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

yeh i meant MP.. sry
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post 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...
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Post Reply