PDA

View Full Version : Strafe [could be used as a shield block]


xAndrewx
05-29-2007, 07:48 PM
Well, here's a stafe thing.

//#CLIENTSIDE
function onCreated()
{
movement = this;
}

public function onStaticDirection(newDirection)
{
if (playerDirection != temp.newDirection)
{
playerDirection = temp.newDirection;
}
if (keydown2(160, true) && playerShield)
{
setani("c_shieldblock", "");
player.dir = playerDirection;
scheduleevent(0.05, "StaticDirection", playerDirection);
}
else
{
playerShield = false;
}
}


How it's called


//#CLIENTSIDE
function onKeyPressed(letterCode)
{
switch(temp.letterCode)
{
case 160:
playerShield = true;
movement.onStaticDirection(player.dir);
return true;
}
}


Advise, make all the keyPressed actions all in one weapon, and then just send it through there

cbk1994
05-31-2007, 02:38 AM
Make sure you add a a break in that case 160:

Few things that could work only on your server though.

Otherwise nice, I never realised you could do movement = this; on clientside, and then call it from other weapons!

xXziroXx
05-31-2007, 02:39 AM
Uhm..

movement = this;

That looks retarded. Why not just name the wNPC to "movement" and do movement.SomeFunctionHere() ?

cbk1994
05-31-2007, 02:41 AM
Uhm..

movement = this;

That looks retarded. Why not just name the wNPC to "movement" and do movement.SomeFunctionHere() ?

How so?

Notice this is in the code gallery, so people using it might not have custom Q Menus.

In that case, it could be deleted! That would be bad :(
There's nothing wrong with what xAndrewx did... I like it.

Better than doing

( @ "-System/Movement" ).doSomething();

xXziroXx
05-31-2007, 02:44 AM
I like it.

Good for you! I don't though.

cbk1994
05-31-2007, 02:49 AM
Good for you! I don't though.

Why not? It seems perfectly logical to me.

xAndrewx
05-31-2007, 11:44 AM
I don't use break, as it would carry on with the script. Calling return just stops the function at hand.

cbk1994
05-31-2007, 01:33 PM
I don't use break, as it would carry on with the script. Calling return just stops the function at hand.

It's probably a better practice to always break; at the end of the switch, then use return. Personal preference I suppose though.