AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [OB-Not TF2] Hat Spawn Snippet (https://forums.alliedmods.net/showthread.php?t=158178)

Samantha 06-01-2011 00:31

[OB-Not TF2] Hat Spawn Snippet
 
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.

Zephyrus 06-01-2011 00:43

Re: [OB-Not TF2] Hat Spawn Snippet
 
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

KawMAN 06-05-2011 17:57

Re: [OB-Not TF2] Hat Spawn Snippet
 
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"
            
}
        }
    }



asherkin 06-06-2011 09:19

Re: [OB-Not TF2] Hat Spawn Snippet
 
Quote:

Originally Posted by KawMAN (Post 1482066)
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

klausenbusk 07-01-2011 10:35

Re: [OB-Not TF2] Hat Spawn Snippet
 
Somebody with some picture? :D

Groger 07-04-2011 15:00

Re: [OB-Not TF2] Hat Spawn Snippet
 
Custom made model made by a member of my community
+
Hat plugin provided by Zephyrus
=
http://cloud.steampowered.com/ugc/54...43A3536AE0FAF/

smithy 07-06-2011 05:19

Re: [OB-Not TF2] Hat Spawn Snippet
 
Quote:

Originally Posted by Samantha (Post 1479098)
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

:up::up:

Gippo 07-08-2011 17:22

Re: [OB-Not TF2] Hat Spawn Snippet
 
Quote:

Originally Posted by Groger (Post 1503676)
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? :P

Peace-Maker 07-08-2011 18:37

Re: [OB-Not TF2] Hat Spawn Snippet
 
Just join one of his servers and check your client's models/materials :P

Groger 07-09-2011 11:33

Re: [OB-Not TF2] Hat Spawn Snippet
 
www.onlyfriends.be/downloads/deadmau5.rar

paths:
materials/models/dannhat
models/drwaffles


All times are GMT -4. The time now is 21:52.

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