Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-26-2010, 10:53 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Strange problem. Variable isn't adding?

Alright so I have this script:

PHP Code:
      if("paralysis" in this.screffs){ //Check if this is true.
        
temp.paralyzecounter += 0.05//Add to the counter.
        
if(temp.paralyzecounter >= 1){ //See if the counter is 1 or higher.
          
random(0,100);
          if(
<= 25){
            
triggerserver("gui"this.name"freezeplayer"player.account0.5"Paralyzed!");
          }
          
temp.paralyzecounter 0//Reset the counter.
        
}
        
player.chat temp.paralyzecounter//Check to see if the number is changing.
      
}
      elseif(!(
"paralysis" in this.screffs)){temp.paralyzecounter 0;} //If false, reset the number. 
It's being run through a timeout of course, and I've tested to see what happens if i put player.chat = serverr.time and it is indeed updating more than once.

however, for some strange reason, temp.paralyzecounter will always return 0.05 And yes, I have also tried removing both parts that reset the timer, and I'm 100% certain that temp.paralyzecounter is handled anywhere else in the weapon.

Any ideas on why it won't add?
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #2  
Old 10-26-2010, 10:56 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Jiroxys7 View Post
Alright so I have this script:

PHP Code:
      if("paralysis" in this.screffs){ //Check if this is true.
        
temp.paralyzecounter += 0.05//Add to the counter.
        
if(temp.paralyzecounter >= 1){ //See if the counter is 1 or higher.
          
random(0,100);
          if(
<= 25){
            
triggerserver("gui"this.name"freezeplayer"player.account0.5"Paralyzed!");
          }
          
temp.paralyzecounter 0//Reset the counter.
        
}
        
player.chat temp.paralyzecounter//Check to see if the number is changing.
      
}
      elseif(!(
"paralysis" in this.screffs)){temp.paralyzecounter 0;} //If false, reset the number. 
It's being run through a timeout of course, and I've tested to see what happens if i put player.chat = serverr.time and it is indeed updating more than once.

however, for some strange reason, temp.paralyzecounter will always return 0.05 And yes, I have also tried removing both parts that reset the timer, and I'm 100% certain that temp.paralyzecounter is handled anywhere else in the weapon.

Any ideas on why it won't add?
Must be your timeout, can I see the script you're using? (full)
__________________
Reply With Quote
  #3  
Old 10-26-2010, 11:01 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
temp variables are cleared when the function is complete and only exist in the scope of that function, so unless your code is in some sort of while or for loop and iterates at least 20 times your code will never get past the (temp.paralyzecounter >= 1).

temp example:

PHP Code:
function onCreated() {
  
temp.2;
  echo(
temp.a);
  
example();
  echo(
temp.a);
}

function 
example() {
  
temp.3;
  echo(
temp.a);

echos

Quote:
Originally Posted by RC
2
3
2
Therefore changing temp.paralyzecounter to this.paralyzecounter would make it work properly (or at least how you expect it to).
__________________
Quote:
Reply With Quote
  #4  
Old 10-26-2010, 11:10 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
edit: Alright, looks like that worked. Thanks fp4
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
Reply


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 02:53 PM.


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