Does anyone knows how could I create a timer, invisible to the player, but that registered the time he spends playing? Minutes and seconds are what I need, my module is small.
I would need the timer to start at the beginning of the module and stop at the end of it, so I can now for sure how long the player played the game. Also, I would like to have some triggers along the way that would tell me how long the player took to reach that point.
I was told that I could use this functions to achive this, but I'm not quite sure how to use it... I'm still king of new to the toolset
GetTimeHour()
GetTimeMinute()
Timer?
Débuté par
el.sombrero
, mai 09 2012 08:32
#1
Posté 09 mai 2012 - 08:32
#2
Posté 09 mai 2012 - 10:27
Not tested but a decent example nonetheless...
void main()
{
object oPC = GetEnteringObject(); //for first trigger
if(!GetIsPC(oPC) return;
SetLocalInt(oPC, "time_hour", GetTimeHour());
SetLocalInt(oPC, "time_mins", GetTimeMinute());
}
void main()
{
object oPC = GetEnteringObject(); //for check triggers
if(!GetIsPC(oPC) return;
int nCurrentHour = GetTimeHour();
int nCurrentMins = GetTimeMinute();
int nElapsedHour = nCurrentHour - GetLocalInt(oPC, "time_hour");
int nElapsedMins = nCurrentMins - GetLocalInt(oPC, "time_mins");
SendMessageToPC(GetFirstPC(), nElapsedHour + " Hours and " + nElapsedMins + " Minutes have passed.");
}
void main()
{
object oPC = GetEnteringObject(); //for first trigger
if(!GetIsPC(oPC) return;
SetLocalInt(oPC, "time_hour", GetTimeHour());
SetLocalInt(oPC, "time_mins", GetTimeMinute());
}
void main()
{
object oPC = GetEnteringObject(); //for check triggers
if(!GetIsPC(oPC) return;
int nCurrentHour = GetTimeHour();
int nCurrentMins = GetTimeMinute();
int nElapsedHour = nCurrentHour - GetLocalInt(oPC, "time_hour");
int nElapsedMins = nCurrentMins - GetLocalInt(oPC, "time_mins");
SendMessageToPC(GetFirstPC(), nElapsedHour + " Hours and " + nElapsedMins + " Minutes have passed.");
}
#3
Posté 10 mai 2012 - 03:50
Note that those are game-world hours. In module properties, you can set the number of minutes per hour. There's always 24 hours in a game-day, though.
#4
Posté 10 mai 2012 - 08:57
Uhm... the time elapsed shouldnt ever be visible to the player. I would like the time measures taken to be stored on a variable, So then I could retrieve it after the player has finnished playing.
At this script, the time would be stored at the variables "CurrentHour" and "CurentMins" is that it?
By the way, to retrieve the data after the player finishes the game I was considering to create an object that would "talk" to me those variables. Anyone has a better idea?
Thx dudes :0)
At this script, the time would be stored at the variables "CurrentHour" and "CurentMins" is that it?
By the way, to retrieve the data after the player finishes the game I was considering to create an object that would "talk" to me those variables. Anyone has a better idea?
Thx dudes :0)
#5
Posté 10 mai 2012 - 09:20
Add this to the end of the above - and remove the SendMessage...
SetGlobalInt("total_hours", nElapsedHours);
SetGlobalInt("total_mins", nElapsedMins);
In the retrieval script (which is up to you to develop at this stage) use: GetGlobalInt(...) to retrieve the final total.
As I said this is all just for examples sake - give it a whack and see what you can do
SetGlobalInt("total_hours", nElapsedHours);
SetGlobalInt("total_mins", nElapsedMins);
In the retrieval script (which is up to you to develop at this stage) use: GetGlobalInt(...) to retrieve the final total.
As I said this is all just for examples sake - give it a whack and see what you can do
Modifié par Morbane, 10 mai 2012 - 09:20 .
#6
Posté 10 mai 2012 - 09:23
Remember this as well ^Lugaid of the Red Stripes wrote...
Note that those are game-world hours. In module properties, you can set the number of minutes per hour. There's always 24 hours in a game-day, though.
#7
Posté 10 mai 2012 - 09:52
This, except count up and don't make it visible.
http://nwvault.ign.c...I.Detail&id=141
It's used in the Easter Egg Hunt module.
http://neverwinter.n...ds.com/mods/124
http://nwvault.ign.c...I.Detail&id=141
It's used in the Easter Egg Hunt module.
http://neverwinter.n...ds.com/mods/124
#8
Posté 16 mai 2012 - 09:09
I will check these out, thx!
#9
Posté 12 juin 2012 - 08:35
Hey there,
I'm playing with these functions and just occured me... to recover the data, could I make a character "speak" the amount stored at the variable? How should be the conversation script for this function?
I'm playing with these functions and just occured me... to recover the data, could I make a character "speak" the amount stored at the variable? How should be the conversation script for this function?
#10
Posté 12 juin 2012 - 09:01
Ow...
When I try to compile Morbane's second function (the one for the check triggers) I'm getting this error
"Script1.nss (13): ERROR: ARITHMETHIC OPERATION HAS INVALID OPERANDS".
I tried to erase the "+" signals from 13 line of the function... but what I got was
"Script1.nss (13): ERROR: UNDEFINED IDENTIFIERS"
When I try to compile Morbane's second function (the one for the check triggers) I'm getting this error
"Script1.nss (13): ERROR: ARITHMETHIC OPERATION HAS INVALID OPERANDS".
I tried to erase the "+" signals from 13 line of the function... but what I got was
"Script1.nss (13): ERROR: UNDEFINED IDENTIFIERS"
#11
Posté 12 juin 2012 - 11:01
Second issue first: The SendMessageToPC function needs a string, or strings concatenated together with a '+'. But nElapsedHour is an integer, so you need to use IntToString(nElapsedHour) instead, and likewise for the second variable.
For your conversation, what you need is a custom token. Token are the variables you can throw into conversations, the <sir/madam> things. Custom tokens are set using a script run anytime prior to the actual conversation, so you can add a script to the conversation action tab of the particular line and it will work.
Basically, you just need to use the function SetCustomToken(1234, "string"), where '1234' is the four-digit "tag" of the token, and "string" is whatever bit of text you want to throw into the conversation (like IntToString(nElapsedHours) ). In the conversation, you just write <CUSTOM1234>, with your number in the '1234', and your bit of text will show up.
Custom tokens will also work in the journal, but only update when a new journal entry is added.
For your conversation, what you need is a custom token. Token are the variables you can throw into conversations, the <sir/madam> things. Custom tokens are set using a script run anytime prior to the actual conversation, so you can add a script to the conversation action tab of the particular line and it will work.
Basically, you just need to use the function SetCustomToken(1234, "string"), where '1234' is the four-digit "tag" of the token, and "string" is whatever bit of text you want to throw into the conversation (like IntToString(nElapsedHours) ). In the conversation, you just write <CUSTOM1234>, with your number in the '1234', and your bit of text will show up.
Custom tokens will also work in the journal, but only update when a new journal entry is added.
#12
Posté 13 juin 2012 - 03:02
SendMessageToPC(GetFirstPC(), IntToString(nElapsedHour) + " Hours and " + IntToString(nElapsedMins) + " Minutes have passed.")
This is what LotRS was referring to - sorry 'bout that :\\
This is what LotRS was referring to - sorry 'bout that :\\
#13
Posté 13 juin 2012 - 02:41
Hey Morbane, thanks!
It's working perfectly now! Just one last doubt (I hope so :0)... I would like that the first script (the one that initiates the timer) would run on module start, and only once per game. I noticed that on module properties tab, there is a line where I can choose a script that will run under this conditions... is there any change that has to be made to the script so he can be called from this tab?
It's working perfectly now! Just one last doubt (I hope so :0)... I would like that the first script (the one that initiates the timer) would run on module start, and only once per game. I noticed that on module properties tab, there is a line where I can choose a script that will run under this conditions... is there any change that has to be made to the script so he can be called from this tab?
#14
Posté 13 juin 2012 - 06:38
Give it a try - it should work - I looked up OnModuleLoad and I hope that the player will be recognised by the GetEnteringObject()





Retour en haut






