this is how i do it: (only a snippet, missing some functions)
PHP Code:
public SpawnABall(iCreator) {
SetTeleportEndPoint(iCreator);
g_iBall = CreateEntityByName("prop_physics_multiplayer");
if(IsValidEntity(g_iBall))
{
SetEntityModel(g_iBall, MDL_BALL);
SetEntProp(g_iBall, Prop_Data, "m_takedamage", 2);
DispatchSpawn(g_iBall);
//DispatchKeyValue(g_iBall, "skin", bool:GetRandomInt(0,1) ? "1" : "0");
//DispatchKeyValue(g_iBall, "targetname", "bomb");
//SetEntPropEnt(g_iBall, Prop_Send, "m_hOwnerEntity", iCreator);
SetEntProp(g_iBall, Prop_Data, "m_takedamage", 2);
//SetEntPropEnt(g_iBall, Prop_Data, "m_hLastAttacker", iCreator);
//Use the balls VPhysics for collisions
SetEntProp( g_iBall, Prop_Data, "m_nSolidType", 6 );
SetEntProp( g_iBall, Prop_Send, "m_nSolidType", 6 );
//Only detect bullet/damage collisions
SetEntProp(g_iBall, Prop_Data, "m_CollisionGroup", 2);
SetEntProp(g_iBall, Prop_Send, "m_CollisionGroup", 2);
//Set the shield's health
SetEntProp(g_iBall, Prop_Data, "m_iMaxHealth", 150);
SetEntProp(g_iBall, Prop_Data, "m_iHealth", 150);
AcceptEntityInput( g_iBall, "DisableCollision" );
AcceptEntityInput( g_iBall, "EnableCollision" );
DispatchKeyValue(g_iBall, "disableshadows", "1");
DispatchKeyValue(g_iBall, "physicsmode", "1");
DispatchKeyValue(g_iBall, "spawnflags", "256");
g_pos[2] += 50.0;
TeleportEntity(g_iBall, g_pos, NULL_VECTOR, NULL_VECTOR);
SDKHook(g_iBall, SDKHook_OnTakeDamage, OnTakeDamage);
}
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {
if(attacker > 0 && attacker <= MaxClients && IsClientInGame(attacker) && TMG_IsPlaying(attacker)) {
new iHealth = GetEntProp(g_iBall, Prop_Data, "m_iHealth");
if(iHealth - damage <= 0.0) {
BallExplode();
}
g_bSuccess[attacker] = g_bSimon;
} else {
damage = 0.0;
}
return Plugin_Continue;
}