Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
|
10-30-2017
, 19:03
Re: [CSGO] How to attach/parent models correctly
|
#17
|
#EDIT
Sorry for double post...
i dont undertand...
In .qc file:
PHP Code:
$CBox 0 0 0 0 0 0
$BBox 0 0 0 0 0 0
$HBox 0 "spine_2" -10.28 -16.540001 -11.06 17.950001 0 9.7
$attachment "defusekit" "spine_2" -1.60 -5.50 0.00 rotate -0 90 90
$attachment "c4" "spine_2" 2.00 -6.00 2.70 rotate 4 4 85
PHP Code:
$ModelName "rodrigo286\jetpack\nuclear_jetpack.mdl" //name model
$CDMaterials "models\rodrigo286\nuclear_jetpack\" //textures
$BodyGroup "studio"
{
studio "nuclear_jetpack_reference.smd"
}
$SurfaceProp "metal"
$Contents "solid"
$MaxEyeDeflection 90
$CBox 0 0 0 0 0 0
$BBox 0 0 0 0 0 0
$HBox 0 "spine_2" -10.28 -16.540001 -11.06 17.950001 0 9.7
$attachment "defusekit" "spine_2" -1.60 -5.50 0.00 rotate -0 90 90
$attachment "c4" "spine_2" 2.00 -6.00 2.70 rotate 4 4 85
$Sequence "idle" {
"nuclear_jetpack_anims\idle.smd"
fadein 0.2
fadeout 0.2
fps 30
loop
}
$CollisionModel "nuclear_jetpack_physics.smd"
{
$mass 25
$inertia 1
$damping 0
$rotdamping 0
$concave
}
On Model Viewer:
In .sp:
PHP Code:
public Action parentAttach(Handle timer, DataPack pAttach)
{
int client;
ResetPack(pAttach, false);
client = ReadPackCell(pAttach);
if (IsValidAndAliveClient(client)){
// Set attachment
SetVariantString("c4");
AcceptEntityInput(entjetpack[client], "SetParentAttachment", entjetpack[client], entjetpack[client], 0);
// Timer to set attachment offset
DataPack pAttachOffset;
CreateDataTimer(0.1, parentAttachOffset, pAttachOffset);
pAttachOffset.WriteCell(client);
}
}
public Action parentAttachOffset(Handle timer, DataPack pAttachOffset)
{
int client;
ResetPack(pAttachOffset, false);
client = ReadPackCell(pAttachOffset);
if (IsValidAndAliveClient(client)){
// Set attachment offset for custom player models
SetVariantString("c4");
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset", entjetpack[client], entjetpack[client], 0);
AcceptEntityInput(entjetpack[client], "TurnOn");
}
}
PHP Code:
void EquipJetpackModel(int client)
{
if(!IsValidAndAliveClient(client))
return;
// Generate unique id for the client so we can set the parenting
// through parentname.
char StrName[64]; Format(StrName, sizeof(StrName), "Client%i", client);
DispatchKeyValue(client, "targetname", StrName);
// Create the hat entity
entjetpack[client] = CreateEntityByName("prop_dynamic");
// Generate unique id for the entity
char StrEntityName[64]; Format(StrEntityName, sizeof(StrEntityName), "prop_dynamic_%i", entjetpack[client]);
// Setup entity
DispatchKeyValue(entjetpack[client], "targetname", StrEntityName);
DispatchKeyValue(entjetpack[client], "parentname", StrName);
DispatchKeyValue(entjetpack[client], "model", MDL_JETPACK);
DispatchKeyValue(entjetpack[client], "solid", "0");
DispatchKeyValue(entjetpack[client], "spawnflags", "256");
DispatchKeyValue(entjetpack[client], "angles", "0 0 0");
SetEntPropEnt(entjetpack[client], Prop_Send, "m_hOwnerEntity", client);
SetEntityMoveType(entjetpack[client], MOVETYPE_NOCLIP);
// Create blank position vector and Determine position for the model
float pos[3]; GetClientAbsOrigin(client, pos);
pos[0] += 0.0;
pos[1] += 0.0;
pos[2] += 0.0;
TeleportEntity(entjetpack[client], pos, NULL_VECTOR, NULL_VECTOR);
// Set parent
SetVariantString(StrName);
AcceptEntityInput(entjetpack[client], "SetParent", entjetpack[client], entjetpack[client], 0);
// Timer to set attachment
DataPack Spawn;
CreateDataTimer(0.1, spawnEnt, Spawn);
Spawn.WriteCell(client);
}
public Action spawnEnt(Handle timer, DataPack Spawn)
{
int client;
ResetPack(Spawn, false);
client = ReadPackCell(Spawn);
if (IsValidAndAliveClient(client)){
// Spawn Jetpack Model Prop
DispatchSpawn(entjetpack[client]);
// Timer to set attachment
DataPack pAttach;
CreateDataTimer(0.1, parentAttach, pAttach);
pAttach.WriteCell(client);
}
}
public Action parentAttach(Handle timer, DataPack pAttach)
{
int client;
ResetPack(pAttach, false);
client = ReadPackCell(pAttach);
if (IsValidAndAliveClient(client)){
// Set attachment
SetVariantString("c4");
AcceptEntityInput(entjetpack[client], "SetParentAttachment", entjetpack[client], entjetpack[client], 0);
// Timer to set attachment offset
DataPack pAttachOffset;
CreateDataTimer(0.1, parentAttachOffset, pAttachOffset);
pAttachOffset.WriteCell(client);
}
}
public Action parentAttachOffset(Handle timer, DataPack pAttachOffset)
{
int client;
ResetPack(pAttachOffset, false);
client = ReadPackCell(pAttachOffset);
if (IsValidAndAliveClient(client)){
// Set attachment offset for custom player models
SetVariantString("c4");
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset", entjetpack[client], entjetpack[client], 0);
AcceptEntityInput(entjetpack[client], "TurnOn");
}
}
But fail on game...
What i do wrong?
Thanks for all help.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet
CZSBrasil TEAM
Last edited by rodrigo286; 10-30-2017 at 19:05.
|
|