Author Topic: saving LocalInt permanent  (Read 5427 times)

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
saving LocalInt permanent
« on: January 10, 2005, 06:04:25 AM »
Another riddle  :D

I want to store a LocalInt on a player permanent so even when the module reloads or the player relogs this LocalInt can be retrieved.

I want to use that LocalInt for giving access to a gate. I use an item that can be activated on a player and a script sets a LocalInt on him (SetLocalInt...)
So far the script works fine but when the player relogs or the module is reloaded or offline the LocalInt is gone and the player has no access to that gate anymore.

Oh and btw, how can I BAN someone for a specific time just by activating an item on him?  :blink:   :blink:
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
saving LocalInt permanent
« Reply #1 on: January 10, 2005, 11:46:15 AM »
Quote
Another riddle  :D

I want to store a LocalInt on a player permanent so even when the module reloads or the player relogs this LocalInt can be retrieved.

I want to use that LocalInt for giving access to a gate. I use an item that can be activated on a player and a script sets a LocalInt on him (SetLocalInt...)
So far the script works fine but when the player relogs or the module is reloaded or offline the LocalInt is gone and the player has no access to that gate anymore.

Oh and btw, how can I BAN someone for a specific time just by activating an item on him?  :blink:   :blink:
[snapback]15214[/snapback]
Easy answer, use a sql databse for it :P
I linked everything you need somewhere in the script forum and arivs forum, just check that. [snapback]14762[/snapback][snapback]15079[/snapback]

Still, you need some basic understandings of sql databases, obcd connections and for best rezults I recommend useing unix/linux operating systems.

Also banning for a specific time is possible but It's harder to script. If you want to make those things, and you only know a bit nwnscript, you'll have to learn a "few" things. If you're familiar with sql and a program langue like C or php that can acces databases, you won't have problems setting up what you want on nwn, it all works a bit in the same way.

Be sure to check the link. Also to manage the sql I use phpmyadmin. It needs a webserver (apache for example) with php supporting mysql. And the mysql database. But it makes my life to manage my databases way easyer and it works like a charm :)

Last think, I'm not someone offering a service to support you running those things. You can ask questions about it, but I 'may not be able to'/'may not want to'/'may be too busy' to answer any of them.

-Mel

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
saving LocalInt permanent
« Reply #2 on: January 10, 2005, 03:08:45 PM »
Quote
Quote
Another riddle  :D

I want to store a LocalInt on a player permanent so even when the module reloads or the player relogs this LocalInt can be retrieved.

I want to use that LocalInt for giving access to a gate. I use an item that can be activated on a player and a script sets a LocalInt on him (SetLocalInt...)
So far the script works fine but when the player relogs or the module is reloaded or offline the LocalInt is gone and the player has no access to that gate anymore.

Oh and btw, how can I BAN someone for a specific time just by activating an item on him?  :blink:   :blink:
[snapback]15214[/snapback]
Easy answer, use a sql databse for it :P
I linked everything you need somewhere in the script forum and arivs forum, just check that. [snapback]14762[/snapback][snapback]15079[/snapback]

Still, you need some basic understandings of sql databases, obcd connections and for best rezults I recommend useing unix/linux operating systems.

Also banning for a specific time is possible but It's harder to script. If you want to make those things, and you only know a bit nwnscript, you'll have to learn a "few" things. If you're familiar with sql and a program langue like C or php that can acces databases, you won't have problems setting up what you want on nwn, it all works a bit in the same way.

Be sure to check the link. Also to manage the sql I use phpmyadmin. It needs a webserver (apache for example) with php supporting mysql. And the mysql database. But it makes my life to manage my databases way easyer and it works like a charm :)

Last think, I'm not someone offering a service to support you running those things. You can ask questions about it, but I 'may not be able to'/'may not want to'/'may be too busy' to answer any of them.

-Mel
[snapback]15239[/snapback]
mel, thanks for your help (as usual) but I fear this will be too complicated for me too understand.
I thought there must be an easier way.
I have a blackboard in our module where players can leave messages. These messages remain even after the mod reloads. Is there a way to do the same with LocalInts???
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
saving LocalInt permanent
« Reply #3 on: January 10, 2005, 08:47:40 PM »
Quote
mel, thanks for your help (as usual) but I fear this will be too complicated for me too understand.
I thought there must be an easier way.
I have a blackboard in our module where players can leave messages. These messages remain even after the mod reloads. Is there a way to do the same with LocalInts???
[snapback]15263[/snapback]
That board use things like GetCampaingString and SetCampaignString (string,int,ect..). They work like GetLocalString and SetLocalString. With the difference you don't apply it to a object but a string named to a database. (if the database doesn't exist it gets created)

It works different when you wish to delete a entry, with DeleteCampaignVariable, it won't even delete but just flag as deleted (makes huge db files) and deletes all types it mach for (string,int,ect..).

You also can use StoreCampaignObject to store a object in the database and get it back with RetrieveCampaignObject. And to end, you can delete the whole database with DestroyCampaignDatabase.

I didn't knew these function were used for a database :P it's also new for me. The database itself gets stored in the directory "database" in your nwserver's root directory. You can know what database is used for what thing as it's named to the string you enter in the nwnfunction like GetCampaingString.

It's quite limited and it can't do as much as the sql database (and it's not suited for useing a lot). Making a ban list prolly is ok with it, writing a load of data that has to be changed daily is bad idea. (use sql for that)  But as it's provided standard with the game and it's easy to use, you better take that for your idea's.

If you plan to use sql later you still can convert the .dbf database to a sql one (if you have a tool for it) Also, remeber that when you say to delete a entry it stays in the database, it just get's flagged as 'deleted'. This will make huge databases if you use it a lot. Making things slower and eating resources. I think there's no way to delete a existing entry so that it doesn't exist in the database anymore, if someone has a idea to do it, I'd like to know.

And btw, if you know you have something that can store code in your mod and could slove your problem ... why you don't look at it's code  :glare:

About tools for the databse outside nwn, I only have good comercial editors/vieuwers. The only opensource one I found is way too limited to be useful and needs gtk+ installed on your system. You can find it here http://sourceforge.net/projects/gtkdbfeditor/

-Mel