The code that has been posted could never have been working.
- There are several brackets missing, that alone should stop this script from getting compiled.
- The switch has a break before any statement, if that even compiles it will do nothing.
- local.player = $player[local.i]; does not need the semicolon
- local.player = $player[local.i] does not work, because in that code local.i is NIL
- local.player = $player[NIL] does not work, because in is a invalid index of the $player entity array
- local.player is NIL
- local.player playsound racmsg11 will not work because NIL can't use playsound, only entities can
- for testing I recommend you use $player instead (works as long as there is only 1 player on the server),
until you figured everything else out
- I am not quite sure, but I think switch has no advantage to if, when there is but a single statement to check
- I have never seen this before, but maybe it is correct, I can't tell: local.master = spawn ScriptMaster
Well, that are the things that I noticed so far without knowing how the rest of your script looks like.
BTW, what kind of crash does the server have ?
What happens to the server after the crash ?
Last edited by chrissstrahl; January 12th, 2020 at 06:56 AM.
I assume the brackets and rest of the code is further down. It was just a section of it from what he's saying.
There will be script errors, but it will compile and run. $player[local.i] will throw an error ('cannot cast NIL to int') but local.player will resolve to $player. As such the playsound will work if there is a player . And it may work with multiple players e.g. you can use stufftext against the player array ($player) and it will perform it for each for you (no loop needed). I'm pretty sure playsound works against targetname arrays.
RE switch, I assume there are more statements further down. The first break is superfluous but it will read the cases fine.
RE ScriptMaster, that is a valid entity. It's for caching resources and defining aliases. It's used if you don't want to mess with ubersound.