Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-29-2009, 08:22 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
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.
Reply With Quote
  #2  
Old 06-29-2009, 08:36 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
You can always make use of the following two events:

function GraalControl.onKeyDown(keycode, keychar) { ... }
function GraalControl.onKeyUp(keycode, keychar) { ... }
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 06-29-2009, 08:45 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
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
Reply With Quote
  #4  
Old 06-29-2009, 10:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You should probably be using the F3 Default Key for attacking as well.

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

either should work.
__________________
Quote:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:20 AM.


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