Graal Forums

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

Googi 12-07-2002 11:03 AM

keypressed :(
 
NPC Code:

if (created) {
i = random(0,1);
}
if (i<=1) {
showimg 0,@@c@G H W E X,screenwidth/2,screenheight/1-10;
changeimgvis 0,4;
timeout=2.05;
this.key1=false;
if (keypressed){
if (keydown2(keycode(g),true)){
this.key1=true;
}
}
if (keypressed){
if (keydown2(keycode(h),true)){
if (this.key1=true){
this.key2=true;
}
}
}
if (keypressed){
if (keydown2(keycode(w),true)){
if (this.key1=true&&this.key2=true){
this.key3=true;
}
}
}
if (keypressed){
if (keydown2(keycode(e),true)){
if (this.key1=true&&this.key2=true&&this.key3=true){
this.key4=true;
}
}
}
if (keypressed){
if (keydown2(keycode(x),true)){
if (this.key1=true&&this.key2=true&&this.key3=true&&t his.key4=true){
this.key5=true;
}
}
}
}



The problem is that keypressed isn't "working", also, I know that it's keypressed that isn't working, and not keycode thanks to the debugger :). So, either something is wrong with keypressed (Heh, yeah right) or I made a mistake (<----That is the correct reason). So, could someone tell me what my mistake was?

Oh, and yes, I am aware of my uneccessarily large if statements, and that this script is actually pointless.

Goboom 12-07-2002 11:40 AM

Do you ever read the rules? DONT POST FULL SCRIPTS!
--try this format
NPC Code:
if (keypressed){
if (keydown2(keycode(R),true){//stuff here;}
if (keydown2(keycode(e),true){//stuff here;}
if (keydown2(keycode(a),true){//stuff here;}
if (keydown2(keycode(d),true){//stuff here;}
//--
if (keydown2(keycode(T),true){//stuff here;}
if (keydown2(keycode(h),true){//stuff here;}
if (keydown2(keycode(e),true){//stuff here;}
//--
if (keydown2(keycode(R),true){//stuff here;}
if (keydown2(keycode(u),true){//stuff here;}
if (keydown2(keycode(l),true){//stuff here;}
if (keydown2(keycode(e),true){//stuff here;}
if (keydown2(keycode(s),true){//stuff here;}
}


Googi 12-07-2002 11:58 AM

Quote:

Originally posted by Goboom
Do you ever read the rules? DONT POST FULL SCRIPTS!

That's far from being the full script. That's a small part of a script I'm making, which is why it was so useless.

Com013 12-08-2002 05:53 AM

My experience is that keypressed is not working when you are pressing one of the default keys (Those you can set in the options).
But I doubt you gave the key "x" a default meaning, so I guess the problem is more due to the fact that the script looks very weird. Yes, keypressed should be treated like an event, while i<=1 is not an event.


All times are GMT +2. The time now is 12:26 PM.

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