Also, items removed from the inventory like to reappear in the objects after a few minutes. After running this script several times, I relogged, and had atleast 20 scripts named "Old Script" in the objects inventory. All of those scripts gave a database error when opened. Along with those, there were several old, removed yet returned, copies of 'InvTest'(the name of the included script), all of which opened with no problem. This suggests that RemoveInventory, even when given a valid script (or object?) name, still fails to remove the script completley.
Nothing horribly complex, just testing functions. Requires the key of another object, and said object to have its Script Pin set to 9999.
Script name : InvTest
CODE
key target = "72ac3020-2dcd-67ef-dbc2-81cbdb3ce405";
default
{
state_entry()
{
string extra = "source";
integer param = llGetStartParameter();
if(param) extra = "target";
llSetObjectName(extra);
llOwnerSay("Testing : " + extra);
llOwnerSay("GetScriptState = \"" + (string)llGetScriptState("InvTest") + "\"");
//Likley to return an incorrect state ( 0 when it should be 1 )
llOwnerSay("GetInventoryType = \"" + (string)llGetInventoryType("InvTest") + "\"");
//Seems to always return 10, which is correct,
//but it seems odd, as nothing else is working
llOwnerSay("llGetScriptName = \"" + llGetScriptName() + "\"");
// Likley to reurn NULL
llGiveInventory(llGetKey(),"InvTest");
// Occasionally not found
if(llGetStartParameter() != 1)
{
llRemoteLoadScriptPin(target,"InvTest",9999,TRUE,1);
//Seems to work, although sometimes only on 2nd try. It also
//takes several minutes for changes to the script to get
//noticed by this function. The target seems to get an old
//compile of the script.
llSleep(2);
}
else
llSleep(5);
llOwnerSay("Removing...");
llRemoveInventory(llGetScriptName());
// Sometimes works after delay.
//Still seems unreliable. llGetScriptName often returns NULL
//and a warning message will appear when it cant find inventory with that name.
//Also. scripts seem to reappear after they are removed!
//Half the time the reappearing scripts are called "Old Script", which are
//missing from the asset server when you try to open them.
}
}
Now, I can add more sleeps into the script, which seems to help go along working, but even with large pauses, the functions are still rather intermittant. Does anyone have a clue what's going on, or is the asset server just slowly dying and dragging scripts down with it?
Edit: Example output when I run it.
source: Testing : source
source: GetScriptState = "1"
source: GetInventoryType = "10"
source: llGetScriptName = ""
target: Testing : target
target: GetScriptState = "0"
target: GetInventoryType = "10"
target: llGetScriptName = ""
source: Removing...
[Script error/warning source: Missing inventory item '' ]
target: Removing...
[Script error/warning target: Missing inventory item '' ]
;
Never thought I'd have to check if llGetScriptName() existed in the inventory before getting info on it.