View previous topic :: View next topic |
Author |
Message |
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Thu Jul 06, 2006 17:40 Post subject: Persistent Locations Using SQLite |
|
|
Hello! I have searched through the forum and haven't been able to find exactly what I am looking for. I would like to request a few scripts to save the locations of my players either using a OnHeartbeat or OnRest. I am using SQLite and would like the CD-Key to be attached to the saved location of the players (so that players with the same name won't be sent to someone else's location )
I can't say I know a whole lot of what all needs to be done, but if you need more information I'd be happy to give you it.
Thanks a ton!
Zunath
Dead Jester Entertainment
Last edited by Zunath on Sun Jun 25, 2017 5:25; edited 1 time in total |
|
Back to top |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Thu Jul 06, 2006 21:45 Post subject: |
|
|
If you make sure to include the aps script (to your OnRest script) like so: Code: | #include "aps_include" | , ie you put that line in the top of the OnRest script, then below the 'void main ()' you add:
Code: | object oPC = GetLastPCRested();
if (GetIsObjectValid(oPC) && GetIsPC(oPC))
{ SetPersistentLocation(oPC, "PlayerLocation", GetLocation(oPC));
}
|
Then to your OnEnter script, add (If you want players to, when logging in, instantly go to their previous rested spot):
Code: | object oPC = GetEnteringObject();
if (GetIsObjectValid(oPC) && GetIsPC(oPC) && !GetIsDM(oPC))
{ location lPCLoc = GetPersistentLocation(oPC, "PlayerLocation");
AssignCommand(oPC, JumpToLocation(lPCLoc));
} |
Remember to include the aps_include script there, too.
You might not need to define oPC everytime depending on what script your currently using.
Good luck. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Thu Jul 06, 2006 22:55 Post subject: |
|
|
Wow! Thanks! Didn't expect such a fast reply. I am having a problem, however.
I don't have a script OnRest already (but I may in the future) and am recieving this error when I copy and paste that code into the script: 7/6/2006 4:53:20 PM: Error. 'save_location' did not compile.
save_location.nss(4): ERROR: INVALID DECLARATION TYPE
Sorry, but I know next to nothing about scripting (aside from using ExecuteScript).
Thanks again for the help! |
|
Back to top |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Fri Jul 07, 2006 11:37 Post subject: |
|
|
Right. If you dont have any resting script. This will be your full script:
Code: | #include "aps_include"
void main()
{ object oPC = GetLastPCRested();
if (GetIsObjectValid(oPC) && GetIsPC(oPC))
{ SetPersistentLocation(oPC, "PlayerLocation", GetLocation(oPC));
}
} |
Good luck. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Fri Jul 07, 2006 17:18 Post subject: |
|
|
Awesome, thank you Rami!
I really appreciate the help. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Fri Jul 07, 2006 18:07 Post subject: |
|
|
I seem to be having problems...
The only script on the starting area's OnEnter is:
Script Name: load_locations
Code: | #include "aps_include"
// This script will send a player to their last saved position (normally OnRest)
void main()
{object oPC = GetEnteringObject();
if (GetIsObjectValid(oPC) && GetIsPC(oPC) && !GetIsDM(oPC))
{ location lPCLoc = GetPersistentLocation(oPC, "PlayerLocation");
AssignCommand(oPC, JumpToLocation(lPCLoc));
}
} |
This is my OnRest script:
Script Name: save_locations
Code: | #include "aps_include"
void main()
{ object oPC = GetLastPCRested();
if (GetIsObjectValid(oPC) && GetIsPC(oPC))
{ SetPersistentLocation(oPC, "PlayerLocation", GetLocation(oPC));
}
} |
I checked in my SQLite database and there are no tables there - should there be?
Sorry for all these problems, and thanks again for your time. |
|
Back to top |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Fri Jul 07, 2006 19:35 Post subject: |
|
|
You should by default have 2 tables, I know next to nothing in setting up tables or anything but if you dont have the tables you can go to my shop script on the vault (link in sig) and download the "nwnx2 files", which have the pre-made tables.
Last edited by Rami_Ahmed on Sat Jul 08, 2006 12:09; edited 1 time in total |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Sat Jul 08, 2006 2:07 Post subject: |
|
|
Huh, that's odd. Well, I'll go download it and let you know. Thanks again for the help. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Sat Jul 08, 2006 2:56 Post subject: |
|
|
Awesome! Thank you so much Rami! It works great!
I'll be sure to put you in the credits of my module.
Thanks again! |
|
Back to top |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Sat Jul 08, 2006 12:08 Post subject: |
|
|
No problem. And I don't need credits really. Just trying to help where I can |
|
Back to top |
|
|
ballestolive
Joined: 30 Oct 2006 Posts: 22 Location: FRENCH
|
Posted: Mon Oct 30, 2006 21:55 Post subject: |
|
|
Hello, I use this script in my module but I have a problems.
The location are not save and the file nwnx_odbc log this:
NWNX ODBC2 plugin V.0.9.2.4
(c) 2005 by Ingmar Stieger (Papillon) and Jeroen Broekhuizen
visit us at http://www.nwnx.org
o Logfile maximum size limit is: 524288 bytes
o Log level: Only errors will be logged.
o Using MySQL connection.
o Hooking SCO....hooked at 5d3560
o Hooking RCO....hooked at 5d3440
o Connect successful.
! SQL Error: Data too long for column 'PLAYERLOCATION' at row 1
! SQL Error: Data too long for column 'PLAYERLOCATION' at row 1
! SQL Error: Data too long for column 'PLAYERLOCATION' at row 1
! SQL Error: Data too long for column 'PLAYERLOCATION' at row 1
o Disconnecting from database.
Thank for your help. |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Wed Nov 01, 2006 16:32 Post subject: |
|
|
The actual SQL statement is not included in the log file, but it looks like the table you have set up to store the locations is not entirely correct. Try to make the PLAYERLOCATION column longer.
You could also set up nwnx to log everything, not only errors. That might point to the problem as well. _________________ Papillon |
|
Back to top |
|
|
ballestolive
Joined: 30 Oct 2006 Posts: 22 Location: FRENCH
|
Posted: Wed Nov 01, 2006 20:20 Post subject: |
|
|
OK, it's good. I found, in made the error came from the value of VARCHAR which was to 100 where as the LOCATION takes approximately 150 characters.
Thank for your help.
And excuse me bad english. |
|
Back to top |
|
|
|