Database on an item?
#1
Posté 07 décembre 2010 - 10:21
I sorta tried that with a normal database but most wouldn't really compile with my current scripts.
So anyone have a script for me that can do that for me?
at any rate thanks!
~Who said that I
#2
Posté 07 décembre 2010 - 05:03
Funky
#3
Posté 07 décembre 2010 - 05:19
Might be me asking it wrong really, my english is not the greatest ^^
But this is my issue:
We do not have a database here really other than the quest database that is stacking on our dicebag,
so what I was wondering: Can a player's HP be saved on an item like this? That if the player has died and the server resets so it will not have its 100% of its health again? Like the item would be the database that will remember and stores everything the player does with his character. That even cheating by logging out and in or waiting for server reset won't really help?
Maybe this will make it a bit clearer to get an answer on my question maybe?
#4
Posté 07 décembre 2010 - 06:51
#5
Posté 07 décembre 2010 - 08:27
#6
Posté 07 décembre 2010 - 08:37
Are you asking for scripts to set up a system like this? Or do you already have the scripting in place?
Modifié par GhostOfGod, 07 décembre 2010 - 08:37 .
#7
Posté 07 décembre 2010 - 09:02
Though I then really need to ask: Would it also store like the current affliction on it and stuff? Like if the player is diseased or has a stat penalty?
#8
Posté 07 décembre 2010 - 09:44
object oPC = GetEnteringObject();
object oStorage = GetItemPossessedBy(oPC, "pc_storage");
if (!GetIsObjectValid(oStorage)) {
oStorage = CreateItemOnObject("pc_storage", oPC);
SetItemCursedFlag(oStorage, TRUE);
}
Then, whenever you would set or get a variable on the pc, instead get the storage item and set it on that instead, using GetItemPossessedBy(oPC, "pc_storage"); As mentioned, you'll want to ExportSingleCharacter(oPC); after you do this.
So, instead of:
SetLocalInt(oPC, "SomeVarName", 3);
you would do:
object oStorage = GetItemPossessedBy(oPC, "pc_storage"); SetLocalInt(oStorage, "SomeVarName", 3);
This is no where near as difficult as you seem to think it should be.
Funky
#9
Posté 07 décembre 2010 - 09:58
#10
Posté 07 décembre 2010 - 10:01
Funky
#11
Posté 07 décembre 2010 - 10:04
object oPC = GetExitingObject(); int nHP = GetCurrentHitPoints(oPC); object oStorage = GetItemPossessedBy(oPC, "pc_storage"); SetLocalInt(oStorage, "HPAmount", nHP);If that makes sense (hopefully my scripting memory is working today). You'd then use "GetLocalInt" with the stored string "HPAmount" to return it.
EDIT: Already answered, nevermind!
Modifié par Rubies, 07 décembre 2010 - 10:04 .
#12
Posté 07 décembre 2010 - 10:04
Not only me but also for the other builders and scripters on the team!
Just ask and they will burst out in tears!! ^^
#13
Posté 07 décembre 2010 - 10:07
Funky
#14
Posté 07 décembre 2010 - 10:18
We have a similar system set up for the quests, a bit more complicated than this but it looks rather similar, but what we do notice is that the players who made a new character get the storage item at entering and the once who were build "before" we used this system didn't get it at each entering.
So my question would be: Would it still be working if the player had to buy the item from a widget merchant? If not, well then I kindly ask for help on this matter since I had a lot of complains about it lately and I do not really know how to solve this myself
#15
Posté 07 décembre 2010 - 10:22
Funky
#16
Posté 07 décembre 2010 - 10:57
#17
Posté 07 décembre 2010 - 11:02
Not true. Player characters are automatically saved a moment before OnClientExit event.GhostOfGod wrote...
You also need to export (save) that character immediately after so that that info sticks to the item. Otherwise if the player logs out before a server wide save or some auto save then the player will have whatever hp was on the item before.
#18
Posté 07 décembre 2010 - 11:08
The scripts I gave you will compile, if you managed to re-capitalize all the instances of 'class'. What error are you getting, on what line?Who said that I wrote...
okay it doesn't wanna compile with the prc locker you have send me earlier....would it also work if I put it in an execute file or an include?
Funky
#19
Posté 07 décembre 2010 - 11:09
That's what I was driving at when I posted this:ShaDoOoW wrote...
Not true. Player characters are automatically saved a moment before OnClientExit event.GhostOfGod wrote...
You also need to export (save) that character immediately after so that that info sticks to the item. Otherwise if the player logs out before a server wide save or some auto save then the player will have whatever hp was on the item before.
I probably should have spelled it out more clearly to start with.Don't forget to do the ExportSingleCharacter(oPC), per GoG's suggestion -
that's the only thing missing from Rubies' example. The character will
be saved anyway, when they exit the server, so it isn't strictly
necessary to do the export, but this will prevent loss of the variable
from a crash, should one happen before they log out.
Funky
#20
Posté 07 décembre 2010 - 11:10
Then what about a crash? Crashes are one of the most annoying things in a server, what we notice is that sometimes the player might actually lose something he had gained in the moment just before the crash or a few moments before.ShaDoOoW wrote...
Not true. Player characters are automatically saved a moment before OnClientExit event.GhostOfGod wrote...
You also need to export (save) that character immediately after so that that info sticks to the item. Otherwise if the player logs out before a server wide save or some auto save then the player will have whatever hp was on the item before.
#21
Posté 07 décembre 2010 - 11:44
Wow. All this time and I never knew that.Player characters are automatically saved a moment before OnClientExit event.
There have been times I have logged off of servers and come back to find that items I've had or info stored were gone or unstored. So then I must have logged out at the exact moment of crashes?
Is this a hard coded and reliable thing?
Also, does booting a player automatically trigger the OnClientExit thus saving the character as well?
Modifié par GhostOfGod, 07 décembre 2010 - 11:46 .
#22
Posté 07 décembre 2010 - 11:47
Crash will of course not save the characters, thats why all of them loose progress. To protect your players agains it, thats different question. In short: you need to save them all automatically after some time and/or when (un)acquire items.Who said that I wrote...
Then what about a crash? Crashes are one of the most annoying things in a server, what we notice is that sometimes the player might actually lose something he had gained in the moment just before the crash or a few moments before.ShaDoOoW wrote...
Not true. Player characters are automatically saved a moment before OnClientExit event.GhostOfGod wrote...
You also need to export (save) that character immediately after so that that info sticks to the item. Otherwise if the player logs out before a server wide save or some auto save then the player will have whatever hp was on the item before.
Funky: it was clear, I just hadnt this thread refreshed, started with reply few hours after I send it
#23
Posté 07 décembre 2010 - 11:51
Yes, and yes. It DOES occasionally fail - I've noted the same thing as you - but it appears to fail only about 1 time in a couple hundred or so, for reasons I've never been able to divine. I think the failures were more frequent in older patches, as I've noticed it far less of late, but I have no scientific data to back that up, just a personal guestimate.GhostOfGod wrote...
Is this a hard coded and reliable thing?
Also, does booting a player automatically trigger the OnClientExit thus saving the character as well?
Funky
#24
Posté 07 décembre 2010 - 11:55
~Player finishes a quest
~Player receives an item from quest
~Every time a player rests
~Every time a player enters a new area or some trigger
~When you want to store specific information on player item(like HP)
And the list gos on. Really its up to the builder to decide when it is important to export and save the players.
#25
Posté 08 décembre 2010 - 05:16
FunkySwerve wrote...
The scripts I gave you will compile, if you managed to re-capitalize all the instances of 'class'. What error are you getting, on what line?Who said that I wrote...
okay it doesn't wanna compile with the prc locker you have send me earlier....would it also work if I put it in an execute file or an include?
Funky
if (!GetIsObjectValid(oStorage)) { <- is what the script gen is saying is wrong and it gives this error -> ERROR: INVALID DECLARATION TYP





Retour en haut







