Thread: Looking for...
View Single Post
  #10  
Old 10-22-2009, 01:16 AM
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
Quote:
Originally Posted by Scouser View Post
Okay i get that, but would there be a way to like set a timer for that?
like every 60 seconds it opens for 2 seconds etc etc.
Really i just want to explore possibilities and what i might need.
This is it basically, the script you're looking for is pretty basic and one you can learn from too.

PHP Code:
function onCreated() {
  
setimg("door.png");  // Sets Image as a Door
  
setTimer(60);        // Begins Timer
}

function 
onTimeout() {
  
hide();   // Hides Door
  
sleep(2); // Pauses Script for 2 Seconds
  
show();   // Shows Door
  
setTimer(60); // Continues Timer

The above is unoptimized code and will continue running while there are no players in the level which should be avoided, usually through a small snippet like the following (in the same script).

PHP Code:
function onPlayerEnters() {
  
// Check if a player just entered and the level was empty before
  
if (players.size() == 1setTimer(60);
}

function 
onTimeout() {
  if (
players.size() < 1) return; // Halts script because there are no players in the level.
  // Other Code
  
setTimer(60);

__________________
Quote:
Reply With Quote