Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   keydown!! (https://forums.graalonline.com/forums/showthread.php?t=34995)

thesmoothcriminal 08-03-2002 07:11 PM

keydown!!
 
how do i use keydown properly
my script only works for numbers
can someone right a script for a Character key eg.o

SingleChance 08-03-2002 07:55 PM

:)
 
This is how the script goes
if(keydown(1-2-3-4-5-6)){whateverhere}
i thnk thats right not to sure about numbers...

screen_name 08-03-2002 09:39 PM

the keydown event doesn't work by itself


i usually run inside a timeout

thesmoothcriminal 08-03-2002 09:50 PM

anyone tell me the whole script for pressing o

nyghtGT 08-03-2002 09:59 PM

'keydown' isn't like a 'playertouchsme' command you have to contantly check for it through a timeout loop...

NPC Code:

if (created) {
timeout=0.05;
}
if (timeout) {
if (keydown(#)) {
stuffs();
}
timeout=0.05;
}


screen_name 08-03-2002 10:33 PM

Quote:

Originally posted by thesmoothcriminal
anyone tell me the whole script for pressing o
lol, look in the newfeatures text file

all you have to do is mod that one


i swear, why dont people just try anymore

thesmoothcriminal 08-03-2002 10:37 PM

ummm i wrote:
if (created) {
timeout=0.05;
}
if (timeout) {
if (keydown(o)) {
say2 works();
}
timeout=0.05;
}

and it only says works when i press up

nyghtGT 08-03-2002 10:41 PM

ugh, there is no keydown for o.

0.1.2.3.4.5.6.7.8.9.10
Up.Left.Down.Right.A.S.D.Q...

CrimsonLotus9838 08-06-2002 11:25 AM

If you do keydown(o) and it only works when you press "up," there's a reason. The program thinks "o" is a variable name and since you didn't declare it before, it would be considered "0" and in the keydown() flag, a 0 is generated when the "up" key is hit.

adam 08-06-2002 10:08 PM

I believe keypressed is a valid event you can use..... whether your using keydown or keydown2....

zorakid2001 08-07-2002 12:45 AM

then how do they do the E and W keys on babylon??

adam 08-07-2002 01:16 AM

Quote:

Originally posted by zorakid2001
then how do they do the E and W keys on babylon??
keydown2...

it's all in the newfeatures text file.

RavenTelvecho 08-08-2002 12:30 PM

Quote:

Originally posted by adam


keydown2...

it's all in the newfeatures text file.

or if ur lazy this should help
NPC Code:


if (keypressed) {
this.on=1-this.on;
if (this.on==1&&strequals(#p(1),o)) {message on;}
else { message off};
}



Quote:

- functions:
keycode(character) - gets the key code for the character
(identical to the windows virtual key code)
keydown2(keycode,ignorecase) - checks if a key has been pressed,
ignorecase must be true if you want to turn off the check
for shift/alt/control key, so keydown2(keycode(A),true) will be
true whenever you press A or Shift+A or Alt+A
- a script to display 'on' when pressing '1' and displaying
'off' when pressing '2':

if (keypressed) {
code = strtofloat(#p(0));
if (code==keycode(1,false)) message on;
else if (code==keycode(2,false)) message off;
}

The same without converting it to the key code:

if (keypressed) {
if (strequals(#p(1),1)) message on;
else if (strequals(#p(1),2)) message off;
}


All times are GMT +2. The time now is 04:18 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.