Raised This Month: $51 Target: $400
 12% 

[OB-Not TF2] Hat Spawn Snippet


Post New Thread Reply   
 
Thread Tools Display Modes
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
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 06-01-2011 , 00:43   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #2

in my hat script i search the mdl file in binary mode for the forward bone, this way i can easily detect whether the model supports hats or not
Zephyrus is offline
KawMAN
SourceMod Donor
Join Date: Sep 2007
Location: Cracov
Old 06-05-2011 , 17:57   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #3

I'm using this to do that
PHP Code:
new Handle:hLookupAttachment            INVALID_HANDLE;
public 
OnPluginStart()
{
    new 
Handle:hGameConf LoadGameConfigFile("cheatbuster.gamedata");
    
StartPrepSDKCall(SDKCall_Entity);
    
PrepSDKCall_SetFromConf(hGameConfSDKConf_Signature"LookupAttachment");
    
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
hLookupAttachment EndPrepSDKCall();
}
ClientLookupAttachment(clientString:point[])
{
    if(
hLookupAttachment==INVALID_HANDLE) return 0;
    if( 
client<=|| !IsClientInGame(client) ) return 0;
    return 
SDKCall(hLookupAttachmentclientpoint);

Linux Sig
PHP Code:
"Games"
{
    
"cstrike"
    
{
        
"Signatures"
        
{
            
"LookupAttachment"
            
{
                
"library"    "server"
                "linux"        "@_ZN14CBaseAnimating16LookupAttachmentEPKc"
            
}
        }
    }

__________________
KawMAN is offline
Send a message via ICQ to KawMAN Send a message via Skype™ to KawMAN
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-06-2011 , 09:19   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #4

Quote:
Originally Posted by KawMAN View Post
Linux Sig
PHP Code:
"Games"
{
    
"cstrike"
    
{
        
"Signatures"
        
{
            
"LookupAttachment"
            
{
                
"library"    "server"
                "linux"        "@_ZN14CBaseAnimating16LookupAttachmentEPKc"
            
}
        }
    }

Here's the Windows sig, it was a hard one to get:
Code:
\x56\x8B\xF1\x83\xBE\x2A\x2A\x2A\x2A\x00\x75\x2A\xE8\x2A\x2A\x2A\x2A\x85\xC0\x74\x2A\x8B\xCE\xE8\x2A\x2A\x2A\x2A\x8B\x86\x2A\x2A\x2A\x2A\x85\xC0\x5E\x74\x2A\x83\x38\x00\x75\x2A\x33\xC0\xC2\x04\x00\x8B\x4C\x24\x04\x51\x50
__________________
asherkin is offline
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Old 07-01-2011 , 10:35   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #5

Somebody with some picture?
klausenbusk is offline
Groger
Veteran Member
Join Date: Oct 2009
Location: Belgium
Old 07-04-2011 , 15:00   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #6

Custom made model made by a member of my community
+
Hat plugin provided by Zephyrus
=
http://cloud.steampowered.com/ugc/54...43A3536AE0FAF/
Groger is offline
smithy
SourceMod Donor
Join Date: Sep 2008
Location: United Kingdom
Old 07-06-2011 , 05:19   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #7

Quote:
Originally Posted by Samantha View Post
If you would like the entire script, I'll be glad to share. 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.
Yes please my community would love to be able to use hats in css

__________________

smithy is offline
Gippo
AlliedModders Donor
Join Date: Oct 2008
Old 07-08-2011 , 17:22   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #8

Quote:
Originally Posted by Groger View Post
Custom made model made by a member of my community
+
Hat plugin provided by Zephyrus
=
http://cloud.steampowered.com/ugc/54...43A3536AE0FAF/
I'm miring. Care to share some hat models with me?
Gippo is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-08-2011 , 18:37   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #9

Just join one of his servers and check your client's models/materials
__________________
Peace-Maker is offline
Groger
Veteran Member
Join Date: Oct 2009
Location: Belgium
Old 07-09-2011 , 11:33   Re: [OB-Not TF2] Hat Spawn Snippet
Reply With Quote #10

www.onlyfriends.be/downloads/deadmau5.rar

paths:
materials/models/dannhat
models/drwaffles
Groger 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 18:25.


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