1. Hooking an entity twice with the same callback will make the callback fire twice
2. No, according to
https://sm.alliedmods.net/new-api/sdkhooks/SDKUnhook, there are no error conditions for SDKUnhook
3. Not built into SDKHooks, but it is possible. One way would be to keep a global count for each hook-callback and increment it every time a player is hooked, and then decrement the count when the player leaves (unhooked). Then you can check if count > 0 e.g.
PHP Code:
int g_iCount = 0;
public void OnClientPutInServer(int iClient) {
SDKHook(iClient, /* blah */);
g_iCount++;
}
public void OnClientDisconnect(iClient) {
g_iCount--;
}
4. Player is unhooked when they disconnect and when the plugin is unloaded
5. Depends on what you want to achieve. Most of the time, you can hook and forget. If you want a one time action, you can hook them, then SDKUnhook in the callback