Raised This Month: $51 Target: $400
 12% 

Add walls to map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jockersoft
Member
Join Date: Aug 2008
Old 07-03-2009 , 17:25   Add walls to map
Reply With Quote #1

I'd like to prevent players to reach certain places of standard TF2 maps.
This could be done using BAILOPAN's Stripper but I cannot use it for performance reasons, so I'm looking for a way to create walls (visible or invisible) using a sourcemod plugin.

Is it possible? Which is the best way to do so?

I tried adding a model to the map (cp_badlands) using the following code in OnMapStart, but I must be doing something wrong since this has absolutely no effect.
Code:
decl Float:origin[3];
origin[0] = 2584.0;
origin[1] = 2780.0;
origin[2] = 140.0;
new Float:angles[3];
new ent1 = CreateEntityByName("prop_physics_override");
PrecacheModel("models/props_hydro/barricade.mdl", true);
SetEntityModel(ent1, "models/props_hydro/barricade.mdl");
SetEntityMoveType(ent1, MOVETYPE_NONE);
SetEntProp(ent1, Prop_Data, "m_CollisionGroup", 0);
SetEntProp(ent1, Prop_Data, "m_usSolidFlags", 28);
SetEntProp(ent1, Prop_Data, "m_nSolidType", 6);
DispatchSpawn(ent1);
AcceptEntityInput(ent1, "DisableShadow");
AcceptEntityInput(ent1, "DisableMotion");
TeleportEntity(ent1, origin, angles, NULL_VECTOR);
SetEntityRenderMode(ent1, RENDER_ENVIRONMENTAL);
I also wonder if there is an easier way, since an invisible rectangular wall will be perfect for my needs.

Last edited by jockersoft; 07-03-2009 at 17:27.
jockersoft is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 07-03-2009 , 18:40   Re: Add walls to map
Reply With Quote #2

It would be better if you created a dynamic instead of a physics, if you just want a static invisible wall to be collideable by the players.

