First, each entity in FPSC can have two sound files assigned to it. PlaySound0 plays first one, PlaySound1 second one.
Second, you need to understand how games generally work and how FPSC reloaded calls LUA code for entities. Generally, each game runs in a endless loop which runs until you pause game or exit game (or win/lose, whatever). This means that your game code will be called again and again, as fast as possible. Now, when you assign a script named "my_custom_behavior.lua" to an entity in FPSC, it will, in each game (endless) loop iteration, call function "my_custom_behavior_main(e)", with "e" being the entity on which the script is operating. So, your function name must match your file name, except you change ".lua" file extension with "_main(e)" in your function name.
Now, if you have infinite loop (and "while true" IS infinite loop, because true is always true) inside the entity function, it may crash whole game, because the engine will call your function, and instead of proceeding with calling other functions, it will wait for your (endless) loop to finish, which will never happen.
So, you need to change your way of thinking. You are always in the game loop, so no need to do something while something else is true. As your function is called numerous times per second, all you need to do is check if the player is near, and then play the sound. Logic tells me that you need to check if the sound is playing too (so it doesn't start it over and over in each function call), but since there is no way to check this in current version of FPSC, I guess FPSC takes care of that automatically.
And yes, I think you can't loop sound in this version of FPSC reloaded.