Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2011, 03:58 AM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
timevar2 question

i'm utilizing timevar2 for a renting system, however i've come into a problem when comparing rentTime to timevar2. essentially if you do something like this

PHP Code:
function onActionRentTime(){

  
rentTime timevar2 6// somewhat stupid comparison

  
if( timevar2 >= rentTime ){
    
player.chat "Rent expired!";
  }
  

timevar2 is always incrementing, so there is no real way to compare the var rentTime to timevar because it'll always be greater than 6. (since it always increments). however, if there was a way to freeze the current timevar and THEN compare it to 6 and wait for the incrementing timevar to get over 6, thus leading the rent to expire that would be a much greater solution.

so, is there a way to freeze the current timevar2/ record it somehow?
Reply With Quote
  #2  
Old 08-30-2011, 04:01 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by furry_mougle View Post
i'm writing a renting-system script, however i've come into a problem when comparing rentTime to timevar2. essentially if you do something like this

timevar2 is always incrementing, so there is no real way to compare the var rentTime to timevar because it'll always be greater than 6. (since it always increments). however, if there was a way to freeze the current timevar and THEN compare it to 6 and wait for the incrementing timevar to get over 6, thus leading the rent to expire that would be a much greater solution.

so, is there a way to freeze the current timevar2 or record it somehow?
??

you seem to have answered your own question within the script.

PHP Code:
function onActionRentTime(){
  
this.rent_time timevar 26;
  
setTimer(1);
}

function 
onTimeout(){
  if(
this.rent_time <= timevar2){
    
player.chat "Rent expired!";
  }
  
setTimer(1);

Reply With Quote
  #3  
Old 08-30-2011, 04:03 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
When the player rents time in whatever service, store the time when it expires (timevar2+6) in a clientr flag. I.e: clientr.rentexpires

Then all you need to do is check if timevar2 is greater than or equal to clientr.rentexpires and act accordingly.

You don't have to use clientr flags either, if it's a house you can store it in a DB as well.
__________________
Quote:
Reply With Quote
  #4  
Old 08-30-2011, 04:10 AM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
oh, I thought since the number increments it's always going to be +6, anyway ty! i'm such a silly goose!
Reply With Quote
  #5  
Old 08-30-2011, 04:15 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 furry_mougle View Post
oh, I thought since the number increments it's always going to be +6, anyway ty! i'm such a silly goose!
The variable timevar2 always increments but if you store the value of timevar2 in another variable you have (in your terms) froze time in that new variable.
__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:19 PM.


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