Member
|
12-10-2011
, 08:36
Re: [OB-Not TF2] Hat Spawn Snippet
|
#22
|
Quote:
Originally Posted by Samantha
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"); }
CreateHat( Target , const String:Model[128], const Float:Offset[3] ) {
if (!IsClientInGame( Target) || !IsPlayerAlive(Target)) return -1; decl String:PlayerModel[128]; GetClientModel( Target, PlayerModel, sizeof(PlayerModel) ); new Team = GetClientTeam( Target ); if( Team == CS_TEAM_CT ) { for( new X = 0; X <= 1; X++ ) { if( !StrEqual( PlayerModel, g_WorkingModels_CT[X], false ) ) { SetEntityModel( Target, g_WorkingModels_CT[GetRandomInt(0,1)] ); break; } } } else if( Team == CS_TEAM_T ) { for( new X = 0; X <= 2; X++ ) { if( !StrEqual( PlayerModel, g_WorkingModels_CT[X], false ) ) { SetEntityModel( Target, g_WorkingModels_T[GetRandomInt(0,1)] ); break; } } } else return -1; new iModel = CreateEntityByName("prop_dynamic_override");
if (IsValidEntity(iModel)) { SDKHook( iModel, SDKHook_SetTransmit, OnShouldDisplayHats); SetVariantString("!activator"); AcceptEntityInput(iModel, "SetParent", Target, iModel, 0);
SetVariantString("forward"); //anim_attachment_head
AcceptEntityInput(iModel, "SetParentAttachment", iModel , iModel, 0); DispatchKeyValue(iModel, "model", Model ); DispatchKeyValue(iModel, "solid", "0"); DispatchSpawn(iModel); DispatchKeyValue(iModel, "targetname", "playerhat"); SetEntDataEnt2(iModel, g_offOwnerEnt, Target, true);
AcceptEntityInput(iModel, "TurnOn", Target, Target, 0); decl Float:Pos[3]; GetEntPropVector(iModel, Prop_Send, "m_vecOrigin", Pos); Pos[0] += Offset[0]; Pos[1] += Offset[1]; Pos[2] += Offset[2];
TeleportEntity( iModel, Pos, NULL_VECTOR, NULL_VECTOR ); return iModel; } return -1; }
public Action:OnShouldDisplayHats( Ent, Client) { //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
|
|