View previous topic :: View next topic |
Author |
Message |
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Fri Dec 15, 2006 23:14 Post subject: [Ask for Help] Your help for the documentation |
|
|
Hello, I'm thinking about integrate some concrete example of use about the function in NWNX4.
Could you, please, help me to write, in this post, some example ?
Something like :
"I want to put a persistent box to my module for allowing PC to stock their equipement...so i wrote a script like that :....SQLExecuteDirect here allow my to make a request...."
If each member put just one example, i'm sure we could have a sufficient panel to show to beginner how to use NWNX4...
Thanks for your help |
|
Back to top |
|
|
Grinning Fool
Joined: 12 Feb 2005 Posts: 264
|
Posted: Sat Dec 16, 2006 2:22 Post subject: |
|
|
Place this in your "on PC loaded" script:
Code: |
#include "nwnx_sql"
void main()
{
object oPC = GetEnteringObject();
location loc = GetPersistentLocation(oPC, "exitloc");
if (GetIsObjectValid(GetAreaFromLocation((loc))) {
AssignCommand(oPC, ActionJumpToLocation(loc));
}
}
|
And place this in your On Client Exit* script:
Code: |
#include "nwnx_sql"
void main()
{
object oPC = GetExitingObject();
location loc = GetLocation(oPC);
if (GetIsObjectValid(GetAreaFromLocation((loc))) {
SetPersistentLocation(oPC, "exitloc", loc);
}
}
|
* caveat: I seem to recall that NWN had some dififculty in that the PC's location was no always valid by the time the PC logged off. I haven't tested this under NWN2; if anyone has and it's still an issue, pl. let me know and I'll provide a different method. _________________ Khalidine, a NWN2 persistent world
Looking for volunteers.
Last edited by Grinning Fool on Mon Dec 18, 2006 5:37; edited 2 times in total |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Sun Dec 17, 2006 10:57 Post subject: |
|
|
thanks for your help ! |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Sun Dec 17, 2006 11:27 Post subject: |
|
|
That is a very good idea. A collection of 5-6 short examples that are easy to understand would be very helpful for newcomers. They would not need to belong to the DB department alone, the Time demo plugin for example demonstrates a nice use of the Timer plugin. _________________ Papillon |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Mon Dec 18, 2006 4:47 Post subject: |
|
|
Quote: | the Time demo plugin for example demonstrates a nice use of the Timer plugin |
If Grinning fool is agreee we could take one of his script in the demo module to demonstrate it...After you will can add this exemple to the timer plugin documentation... |
|
Back to top |
|
|
Grinning Fool
Joined: 12 Feb 2005 Posts: 264
|
Posted: Mon Dec 18, 2006 5:43 Post subject: |
|
|
caloup wrote: | Quote: | the Time demo plugin for example demonstrates a nice use of the Timer plugin |
If Grinning fool is agreee we could take one of his script in the demo module to demonstrate it...After you will can add this exemple to the timer plugin documentation... |
Sure, that's what it's there for. _________________ Khalidine, a NWN2 persistent world
Looking for volunteers. |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Tue Dec 19, 2006 17:02 Post subject: |
|
|
So here his an exammple of using timer plugin :
Quote: |
// Name : e_trig_enter
// Purpose : Fires when the PC pulls the lever.
// Authors : Grinning Fool [Marc Paradise]
// Modified : December 6th, 2006
#include "nwnx_time"
void main()
{
AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
object oPC = GetLastUsedBy();
int id = GetLocalInt(OBJECT_SELF, "id");
int state = GetLocalInt(OBJECT_SELF, "state");
string name = "Timer" + IntToString(id);
string time;
if (state) {
time = StopTimer(OBJECT_SELF, name);
SendMessageToPC(oPC, name + " has been stopped.");
SendMessageToPC(oPC, "Time since you started " + name + ": " + time + " microseconds");
SetFirstName(OBJECT_SELF, "Start " + name);
} else {
SendMessageToPC(oPC, name + " has been started.");
StartTimer(OBJECT_SELF, name);
SetFirstName(OBJECT_SELF, "Stop " + name);
}
SetLocalInt(OBJECT_SELF, "state", !state);
}
|
I think you could add this example in the documentation of timer plugin pap's. :
Perhaps you could add a note about the possibility to use this in a quest or a mini game...
For example, in a quest you could ask one or more player to activate a number of switch defined in the script (5 for example, placed in different position in the map) and the script verify "timelastswitch" - "timefirstswitch" if it's inferior to a number defined in seconde (15s for example) then a door could be open, unless the lever are reset...It could make that a quest must be done by 2 or more player !...
Another example, you place a mini game with a little labyrinth with a trigger in the beginning of the labyrinth and another in the end...If player make less than the time you're asking to do, then i won ! |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Sun Dec 31, 2006 19:42 Post subject: |
|
|
just a litle up for this post !
No other idea ?
Could some one post some exemple for the use of SetPersistentInt (string and or location ?) |
|
Back to top |
|
|
amphiprion
Joined: 07 Nov 2006 Posts: 44 Location: Toulouse (France)
|
Posted: Mon Jan 01, 2007 1:29 Post subject: |
|
|
Grinning Fool wrote: | I seem to recall that NWN had some dififculty in that the PC's location was no always valid by the time the PC logged off. I haven't tested this under NWN2; if anyone has and it's still an issue, pl. let me know and I'll provide a different method. |
like Nwn1 when you Exit, in the OnModuleExit script, nwn2 don't have a valid location. |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Mon Jan 01, 2007 9:47 Post subject: |
|
|
Quote: |
I seem to recall that NWN had some dififculty in that the PC's location was no always valid |
could that be because of where you put the script ?
Because if the script is onclientleave...Perhaps it's lauching when the PC is already gone ! So there is'nt any valid location to save... |
|
Back to top |
|
|
amphiprion
Joined: 07 Nov 2006 Posts: 44 Location: Toulouse (France)
|
Posted: Mon Jan 01, 2007 13:50 Post subject: |
|
|
yes, it is the problem. |
|
Back to top |
|
|
Grumalg
Joined: 04 Nov 2005 Posts: 70
|
Posted: Tue Jan 02, 2007 3:35 Post subject: |
|
|
It is true that the PC object is no longer a valid PC at client leave and thus no longer has a valid location. But you can still access local variables stored on a pc at client leave by useing GetExitingObject(). So if you have maintained a local var copy of location and kept it updated you can get a useable location that way. This is also true for any other local vars kept on the PC.
--- Grumalg --- |
|
Back to top |
|
|
Grinning Fool
Joined: 12 Feb 2005 Posts: 264
|
Posted: Tue Jan 02, 2007 15:47 Post subject: |
|
|
Grumalg wrote: | It is true that the PC object is no longer a valid PC at client leave and thus no longer has a valid location. But you can still access local variables stored on a pc at client leave by useing GetExitingObject(). So if you have maintained a local var copy of location and kept it updated you can get a useable location that way. This is also true for any other local vars kept on the PC.
--- Grumalg --- |
Yes, that's the route I took. On server heartbeat, I'd update a local location on the PC, since that's a fairly low-cost operation. Once the PC logged out, I would use the value retrieved from the local variable to save it to DB. _________________ Khalidine, a NWN2 persistent world
Looking for volunteers. |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Tue Jan 02, 2007 20:25 Post subject: |
|
|
Ok i note that idea for the FAQ... |
|
Back to top |
|
|
|