Jump to content

Npc Respawn


jacksonl

Recommended Posts

You have no && between Gamehour == 6 and GetDayofWeek == 3.

 

 

Hmm, I fixed the && it but no dice.

Now, no one is spawning.

I don't think it likes the Gamehour next to the GetDayofWeek.

If you have any ideas get back to me when you can!

 

Thank you JJ

 

 

Edit: I brought it into the Cipscis code checker and it said:

 

int Respawn -- Error: Variable declaration illegal within Begin/End block

Edited by jacksonl
Link to comment
Share on other sites

Okay did some testing, I think the main problem is that gamehour is unlikely to ever be exactly 12 or 6 (unless you actually wait for it to be exactly 12:00:00). So here is a script that works from 12-1PM and I've made a variable for each Ref:

scn ScriptName
 
Begin GameMode
 
int Respawn
int Respawn2
int Respawn3
 
If GameHour >= 12 && GameHour <= 13 && GetDayOfWeek == 0 || GetDayOfWeek == 3
 
ShowMessage TestMSG1
 
If ActorRef1.GetDead == 1 && Respawn == 0
ActorRef1.Resurrect
Set Respawn to 1
endif
 
If ActorRef2.GetDead == 1 && Respawn2 == 0
ActorRef2.Resurrect
Set Respawn2 to 1
endif
 
If ActorRef3.GetDead == 1 && Respawn3 == 0
ActorRef3.Resurrect
Set Respawn3 to 1
endif 
else
 
Set Respawn to 0
Set Respawn2 to 0
Set Respawn3 to 0
 
endif
 
end
Edited by JJ2198
Link to comment
Share on other sites

The script above is flawed in a few ways and it seems that much of it is unnecessary. A much more concise code block that does that has the same function with some fixes would be as follows;

 

scn ScriptName

int DoOnce

Begin GameMode

If GetDayOfWeek == 2
   set DoOnce to 0
endif

   If GameHour >= 12 && GameHour <= 13 && GetDayOfWeek == 0 || GetDayOfWeek == 3 && DoOnce == 0

ShowMessage TestMSG1

If ActorRef1.GetDead == 1
   ActorRef1.Resurrect
endif

If ActorRef2.GetDead == 1
   ActorRef2.Resurrect
endif

If ActorRef3.GetDead == 1
   ActorRef3.Resurrect
endif 

   set DoOnce to 1
endif

end

First off, integers must be defined outside of the "Begin" function, or an error will follow. Second, the "respawn" integers you currently have serve no real purpose, as they are immediately redefined to fit all perimeters. Lastly, say the player were to kill the NPCs during that hour of gametime; the NPCs would immediately respawn. I simple fix is running this code once, and setting it up to run again on the day before the scheduled respawn cycle.

Link to comment
Share on other sites

You forgot to remove the Showmessage (that I accidentally left in, lol). Though this script works, from what I can see it will only run on Wednesday as DoOnce isn't set to 0 again until Tuesday making it so Sunday doesn't work (expect for the first time if after Wednesday). Also it is fine to use variables inside a block, though you can do it outside if you want to share them between different blocks.

 

So something like this would be better:

 
scn ScriptName
 
int DoOnce
 
Begin GameMode
 
If GetDayOfWeek == 2 || GetDayOfWeek == 4
   set DoOnce to 0
endif
 
   If GameHour >= 12 && GameHour <= 13 && GetDayOfWeek == 0 || GetDayOfWeek == 3 && DoOnce == 0
 
If ActorRef1.GetDead == 1
   ActorRef1.Resurrect
endif
 
If ActorRef2.GetDead == 1
   ActorRef2.Resurrect
endif
 
If ActorRef3.GetDead == 1
   ActorRef3.Resurrect
endif 
 
   set DoOnce to 1
endif
 
end
 
Edited by JJ2198
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...