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 11-24-2011, 08:07 PM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Mining System Timeout

Hello! I'm trying to make a mining system 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.
__________________
Reply With Quote
  #2  
Old 11-24-2011, 08:10 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 Ohk4y View Post
Hello! I'm trying to make a mining system 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.
Reply With Quote
  #3  
Old 11-24-2011, 08:13 PM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Okay, well the check isn't even working.
__________________
Reply With Quote
  #4  
Old 11-24-2011, 08:20 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
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!
__________________
Quote:
Reply With Quote
  #5  
Old 11-26-2011, 07:21 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Red face

I took a different approach at it. Thank you.
__________________
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 05:08 PM.


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