PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "2.0"
new String:model[PLATFORM_MAX_PATH] = "models/props_mall/mall_shopliftscanner.mdl";
public Plugin:myinfo = {
name = "test",
author = "FluD",
description = "test device",
version = PLUGIN_VERSION,
url = "www.alliedmods.net"
}
public OnPluginStart(){
RegConsoleCmd("sm_test", cmd_test, "");
}
public Action:cmd_test(client,args){
new index = CreateEntityByName("prop_dynamic");
if (index != -1){
new Float:position[3];
GetCollisionPoint(client, position);
if (!IsModelPrecached(model))
{
PrecacheModel(model);
}
DispatchKeyValue(index, "model", model);
DispatchKeyValue(index, "classname", "prop_dynamic");
DispatchKeyValue(index, "disableselfshadowing", "1");
DispatchKeyValue(index, "disablevertexlighting", "1");
DispatchKeyValue(index, "fademindist", "-1");
DispatchKeyValue(index, "fadescale", "1");
DispatchKeyValue(index, "renderamt", "255");
DispatchKeyValue(index, "rendercolor", "255 0 0");
DispatchKeyValue(index, "skin", "0");
DispatchKeyValue(index, "solid", "0");
DispatchKeyValueVector(index, "Origin", position);
DispatchSpawn(index);
}
new trigger = CreateEntityByName("trigger_teleport");
if (trigger != -1){
new Float:position[3];
GetCollisionPoint(client, position);
DispatchKeyValueVector(trigger, "origin", position );
DispatchKeyValue(trigger, "classname", "trigger_teleport");
DispatchKeyValue(trigger, "spawnflags", "15");
DispatchKeyValue(trigger, "StartDisabled", "0");
DispatchKeyValue(trigger, "target", "t_out");
DispatchSpawn(trigger);
ActivateEntity(trigger);
SetEntityModel(trigger, model);
new Float:minbounds[3];
minbounds[0] = -100.0;
minbounds[1] = -100.0;
minbounds[2] = 0.0;
new Float:maxbounds[3];
minbounds[0] = 100.0;
minbounds[1] = 100.0;
minbounds[2] = 200.0;
SetEntPropVector(trigger, Prop_Send, "m_vecMins", minbounds);
SetEntPropVector(trigger, Prop_Send, "m_vecMaxs", maxbounds);
SetEntProp(trigger, Prop_Send, "m_nSolidType", 2);
new enteffects = GetEntProp(trigger, Prop_Send, "m_fEffects");
enteffects |= 32;
SetEntProp(trigger, Prop_Send, "m_fEffects", enteffects);
}
new destination = CreateEntityByName("info_teleport_destination");
if (destination != -1){
new Float:position[3];
GetCollisionPoint(client, position);
position[0] = (position[0] + 200);
DispatchKeyValueVector(destination, "origin", position);
DispatchKeyValue(destination, "angles", "0 0 0");
DispatchKeyValue(destination, "spawnflags", "15");
DispatchKeyValue(destination, "targetname", "t_out");
DispatchKeyValue(destination, "classname", "info_teleport_destination");
DispatchSpawn(destination);
}
return Plugin_Continue;
}
stock GetCollisionPoint(client, Float:pos[3]){
decl Float:vOrigin[3], Float:vAngles[3];
GetClientEyePosition(client, vOrigin);
GetClientEyeAngles(client, vAngles);
new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SOLID, RayType_Infinite, TraceEntityFilterPlayer);
if(TR_DidHit(trace))
{
TR_GetEndPosition(pos, trace);
CloseHandle(trace);
return;
}
CloseHandle(trace);
}
public bool:TraceEntityFilterPlayer(entity, contentsMask){
return entity > GetMaxClients() || !entity;
}