Trapping keys?

Post your scripting questions / solutions here

Moderator: Moderators

Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Trapping keys?

Post by Elgan »

hi everyone!

ill be quick, is there a way i can detect what keys have been pressed?

so like if someone pressed their key for left then do something?

if(local.player.pressed=="moveleft") -or something?
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

the only 2 I know of are useheld and fireheld
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

yeah i have used both of them:(
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

is there a way of detecting secondry fire?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes there is a way, but it involves more than just scripting :(

Since I think you are a talented scripter, I'll give a brief explanation and see how far you get with it :)

Mohaa uses so-called state files to determine player animations based on their actions (i.e. what they are doing) and the good thing is you can modify these things. You can find them in global/mike_legs.st and global/mike_torso.st.

You can use these files to send information about key presses to other scripts, for example when a player is starting to walk forward you could exec a script by adding it to the entrycommands of that state.

You could also add a bunch of new states to keep things easier and better organized. In a script, you can use $player forcelegsstate SOME_STATE and $player forcetorsostate SOME_STATE to throw players in a certain state.

Anyway hope this helps some how... good luck :)
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

wow thanx ill go try:):D

and this would be totaly server sided yes?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes :)

Note: if you want you could use map specific state files. For example, if you want to use global/mymap_legs.st and global/mymap_torso.st add this line to the top of your map script:

setcvar g_statefile "global/mymap"

Downside is that you'd have to change it back somehow when the map changes :(
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

couldnt you just have setcvar g_statefile "global/mike_legs.st" at the top of all the maps and then on the one i want modified have setcvar g_statefile "global/maymaps_new_state.st"?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes you could do that :)

But remember it should be without the _legs.st :wink:

(default is global/mike)
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

hmm have u an example of an edited .st please?

i edited it and changed the map file to load its new state but maps wont load now :o

:roll:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Look in the console for errors.
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

it just says error coulnt load filename


ill delete it and try again:P
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

ok ive been trying this for hours but everytime i try to load the map it fails:(


does any1 have an example?
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

crap!

i been messing for aggges and nout worked!

1 of them might of:(

because i just set setcvar g_statefile "global/mymap.st"

and made mymap state with default and it still didnt work:@
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Set g_statefile to global/mymap and make 2 statefiles global/mymap_legs.st and global/mymap_torso.st... then you should be fine :)
Image
Post Reply