View Single Post
  #5  
Old 11-29-2009, 06:21 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fowlplay4 View Post
Well the use of a timeout and keydown would suffice, here's the basic shell of it.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
// Check if weapon currently selected.
  
if (this.id == selectedweapon) {
    
// Check if "D" / Weapon key is pressed down
    
if (keydown(4)) onShoot();
    
// Loop
    
setTimer(0.1);
  }
  else 
setTimer(0.1);
}

function 
onShoot() {
  
// Gun shooting stuff here.
  /*
      would be your onWeaponFired code.
  */

Why would you always have a timeout running if not needed? And yeah, I forgot to add if the weapon was selected in mine, oops.

Also, "on" is for events, not for functions
__________________
Reply With Quote