Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   keyup help (https://forums.graalonline.com/forums/showthread.php?t=86617)

scriptless 06-29-2009 08:22 PM

keyup help
 
Okay I am working on a "-punch" system that ruuns smoothly and effeciently. There is only 1 problem I am having. Well 2 kinda. Lets start here.


NPC Code:
//#CLIENTSIDE
function onCreated()
{
disableweapons();
}

function onActionPunchHurt()
{
if (ispaused)
{
//blah
}
else
{
player.hearts -= 0.5;
player.chat = "Ouch!";
setani( "idle", NULL);
setani( "hurt", NULL);
}
}

function onKeyPressed(code,key)
{
if ( player.ani != "swim")
{
if ( key == "s" )
{
if ( player.freezetime < 0 )
{
ar = {player.x + (vecx(player.dir) * 2) + 1.5, player.y + (vecy(player.dir) * 2) + 1.8};
triggeraction( ar[0], ar[1], "PunchHurt", player.account, player.nick, player.guild);
setani( "punch-right", null);
freezeplayer(.4);
sleep(.3);
setani( "idle" , null );
}
}
}
}



Origonally my problems were if u held "tab" and "s" u would punch really fast. Now it seems u can just hold "s" to punch repeatedly. How can I do a "loop-less" keyup check? Any suggestions? I only want it to punch once even if I hold "s" down. I tried adding a while loop at the end to basicallt loop as long as the keydown2 says its still pressed.. bug all I got was lag.

xXziroXx 06-29-2009 08:36 PM

You can always make use of the following two events:

function GraalControl.onKeyDown(keycode, keychar) { ... }
function GraalControl.onKeyUp(keycode, keychar) { ... }

scriptless 06-29-2009 08:45 PM

I could have sworn I tried those with no luck... I will try again. Maybe I am using them wrong?

Guess I was doing it wrong before. Those help me ALOT.. thanks :)

fowlplay4 06-29-2009 10:09 PM

You should probably be using the F3 Default Key for attacking as well.

keydown(5)
key == keyname(5).lower()

either should work.


All times are GMT +2. The time now is 12:53 AM.

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