First, you need to implement the following function passing 0 to viewstate when a player dies and 1 when they spawn:
PHP Code:
stock SwitchView(target, viewstate){
if (viewstate >= 1){
SetEntPropEnt(target, Prop_Send, "m_hObserverTarget", target);
SetEntProp(target, Prop_Send, "m_iObserverMode", 1);
SetEntProp(target, Prop_Send, "m_bDrawViewmodel", 0);
} else {
SetEntPropEnt(target, Prop_Send, "m_hObserverTarget", -1);
SetEntProp(target, Prop_Send, "m_iObserverMode", 0);
SetEntProp(target, Prop_Send, "m_bDrawViewmodel", 1);
}
}
Next, in the death event AFTER the call to SwitchView, add this:
PHP Code:
CreateTimer(0.1, Timer_Ragdoll, client);
And then add this timer to your code:
PHP Code:
public Action:Timer_Ragdoll(Handle:timer, any:client){
if(IsClientInGame(client)){
RemoveEdict(GetEntPropEnt(client, Prop_Send, "m_hRagdoll"));
}
}
It took me three days to find out how to avoid this annoying bug (when you die, the camera is permanently locked on to your dead body until you leave the server).
This (removing the ragdoll instantly) is one of two workarounds; the other screws up the camera and isn't worth having.
__________________