View Single Post
flud
Senior Member
Join Date: Jun 2009
Location: Latvija
Old 07-05-2010 , 06:31   Re: [Tutorial] Creating brush entities
Reply With Quote #17

anyone try trigger_teleport ?

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(clientposition);

        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(clientposition);

        
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(triggermodel);

        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(triggerProp_Send"m_vecMins"minbounds);
        
SetEntPropVector(triggerProp_Send"m_vecMaxs"maxbounds);
        
        
SetEntProp(triggerProp_Send"m_nSolidType"2);

        new 
enteffects GetEntProp(triggerProp_Send"m_fEffects");
        
enteffects |= 32;
        
SetEntProp(triggerProp_Send"m_fEffects"enteffects);
    }

    new 
destination CreateEntityByName("info_teleport_destination");
    if (
destination != -1){
        new 
Float:position[3];
        
GetCollisionPoint(clientposition);
        
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(clientFloat:pos[3]){

    
decl Float:vOrigin[3], Float:vAngles[3];

    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);

    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SOLIDRayType_InfiniteTraceEntityFilterPlayer);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        
CloseHandle(trace);

        return;
    }
    
CloseHandle(trace);
}

public 
bool:TraceEntityFilterPlayer(entitycontentsMask){
    return 
entity GetMaxClients() || !entity;

does not work I will be glad if someone can help
__________________
Beware of a terrible language
flud is offline
Send a message via Skype™ to flud