Transitioning with a summons crashes server
#1
Posté 24 mars 2011 - 01:52
The script is supposed to destroy leftover encounter creatures and reset the encounters. I don't want to touch loot bags or placeables.
void main()
{
object oTarget = GetFirstObjectInArea();
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oTarget);
if (GetIsObjectValid(oPC) == TRUE) return;
while (GetIsObjectValid(oTarget) == TRUE)
{
if (GetIsEncounterCreature(oTarget) == TRUE)
{
DestroyObject(oTarget);
}
if (GetObjectType(oTarget) == OBJECT_TYPE_ENCOUNTER)
{
SetEncounterActive(TRUE, oTarget);
}
oTarget = GetNextObjectInArea();
}
}
#2
Posté 24 mars 2011 - 02:24
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oTarget);
since some patch probably 1.69 this behaves differently than it used to, in past this returned any PC dead or alive but now this line acts as you would set the second parameter to IS_ALIVE and TRUE
to be sure that there is nobody in area you must also try is there is any dead PC using IS_ALIVE and FALSE in second parameter
but i dont know if this fixes your crashing problem, I didnt even though its possible to crash a server via nwscript anymore...
#3
Posté 24 mars 2011 - 02:43
A check will not hurt even if it is not what is causing your crash. The way the script is currently written it is checking for a clean every time you kill a creature in the area. It is a total waste of cpu time.
#4
Posté 24 mars 2011 - 03:09
Is this version any better?
void main()
{
object oExiting = GetExitingObject();
object oTarget = GetFirstObjectInArea();
if (GetIsPC(oExiting))
{
while (GetIsObjectValid(oTarget) == TRUE)
{
if (GetIsPC(oTarget))
{
return;
}
if (GetIsEncounterCreature(oTarget) == TRUE)
{
DestroyObject(oTarget);
}
if (GetObjectType(oTarget) == OBJECT_TYPE_ENCOUNTER)
{
SetEncounterActive(TRUE, oTarget);
}
}
oTarget = GetNextObjectInArea();
}
}
#5
Posté 24 mars 2011 - 03:11
ShaDoOoW wrote...
I didnt even though its possible to crash a server via nwscript anymore...
Nice to know I can achieve the impossible :innocent:
#6
Posté 24 mars 2011 - 04:36
Tassie Wombat wrote...
Thanks for the responses. Lightfoot8 I completely missed that I had removed the check for oPC being the exiting object ... that's what I get for cobbling several scripts together at 2am.
Is this version any better?
void main()
{
object oExiting = GetExitingObject();
object oTarget = GetFirstObjectInArea();
if (GetIsPC(oExiting))
{
while (GetIsObjectValid(oTarget) == TRUE)
{
if (GetIsPC(oTarget))
{
return;
}
if (GetIsEncounterCreature(oTarget) == TRUE)
{
DestroyObject(oTarget);
}
if (GetObjectType(oTarget) == OBJECT_TYPE_ENCOUNTER)
{
SetEncounterActive(TRUE, oTarget);
}
}
oTarget = GetNextObjectInArea();
}
}
Nope, That one is worse.
You will get a TMI error when the script runs. The changing of oTarget is out side of the while loop.
It will destroy encounter creatures untill it hits a PC even if the oTarget is inside of the loop. You need to verify that a PC is not in the area before you start destroying any creatures.
#7
Posté 24 mars 2011 - 05:35
Finally managed to find a script on the old forums by Axe Murderer. I'll stick that in and give it a whirl. If everything suddenly works perfectly fine (as I suspect it now will) then I will pull the script apart line by line and figure out how it's done.
Again, thank you for your help.





Retour en haut






