Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Strange Random() ? (https://forums.graalonline.com/forums/showthread.php?t=134265635)

scriptless 01-27-2012 06:13 AM

Strange Random() ?
 
I was testing a npc on N-Pulse when I noticed I dug up 2 items at once.. how could this be? I only generate the number once.. and they both have seperate ranges..

PHP Code:

function checkdig(chxchy) {
  
temp.randomnumber random(0,100);
  
//player.chat = random(0,3) SPC temp.randomnumber;
  
if ( int(temp.randomnumberin |20,40| ) {
    
temp.obj putnpc2(chxchy"");
    
temp.obj.image "block.png";
    
temp.obj.join("shovel_obj");
  }
  if ( 
int(temp.randomnumberin |50,60| ) {
    
temp.obj putnpc2(chxchy"");
    
temp.obj.image "np_worm.png";
    
temp.obj.join("shovel_obj");
  }


This is serverside also.

And yes I will be using case/switch. But any reason this would be acting this way?

fowlplay4 01-27-2012 06:21 AM

How do you know your script just isn't getting executed twice?

You'd be able to tell if you used echo instead of player.chat for debugging.

scriptless 01-27-2012 06:23 AM

Quote:

Originally Posted by fowlplay4 (Post 1682836)
How do you know your script just isn't getting executed twice?

You'd be able to tell if you used echo instead of player.chat for debugging.

Good point.

After review, you are correct. Thanks for the help, it was actually executing 4 times. It's been a rough week.


All times are GMT +2. The time now is 10:22 AM.

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