View Single Post
  #10  
Old 03-29-2012, 06:48 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Devil_Lord2 View Post
PHP Code:
      else if (player.account in this.tempStaff){
        for (
temp.a=0this.tempStaff.size(); a++){
          if  (
player.account == this.tempStaff[a] && player.level == this.tempStaff[a+1]){
            for (
temp.i=0params[1].size(); i++){ 
Do you realise you have 2 conditions which are exactly the same?
If you were to remove the first line of player.account in this.tempStaff, it would still work.

player.level is an object rather than a string, the correct value to check is 'player.level.name'.

It's a bad practise to loop through non-changing arrays and use .size(); for every cycle, as the function will occur every time rather than once, this can generate a lot of overhead with very large arrays. The array size can be defined as a temporary variable beforehand, which can then be used in the loop condition.

Quote:
Originally Posted by Devil_Lord2 View Post
However, my friend is trying to create a baddy using a specific algorithm and he is having problems with maxing out the loop only if he doesn't add a sleep .05 in..

I believe he wants something like an onTimeout calling an onTimeout right after the end of checking... Perhaps that is the same problem? I don't know. I doubt he will post on the forums though..
onTimeout(); occuring within function onTimeout(){} without any specification for it would run infinitely until cancelled by the engine/NPC-Server.
Reply With Quote