Skip to content

Instantly share code, notes, and snippets.

@icequeenzz
Created August 29, 2010 21:55
Show Gist options
  • Save icequeenzz/556738 to your computer and use it in GitHub Desktop.
Save icequeenzz/556738 to your computer and use it in GitHub Desktop.
#include <sourcemod>
#include <sdktools>
#define VERSION "0.1"
new Float:g_pos[3];
public Plugin:myinfo =
{
name = "[TF2] test",
author = "Icequeenzz",
description = "Spawns test.",
version = VERSION,
url = "http://www.sourcemod.net"
}
public OnPluginStart()
{
CreateConVar("sm_test_version", VERSION, "test Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
RegAdminCmd("sm_test", Command_Test, ADMFLAG_SLAY);
}
public Action:Command_Test(client, args)
{
if(!SetTeleportEndPoint(client))
{
PrintToChat(client, "[SM] Could not find spawn point.");
return Plugin_Handled;
}
if(GetEntityCount() >= GetMaxEntities()-32)
{
PrintToChat(client, "[SM] Entity limit is reached.");
return Plugin_Handled;
}
PrecacheModel("models/props_farm/concrete_block001.mdl" ,true);
new Prop = CreateEntityByName("prop_physics_override");
DispatchKeyValue(Prop, "model", "models/props_farm/concrete_block001.mdl");
if(IsValidEntity(Prop))
{
DispatchSpawn(Prop);
g_pos[2] -= 10.0;
TeleportEntity(Prop, g_pos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(Prop, "DisableMotion");
AcceptEntityInput(Prop, "SetHealth 100");
}
TurnProp(client, Prop);
return Plugin_Handled;
}
SetTeleportEndPoint(client)
{
decl Float:vAngles[3];
decl Float:vOrigin[3];
decl Float:vBuffer[3];
decl Float:vStart[3];
decl Float:Distance;
GetClientEyePosition(client,vOrigin);
GetClientEyeAngles(client, vAngles);
//get endpoint for teleport
new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
if(TR_DidHit(trace))
{
TR_GetEndPosition(vStart, trace);
GetVectorDistance(vOrigin, vStart, false);
Distance = -35.0;
GetAngleVectors(vAngles, vBuffer, NULL_VECTOR, NULL_VECTOR);
g_pos[0] = vStart[0] + (vBuffer[0]*Distance);
g_pos[1] = vStart[1] + (vBuffer[1]*Distance);
g_pos[2] = vStart[2] + (vBuffer[2]*Distance);
}
else
{
CloseHandle(trace);
return false;
}
CloseHandle(trace);
return true;
}
TurnProp(client, prop)
{
decl Float:vAngles[3];
GetClientEyeAngles(client, vAngles);
vAngles[0] = 0.0;
vAngles[2] = 0.0;
TeleportEntity(prop, NULL_VECTOR, vAngles, NULL_VECTOR);
}
public bool:TraceEntityFilterPlayer(entity, contentsMask)
{
return entity > GetMaxClients() || !entity;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment