Raycasting to check if a player is visible or not

I have been looking at: https://runtime.fivem.net/doc/reference.html#_0x377906D8A31E5586
I am new to the whole FiveM modding and such, and Lua aswell.
But my plan is to somehow check if a player is visible or not, and return a boolean.
In that way I can show the player name above his head if he is visible and if not I hide his name.

I do not ask for copy-paste code, that is not what I want.
As for now I want someone to like give me ideas on how to progress.

I assume that I need to do something like:
startRays = StartShapeTestRay(x1, y1, z1, x2, y2, z2, -1, ID, int p8) now the p8 part I do not really understand.

If a parameter is named p1-p8 or whatever, that just means we don’t know what it does. I have used 0 there, and it works fine.

Just draw a ray from you to the other player. If it hits the player, then draw the name. If it doesn’t return the player, don’t do anything.

Perfect, thank you for the fast answer.

Do you mean visible in your current field of view or do you mean if he is literally invisible?