The version I had was for war3 so it was slightly different, but something like this should work:
Code:
new bool:noclip[MaxClients];
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, SDK_Forwarded_OnTakeDamage);
SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePostHook);
noclip[client] = false;
}
public OnClientDisconnect(client)
{
SDKUnhook(client, SDKHook_OnTakeDamage, SDK_Forwarded_OnTakeDamage);
SDKUnhook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePostHook);
}
public Action:SDK_Forwarded_OnTakeDamage(victim,&attacker,&inflictor,&Float:damage,&damagetype)
{
if (ValidPlayer(victim) && GetEntityMoveType(victim) == MOVETYPE_NOCLIP)
{
SetEntityMoveType(victim, MOVETYPE_WALK);
}
}
public OnTakeDamagePostHook(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3])
{
if (ValidPlayer(victim, true) && noclip[client] && GetEntityMoveType(victim) != MOVETYPE_NOCLIP)
{
SetEntityMoveType(victim, MOVETYPE_NOCLIP);
SetEntProp(victim, Prop_Data, "m_takedamage", 2, 1); //Not sure if necessary
}
}
stock bool:ValidPlayer(client,bool:check_alive=false,bool:alivecheckbyhealth=false) {
if(client>0 && client<=MaxClients && IsClientConnected(client) && IsClientInGame(client))
{
if(check_alive && !IsPlayerAlive(client))
{
return false;
}
if(alivecheckbyhealth&&GetClientHealth(client)<1) {
return false;
}
return true;
}
return false;
}
//Your code somewhere
SetEntityMoveType(client, MOVETYPE_NOCLIP);
noclip[client] = true;
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); //Not sure if necessary