Raised This Month: $ Target: $400
 0% 

[OB-Not TF2] Hat Spawn Snippet


Post New Thread Reply   
 
Thread Tools Display Modes
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 08-23-2011 , 17:31   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #21

changing the movetype of the shield after parenting should allow it become solid and block attacks.
blodia is offline
w4rkr4f7
Member
Join Date: Dec 2008
Old 12-10-2011 , 08:36   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #22

Quote:
Originally Posted by Samantha View Post
Not sure if this is useful to anyone, but why not! This is a snippet that was used to give people hats. I remember people asking about hats in the request section a while back so here we go. If you would like the entire script, I'll be glad to share, its kinda messy so i didn't wanna submit it as a new plugin. The script also has a php back end so its pretty complicated. If people want this in a plugin I'll be glad to make it one.

I've used this in CSS and Hl2dm, NOT TF2 ;)

~If I recall correctly, part of this was given by psychonic.

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

static const String:g_WorkingModels_CT[2][] = { "models/player/ct_gign.mdl""models/player/ct_urban.mdl" };
static const 
String:g_WorkingModels_T[3][] = { "models/player/t_arctic.mdl""models/player/t_guerilla.mdl""models/player/t_guerilla.mdl" };
//The other models dont have the "forward" attachment afaik

static g_offOwnerEnt;

public 
OnPluginStart()
{
    
g_offOwnerEnt FindSendPropInfo("CDynamicProp""m_hOwnerEntity");
}

CreateHatTarget , const String:Model[128], const Float:Offset[3] )
{

    if (!
IsClientInGameTarget) || !IsPlayerAlive(Target))
        return -
1;
        
    
decl String:PlayerModel[128];
    
GetClientModelTargetPlayerModelsizeof(PlayerModel) );
    
    new 
Team GetClientTeamTarget );
    
    if(  
Team == CS_TEAM_CT )
    {
        for( new 
0<= 1X++ )
        {
            if( !
StrEqualPlayerModelg_WorkingModels_CT[X], false ) )
            {
                
SetEntityModelTargetg_WorkingModels_CT[GetRandomInt(0,1)] );
                break;
            }
        }
    }
    else if(  
Team == CS_TEAM_T )
    {
        for( new 
0<= 2X++ )
        {
            if( !
StrEqualPlayerModelg_WorkingModels_CT[X], false ) )
            {
                
SetEntityModel(  Targetg_WorkingModels_T[GetRandomInt(0,1)] );
                break;
            }
        }
    }
    else return -
1;
        
    new 
iModel CreateEntityByName("prop_dynamic_override");

    if (
IsValidEntity(iModel))
    {
        
SDKHookiModelSDKHook_SetTransmitOnShouldDisplayHats);
        
SetVariantString("!activator");
        
AcceptEntityInput(iModel"SetParent"TargetiModel0);

        
SetVariantString("forward"); //anim_attachment_head

        
AcceptEntityInput(iModel"SetParentAttachment"iModel iModel0);
        
DispatchKeyValue(iModel"model"Model );
        
DispatchKeyValue(iModel"solid""0");
        
DispatchSpawn(iModel);
        
DispatchKeyValue(iModel"targetname""playerhat");
        
SetEntDataEnt2(iModelg_offOwnerEntTargettrue);

        
AcceptEntityInput(iModel"TurnOn"TargetTarget0);
        
        
decl Float:Pos[3];
        
GetEntPropVector(iModelProp_Send"m_vecOrigin"Pos);
        
        
Pos[0]     += Offset[0];
        
Pos[1]    += Offset[1];
        
Pos[2]     += Offset[2];

        
        
TeleportEntityiModelPosNULL_VECTORNULL_VECTOR );
        
        return 
iModel;
    }
    return -
1;
}

public 
Action:OnShouldDisplayHatsEntClient)
{
    
//You wanna save the hatent in an array such as PlayerHat[MAXPLAYERS+1], and if the ent = the one the client is wearing it shoulnd't get transmitted.

Haven't scripted in a while, so if you find any issues, ill be glad to fix.
You can make a plugin to use in CSS ?? I like to have all players Santa Hat on holidays .

My request is here http://forums.alliedmods.net/showthr...58#post1605858

Thanks in advance
w4rkr4f7 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode