JJ2198 Posted June 26, 2014 Share Posted June 26, 2014 You have no && between Gamehour == 6 and GetDayofWeek == 3. Link to comment Share on other sites More sharing options...
jacksonl Posted June 27, 2014 Author Share Posted June 27, 2014 (edited) 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 June 27, 2014 by jacksonl Link to comment Share on other sites More sharing options...
JJ2198 Posted June 27, 2014 Share Posted June 27, 2014 (edited) 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 June 27, 2014 by JJ2198 Link to comment Share on other sites More sharing options...
BitsOBacon Posted June 27, 2014 Share Posted June 27, 2014 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 More sharing options...
JJ2198 Posted June 27, 2014 Share Posted June 27, 2014 (edited) 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 June 27, 2014 by JJ2198 Link to comment Share on other sites More sharing options...
BitsOBacon Posted June 27, 2014 Share Posted June 27, 2014 The "Variable declaration illegal within Begin/End block" error comes from defining an int inside a Begin block, so you MUST declare it at the beginning. I didn't see the other day to reset the DoOnce, but the concept still remains. Link to comment Share on other sites More sharing options...
JJ2198 Posted June 27, 2014 Share Posted June 27, 2014 (edited) Variables can be declared in the block and still work, try it for yourself. Edited June 27, 2014 by JJ2198 Link to comment Share on other sites More sharing options...
BitsOBacon Posted June 27, 2014 Share Posted June 27, 2014 Variables can be declared in the block and still work, try it for yourself.I'm not here to get in an argument; It causes an error. Even if it somehow still works, proper form is a good habit to have. Link to comment Share on other sites More sharing options...
JJ2198 Posted June 27, 2014 Share Posted June 27, 2014 Not trying to start an argument simply just stating that they can be used inside a block. Not sure why Cipscis syntax checker says there's an error, it works just fine, so why is it an error? Link to comment Share on other sites More sharing options...
jacksonl Posted July 3, 2014 Author Share Posted July 3, 2014 Once again! Thanks for the help. Finally had time to put the script in this week and works like a charm. Sets up some very interesting gun fights. Best regards, J L Link to comment Share on other sites More sharing options...
Recommended Posts