PHP Code:
CreateInvisibleWall(Float:Position[3], Float:Angles[3])
{
    
// Create entity
    
new Entity CreateEntityByName("prop_dynamic_override");

    
// Configure and dispatch.
    
DispatchKeyValue(Entity"model",  "models/props_hydro/barricade.mdl");
    
DispatchKeyValue(Entity"solid",   "6");
    
SetEntityModel(Entity"models/props_hydro/barricade.mdl");
    
DispatchSpawn(Entity);

    
// Make it unable to cast shadows and set it to non-render mode.
    
AcceptEntityInput(Entity"DisableShadow");
    
SetEntityRenderMode(EntityRENDER_NONE);

    
// Teleport to given position and angles
    
TeleportEntity(EntityPositionAnglesNULL_VECTOR);

    
// Done
    
return Entity;

__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
Gachl
BANNED
Join Date: Feb 2009
Old 07-03-2009 , 18:50   Re: Add walls to map
Reply With Quote #3

is there a way to create a brush dynamically? So you can give it a texture, height, width, depth etc..?
Gachl is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-03-2009 , 19:01   Re: Add walls to map
Reply With Quote #4

No, it's not possible ATM.
bl4nk is offline
jockersoft
Member
Join Date: Aug 2008
Old 07-04-2009 , 05:52   Re: Add walls to map
Reply With Quote #5

Damizean, thanks for your response. I tried your code but i still can't get the wall spawning.

The following code should add a wall in front of the right door of the 1st blue spawn in cp_badlands, but does absolutely nothing apart from printing "wall added" in server console.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"

public Plugin:myinfo 
{
    
name "add wall test",
    
author "",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
}

public 
OnMapStart()
{
    
decl Float:Position[3];
    
decl Float:Angles[3];
    
Position[0] = -271.0;
    
Position[1] = -4197.0;
    
Position[2] = 290.0;
    
Angles[0] = 0.0;
    
Angles[1] = 0.0;
    
Angles[2] = 0.0;

    
PrecacheModel("models/props_hydro/barricade.mdl"true);
    new 
Wall CreateInvisibleWall(PositionAngles);
    
PrintToServer("wall added");
}

CreateInvisibleWall(Float:Position[3], Float:Angles[3])
{
    
// Create entity
    
new Entity CreateEntityByName("prop_dynamic_override");

    
// Configure and dispatch.
    
DispatchKeyValue(Entity"model",  "models/props_hydro/barricade.mdl");
    
DispatchKeyValue(Entity"solid",   "6");
    
SetEntityModel(Entity"models/props_hydro/barricade.mdl");
    
DispatchSpawn(Entity);

    
// Make it unable to cast shadows and set it to non-render mode.
    
AcceptEntityInput(Entity"DisableShadow");
    
SetEntityRenderMode(EntityRENDER_ENVIRONMENTAL); //TODO: set back to RENDER_NONE

    // Teleport to given position and angles
    
TeleportEntity(EntityPositionAnglesNULL_VECTOR);

    
// Done
    
return Entity;

Any idea? thanks
jockersoft is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 07-04-2009 , 09:35   Re: Add walls to map
Reply With Quote #6

My guess is the game destroys and recreates all entities during the round start events, so you should hook them to determine when to create the walls.

PHP Code:
// ------------------------------------------------------------------------
// OnPluginStart
// ------------------------------------------------------------------------
public OnPluginStart()
{
    
HookEvent("teamplay_round_start"Event_RoundStartEventHookMode_PostNoCopy);
    
RegConsoleCmd("MyPosition"Cmd_MyPos);
}

// ------------------------------------------------------------------------
// OnMapStart
// ------------------------------------------------------------------------
public OnMapStart()
{
    
PrecacheModel("models/props_hydro/barricade.mdl"true);
}

// ------------------------------------------------------------------------
// Event_RoundStart
// ------------------------------------------------------------------------
public Event_RoundStart(Handle:hEventString:StrName[], bool:bDontBroadcast)
{
    
// Create wall
    
CreateInvisibleWall(-1242.075317, -4212.376953192.0312500.00.00.0);
    
PrintToServer("wall added");
}

// ------------------------------------------------------------------------
// CreateInvisibleWall
// ------------------------------------------------------------------------
CreateInvisibleWall(Float:XFloat:YFloat:ZFloat:PitchFloat:YawFloat:Roll)
{
    
// Create entity
    
new Entity CreateEntityByName("prop_dynamic_override");

    
// Configure and dispatch.
    
DispatchKeyValue(Entity"model",  "models/props_hydro/barricade.mdl");
    
DispatchKeyValue(Entity"solid",   "6");
    
SetEntityModel(Entity"models/props_hydro/barricade.mdl");
    
DispatchSpawn(Entity);

    
// Make it unable to cast shadows and set it to non-render mode.
    
AcceptEntityInput(Entity"DisableShadow");
    
SetEntityRenderMode(EntityRENDER_NORMAL);

    
// Setup position and rotation vectors and teleport.
    
new Float:Position[3];
    
Position[0] = X;
    
Position[1] = Y;
    
Position[2] = Z;
    new 
Float:Angles[3];
    
Angles[0] = Pitch;
    
Angles[1] = Yaw;
    
Angles[2] = Roll;
    
TeleportEntity(EntityPositionAnglesNULL_VECTOR);

    
// Done
    
return Entity;
}  

// ------------------------------------------------------------------------
// Cmd_MyPos
// ------------------------------------------------------------------------
public Action:Cmd_MyPos(ClientArgs)
{
    
// Retrieve position from player
    
new Float:Position[3];
    
GetClientAbsOrigin(ClientPosition);
    
    
// Show on chat
    
PrintToChatAll("%f, %f, %f"Position[0], Position[1], Position[2]);
    
    
// Done
    
return Plugin_Handled;

This code works, I've tested it out and it creates the barricade on the left door (just in case the coordinates you used were incorrect). I've also included a command to determine the position, so you can just place them where you are at.
__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
jockersoft
Member
Join Date: Aug 2008
Old 07-04-2009 , 11:15   Re: Add walls to map
Reply With Quote #7

THANKS! that did the trick

if anyone is interested: models/props_hydro/metal_barrier03.mdl is a pretty good model for a big wall
jockersoft is offline
fragnichtnach
AlliedModders Donor
Join Date: Oct 2008
Old 03-08-2019 , 15:28   Re: Add walls to map
Reply With Quote #8

Quote:
Originally Posted by Gachl View Post
is there a way to create a brush dynamically? So you can give it a texture, height, width, depth etc..?
is there a way to do this in 2019?
fragnichtnach is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 03-09-2019 , 06:13   Re: Add walls to map
Reply With Quote #9

https://forums.alliedmods.net/showth...=129597&page=7
Width, high, depth but no texture, just invisible
Indarello is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:49.


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