i desgin to create a attachment and show whether the owner is on firstperson.
once the owner is limp, the position and angle will skewing when look at firstperson.
i need some help to make the attachment look the same whether the owner is limp ...
code is able to find at
https://forums.alliedmods.net/showthread.php?p=2755232
also upload and post the core.
Code:
void set_attach_model(int client, int entity)
{
if(Infor[client].Has_melee == true)
{
char model[PLATFORM_MAX_PATH];
int melee = create_weapon("weapon_melee", Infor[client].Melee_name);
if(get_useable_weapon_type(melee) == TYPE_MELEE)
{
GetEntPropString(melee, Prop_Data, "m_ModelName", model, PLATFORM_MAX_PATH);
SetEntityModel(entity, model);
}
if(melee > 0 && IsValidEntity(melee))
{
RemoveEdict(melee);
}
}
else if(Infor[client].Has_chainsaw == true)
{
SetEntityModel(entity, MODEL_W_CHAINSAW);
}
}
void teleport_attach(int entity)
{
char model[PLATFORM_MAX_PATH];
GetEntPropString(entity, Prop_Data, "m_ModelName", model, PLATFORM_MAX_PATH);
if(strcmp(model, MODEL_W_CHAINSAW) == 0)
{
TeleportEntity(entity, O_pos_chainsaw, O_ang_chainsaw, NULL_VECTOR);
}
else
{
TeleportEntity(entity, O_pos_melee, O_ang_melee, NULL_VECTOR);
}
}
void add_attach(int client)
{
if(Infor[client].Attach_ref == 0)
{
int entity = CreateEntityByName("prop_dynamic_override");
if(is_prop_dynamic(entity, true))
{
set_attach_model(client, entity);
DispatchSpawn(entity);
ActivateEntity(entity);
SetVariantString("!activator");
AcceptEntityInput(entity, "SetParent", client);
SetVariantString("medkit");
AcceptEntityInput(entity, "SetParentAttachment", entity);
AcceptEntityInput(entity, "TurnOn");
AcceptEntityInput(entity, "DisableShadow");
AcceptEntityInput(entity, "DisableCollision");
SetEntProp(entity, Prop_Send, "m_noGhostCollision", 1, 1);
SetEntProp(entity, Prop_Data, "m_CollisionGroup", 0x0004);
SetEntPropVector(entity, Prop_Send, "m_vecMins", view_as<float>({0.0, 0.0, 0.0}));
SetEntPropVector(entity, Prop_Send, "m_vecMaxs", view_as<float>({0.0, 0.0, 0.0}));
teleport_attach(entity);
SetEntProp(entity, Prop_Data, "m_iEFlags", 0);
SDKHook(entity, SDKHook_SetTransmit, set_transmit);
Infor[client].Attach_ref = EntIndexToEntRef(entity);
Attach_owner[entity] = client;
}
}
}
----------------------------------------------
the reason cause the skewing is, when survivor is limp, the model and animation will change.
haven't found a good way fix if still keep to design to show it on firstperson.