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.