Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Mining System Timeout (https://forums.graalonline.com/forums/showthread.php?t=134265101)

Ohk4y 11-24-2011 08:07 PM

Mining System Timeout
 
Hello! I'm trying to make a mining system x_x and I ran into an issue. I want it to put all the rocks back to normal (from being destroyed - to how they were before the player 'hurt' them) if there are no players around the rocks.

This is what I have so far for that part of the script. keep in mind I am just testing the X and Y of the player so I can go from there.

PHP Code:

function onTimeOut() {
  for (
pl allplayers) {
    if (
pl.1.5 in |this.xthis.2|) {
      
onTrueX();
    }else 
onFalse();
    if (
pl.1.5 in |this.ythis.2|) {
      
onTrueY();
    }else 
onFalse();    
  }
 
setTimer(.05);
}

function 
onTrueX() this.chat "true X";
function 
onTrueY() this.chat "true Y";
function 
onFalse() {
  
this.chat "  ";


NOTE: This is within a class, serverside.

ffcmike 11-24-2011 08:10 PM

Quote:

Originally Posted by Ohk4y (Post 1675288)
Hello! I'm trying to make a mining system x_x and I ran into an issue. I want it to put all the rocks back to normal (from being destroyed - to how they were before the player 'hurt' them) if there are no players around the rocks.

This is what I have so far for that part of the script. keep in mind I am just testing the X and Y of the player so I can go from there.

PHP Code:

function onTimeOut() {
  for (
pl allplayers) {
    if (
pl.1.5 in |this.xthis.2|) {
      
onTrueX();
    }else 
onFalse();
    if (
pl.1.5 in |this.ythis.2|) {
      
onTrueY();
    }else 
onFalse();    
  }
 
setTimer(.05);
}

function 
onTrueX() this.chat "true X";
function 
onTrueY() this.chat "true Y";
function 
onFalse() {
  
this.chat "  ";


NOTE: This is within a class, serverside.

0.05 second timeouts do not work serverside.
You should also really be breaking that loop once an intersect is detected, and only calling onFalse(); if no players are detected after the loop has finished.

Ohk4y 11-24-2011 08:13 PM

Okay, well the check isn't even working.

fowlplay4 11-24-2011 08:20 PM

You don't even need a check like what you have, makes almost no sense to have it that way either. This is the gist of what you should be aiming for:

PHP Code:

function onPlayerEnters() {
  if (
players.size() == 1) {
    if (
this.rock_is_alive) {
      
setRockToFullHealth();
    }
  } 
}

function 
onRockDestroyed() {
  
// Set's Timer to Timeout in 10 Seconds
  
setTimer(10);
}

function 
onTimeout() {
  
respawnRock();
}

function 
respawnRock() {
  
// Return rock back to normal


Obviously the script won't work by just copy and pasting it in, you're going have to figure that part out on your own!

Ohk4y 11-26-2011 07:21 AM

I took a different approach at it. Thank you.


All times are GMT +2. The time now is 02:05 AM.

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