![]() |
keypressed
I know, its easy use: "for" with oldkeys arrays to make "keypressed" and not keydown..
But the graal should have something fast as: "if(keypressed(i)) blah blah blah" |
Why?
|
Re: keypressed
Quote:
|
¬¬'' ..no comments...
:rolleyes: Keypressed you have to RELEASE the key!!! try this script and u will understand.. timeout=.05; if (keydown(5)&&this.mode==0){this.mode=1} if (keydown(5)&&this.mode==1){this.mode=0} if (this.mode==1){setplayerprop #c,1;}else setplayerprop #c,2; I wanna press S and say 1.. if I press S again say 2.. but the timeout is too fast and will be showing {1,2,1,2,1,2,1,2,1... very fast}.. There is an easy way to do release keys.. setarray this.key,10; setarray this.oldkey,10; for (i=0;i<10;i++) {this.key[i]=this.oldkey[i]; this.oldkey[i]=keydown(i);} ¬¬'' Did u get now??? Did u see somewhere menus where you press D to open, S to the first choise and A to the second choise? the guy that made it didnt know the script that I said.. |
Quote:
|
couldnt you just do while (keydown(#)) {stuff}
|
Not necesarry, so I see no real point in adding it.
|
umm
from what I read....
you have a problem of going straight from one number to the other...having an "if (keypressed(#))" wont solve anything, because that would be a one-time action that is sent, like playerchats. If youve ever done NPC Code: You'll notice nothing ever happens when you speak...because the chance of the player chatting at the right time (when the timeout loop reaches the IF), are like 1 billion to 1, so if (keypressed(#)) wont work for that reason. but, to make it so the player doesnt need to have 0.05 second reflexes, you can add a function, like: NPC Code: *Note : this can be done without a function, but functions are more organized* that way the program only waits when a key is pressed...or...you can do this: NPC Code: that will make it so the NPC will not respond to the s key until .5 seconds have passed since the last press. |
Yes, it's called using timers and making a wait variable. That is how most all the scripts are done that use keydown in that manner.
I thought this was a topic for like, if a key is being held down, as that might be more useful for key combinations of things.. like for example, the ingame inventory dropping system (holding S and pressing A to cycle through items) That might be more helpful, even though it's possible to do anyway. There are lots of commands that would be helpful, but most all commands that people request can be done with the current scripting, plus you get the advantage of being able to do more things with a script then having a simple command that is limited to certain things. |
Quote:
I know I've never done it that way. I can't even imagine what you're describing. |
Quote:
NPC Code:Is what he means. Probably. |
| All times are GMT +2. The time now is 03:49 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.