Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:02 AM.


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