Raised This Month: $ Target: $400
 0% 

[OB-Not TF2] Hat Spawn Snippet


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Samantha
SourceMod Donor
Join Date: Feb 2010
Location: Madagascar
Old 06-01-2011 , 00:31   [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #1

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.
__________________
"I give sopport and knolage in making extractions"
"MASTER(D) - dun0: are you mocing me?" -Master the grate

Plugins
Godmode Until Attack | No Block Team Filter
Extensions
Rcon Hooks
Samantha is offline
 



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 21:52.


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