logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Persistent Locations Using SQLite

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Jul 06, 2006 17:40    Post subject: Persistent Locations Using SQLite Reply with quote

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 Smile )

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
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Thu Jul 06, 2006 21:45    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Jul 06, 2006 22:55    Post subject: Reply with quote

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
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Fri Jul 07, 2006 11:37    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Fri Jul 07, 2006 17:18    Post subject: Reply with quote

Awesome, thank you Rami! Smile

I really appreciate the help.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Fri Jul 07, 2006 18:07    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Fri Jul 07, 2006 19:35    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Sat Jul 08, 2006 2:07    Post subject: Reply with quote

Huh, that's odd. Well, I'll go download it and let you know. Thanks again for the help. Smile
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Sat Jul 08, 2006 2:56    Post subject: Reply with quote

Awesome! Thank you so much Rami! It works great! Smile

I'll be sure to put you in the credits of my module. Smile

Thanks again!
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Sat Jul 08, 2006 12:08    Post subject: Reply with quote

No problem. And I don't need credits really. Just trying to help where I can Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
ballestolive



Joined: 30 Oct 2006
Posts: 22
Location: FRENCH

PostPosted: Mon Oct 30, 2006 21:55    Post subject: Reply with quote

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.

Confused Crying or Very sad
Thank for your help.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Wed Nov 01, 2006 16:32    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
ballestolive



Joined: 30 Oct 2006
Posts: 22
Location: FRENCH

PostPosted: Wed Nov 01, 2006 20:20    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group