Aller au contenu

Photo

This Counter Does Not Work!? (Resolved)


  • Veuillez vous connecter pour répondre
12 réponses à ce sujet

#1
Morbane

Morbane
  • Members
  • 1 883 messages
 I am trying to script a counter from a conversation.

It is supposed to last 3 hours of Game Time.

In my Module the Game Hour is set to 10 minutes real time per Game Hour.

See Next Post. =]

Modifié par Morbane, 15 mai 2012 - 09:59 .


#2
Morbane

Morbane
  • Members
  • 1 883 messages
I tinkered with this for a while but the result was no result.... :unsure:

Modifié par Morbane, 15 mai 2012 - 01:33 .


#3
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oPC = GetPCSpeaker();
int trans = GetTimeHour();

if(!GetLocalInt(OBJECT_SELF, "efreet"))
{
SetGlobalInt("time", trans);

int mark = GetGlobalInt("time") + 3;

SaveGlobalVariables("time");

SetLocalInt(OBJECT_SELF, "efreet", TRUE);

FloatingTextStringOnCreature("Three Hours (Game Time) And Counting Down...", oPC);
}
if(trans == LoadGlobalVariables("mark") + 1)
{
FloatingTextStringOnCreature("Two Hours (Game Time) And Counting Down...", oPC);
}
else if(trans == LoadGlobalVariables("mark") + 2)
{
FloatingTextStringOnCreature("One Hour (Game Time) And Counting Down...", oPC);
}
else if(trans == LoadGlobalVariables("mark") + 3)
{
FloatingTextStringOnCreature("Zero Hours (Game Time) Remain...", oPC);
DestroyObject(GetObjectByTag("efreet_coin"));
return;
}
else
{
DelayCommand(60.0f, ExecuteScript("ga_efreet_time", OBJECT_SELF));

trans++;
}
}


I have currently set the re-fire of the script to 1 minute just for time's sake.

Modifié par Morbane, 15 mai 2012 - 01:36 .


#4
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Should "time" and "mark" be the same?

Also, not to frustrate you more, but you have to figure out the wrap around, when someone starts at 2200 and the timer is supposed to go off at 0100.

#5
Morbane

Morbane
  • Members
  • 1 883 messages
Well that is the problem - "time" is the start time and "mark" is the 3 hour deadline - so to speak...

As far as the wrap around - that doesnt work with standard addition of GetTimeHour() +3 etc?

#6
Shallina

Shallina
  • Members
  • 1 011 messages
you need to do a modulo 24.

#7
Morbane

Morbane
  • Members
  • 1 883 messages

Shallina wrote...

you need to do a modulo 24.


Where? :crying:

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
If "mark" is the deadline, then your checks should be -2, -1, and 0, not +1, +2, +3.

As for the 24-hour loop, at 2200, GetTimeHour() + 3 = 25, but when the time actually comes, it won't be 2500, it will be 0100, or 1. 1 is not greater than or equal to 25.

Using modulo, as Shallina suggests, could help. 25 % 24 =1, but if you just set '1' as your deadline, then 22 and 23 will also set the timer off, prematurely. You have to also keep track of the day, and make sure that the day has changed as well. A cheap trick would be just to reset the time to something earlier in the day whenever the timer is started, so that the clock never has to span midnight.

#9
Shallina

Shallina
  • Members
  • 1 011 messages
I have done time counters that work for BGR, I'll post one when I'll be home.

Modifié par Shallina, 15 mai 2012 - 04:20 .


#10
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oPC = GetPCSpeaker();

FloatingTextStringOnCreature("Three Hours (Game Time) And Counting Down...", oPC);

DelayCommand(600.0, ExecuteScript("a_hour_one", OBJECT_SELF));

DelayCommand(1200.0, ExecuteScript("a_hour_two", OBJECT_SELF));

DelayCommand(1800.0, ExecuteScript("a_hour_three", OBJECT_SELF));
}

#11
Shallina

Shallina
  • Members
  • 1 011 messages
//fct_number_of_day

int number_of_day(int year1,int month1,int day1,int year2,int month2,int day2){

int nDay = 0;
if ((year2-year1)==0){

if ((month2 - month1) == 0){

nDay = nDay + abs(day2 -day1);
}
else {


nDay = ((month2 - month1)-1) * 30 + (30 - day1) + day2;

}
}
else{

nDay = (year2 - year1 - 1) *365 + (12 -month1)*30 + month2 + (30 - day1) + day2;

}



return nDay;
}

#12
kamal_

kamal_
  • Members
  • 5 258 messages
we can do modulo in script? Shucks, I've been checking my results to make sure they're in range.

#13
Morbane

Morbane
  • Members
  • 1 883 messages
ya I've used modulo to determine even/odd - but that is the extent of my comprehension 8P