View Single Post
chundo
Senior Member
Join Date: May 2008
Old 09-21-2008 , 20:17   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #11

Here's what I used to attach the party hat model to a player. "model" is the model path (I was using "models/effects/bday_hat.mdl"), and "target" is the player index to put it on:

Code:
    if (!IsModelPrecached(model))
        PrecacheModel(model);

    g_prop = CreateEntityByName("prop_dynamic_override");
    if (IsValidEntity(g_prop)) {
        SetVariantString("!activator");
        AcceptEntityInput(g_prop, "SetParent", target, g_prop, 0);
        SetVariantString("head");
        AcceptEntityInput(g_prop, "SetParentAttachment", g_prop, g_prop, 0);
        DispatchKeyValue(g_prop, "model", model);
        if (GetClientTeam(target) == 3)
            DispatchKeyValue(g_prop, "skin", "1");
        DispatchKeyValue(g_prop, "solid", "0");
        DispatchKeyValue(g_prop, "targetname", "potw_hat1");
        DispatchSpawn(g_prop);
        AcceptEntityInput(g_prop, "TurnOn", g_prop, g_prop, 0);
    }
The purpose was to force the player of the week to wear a party hat, but like I said, I couldn't work around the fact that the hat obstructed the player's view no matter what I did (try it and you'll see). If someone knows how to make it invisible to the player, please let me know.
__________________
chundo is offline