AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Create "Dueling Box" (https://forums.alliedmods.net/showthread.php?t=233247)

keyboard1333 01-11-2014 22:41

Create "Dueling Box"
 
A while ago I saw a plugin (on Pink Taco I believe) that created a box that would allow certain players in and repel the other players.

Is there any plugin (with public sourcecode) that does this? (I've looked :|)

If not, what would be the steps to create such a plugin? And also, would it be possible to prevent weapons discharge entering the box?

thetwistedpanda 01-11-2014 23:47

Re: Create "Dueling Box"
 
Hmm, you could probably piece it together with code from several plugins, but I'd do the following:

Create a Trigger Multiple entity, then hook it for OnTouch or OnStartTouch and use that method for ensuring only your two dueling players are allowed. Hook OnEndTouch to see if your duelers leave the box. Use Temp Ents (the beam, see Timer for some usable code) to create a visible box around the trigger entity. For the repelling, you could go for complicated and create a series of push entities around it, or go the math route and use TeleportEntity with vector funness. As for the weapon discharge, I'm going to assume you mean preventing players from outside the box from injuring the ones inside, in which case you can hook OnTakeDamage or TraceAttack and see if both players are within the box, and if not, nullify the damage.

keyboard1333 01-12-2014 00:03

Re: Create "Dueling Box"
 
I think I understood most of what you said (and I know from experience how to do a few of those), but the one that goes straight past me is
Quote:

Create a Trigger Multiple entity
.
Would a quick explanation or a link to something explaining what that is be possible? :)

Also, I meant stopping the weapon projectiles from entering the box (hooking the collision then destroying them?)

ddhoward 01-12-2014 00:45

Re: Create "Dueling Box"
 
I did something like this recently. Not sure what of it you'd be able to utilize. Also here's hoping you have at least basic sourcepawn knowledge.

also i've REALLY cleaned up my stock brush-creating code since I released that plugin

ddhoward 01-12-2014 00:53

Re: Create "Dueling Box"
 
whoops, forgot the link

https://forums.alliedmods.net/showthread.php?t=228521

friagram 01-12-2014 01:05

Re: Create "Dueling Box"
 
Quote:

Originally Posted by thetwistedpanda (Post 2084729)
Hmm, you could probably piece it together with code from several plugins, but I'd do the following:

Create a Trigger Multiple entity, then hook it for OnTouch or OnStartTouch and use that method for ensuring only your two dueling players are allowed. Hook OnEndTouch to see if your duelers leave the box. Use Temp Ents (the beam, see Timer for some usable code) to create a visible box around the trigger entity. For the repelling, you could go for complicated and create a series of push entities around it, or go the math route and use TeleportEntity with vector funness. As for the weapon discharge, I'm going to assume you mean preventing players from outside the box from injuring the ones inside, in which case you can hook OnTakeDamage or TraceAttack and see if both players are within the box, and if not, nullify the damage.

Maths are the obvious best choice here.

keyboard1333 01-12-2014 20:03

Re: Create "Dueling Box"
 
Thanks for the replies guys!

I tried putting something together using your code (really dodgy) and it just crashes the server.

Code:

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <sdkhooks>


#define BRUSH_CLASSNAME "func_nav_avoid"
#define M_COLLISION_GROUP 11
#define SOLID_FLAGS 668
new BoxingBrush;

stock bool:IsValidClient(client, bool:replaycheck = true) {
    if (client < 1 || client > MaxClients ) return false;
    if (!IsClientInGame(client)) return false;
    if (GetEntProp(client, Prop_Send, "m_bIsCoaching")) return false;
    if (replaycheck)
    {
        if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
    }
    return true;


public OnPluginStart() {
    RegAdminCmd("sm_createDuel", Command_CreateDuel, ADMFLAG_SLAY, "Create the dueling box");
}
public Action:Command_CreateDuel(client,args)
{
    if(!IsValidClient(client))
    {
        return Plugin_Continue;
    }
    new Float:minbounds[3] = {0.0, 0.0, 0.0};
    new Float:maxbounds[3] = {360.0, 360.0, 430.0};
    new Float:PlayerLocation[3];
    GetClientAbsOrigin(client, PlayerLocation);
    BoxingBrush = CreateEntityByName(BRUSH_CLASSNAME);

    DispatchSpawn(BoxingBrush);
    ActivateEntity(BoxingBrush);

    TeleportEntity(BoxingBrush, PlayerLocation, NULL_VECTOR, NULL_VECTOR);

    SetEntityModel(BoxingBrush, "models/props_gameplay/resupply_locker.mdl");

    SetEntPropVector(BoxingBrush, Prop_Send, "m_vecMins", minbounds);
    SetEntPropVector(BoxingBrush, Prop_Send, "m_vecMaxs", maxbounds);
    SetEntProp(BoxingBrush, Prop_Send, "m_CollisionGroup", M_COLLISION_GROUP);
    SetEntProp(BoxingBrush, Prop_Send, "m_usSolidFlags", SOLID_FLAGS);

    new enteffects = GetEntProp(BoxingBrush, Prop_Send, "m_fEffects");
    enteffects |= 32;
    SetEntProp(BoxingBrush, Prop_Send, "m_fEffects", enteffects);

    SDKHook(BoxingBrush, SDKHook_StartTouch, OnStartTouchBoxing);
    SDKHook(BoxingBrush, SDKHook_Touch, OnTouchBoxing);
    SDKHook(BoxingBrush, SDKHook_EndTouch, OnStopTouchBoxing);
    return Plugin_Changed;
}

public Action:OnStartTouchBoxing(point, client) {
    PrintToChatAll("Test");
}

public Action:OnTouchBoxing(point, client) {
   
}


public Action:OnStopTouchBoxing(point, client) {
   
}

Any tips?

zipcore 01-13-2014 04:58

Re: Create "Dueling Box"
 
Look into timer-mapzones.sp: https://forums.alliedmods.net/showth...99#post2074699

There is a zonetype called ZtArena you could use this source to create your plugin.

Root_ 01-13-2014 06:20

Re: Create "Dueling Box"
 
Or this :P
Set 'no shoot' punishment and edit it within OnTouch callback, set booleans for both players that 'InZone[activator] = true' and set InZone[activator] = false appropriately when players enters/leaves zone and check those booleans in TraceAttack/OnTakeDamage like this
Code:
public OnClientPutInServer(client) {     SDKHook(client, SDKHook_TraceAttack, TraceAttack);     SDKHook(client, SDKHook_OnTakeDamage, TakeDamage); } public Action:TraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup) {     return (InZone[attacker] && InZone[victim]) ? Plugin_Continue : Plugin_Handled; } public Action:TakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {     return (InZone[attacker] && InZone[victim]) ? Plugin_Continue : Plugin_Handled; }

keyboard1333 01-14-2014 01:23

Re: Create "Dueling Box"
 
Thanks for all the responses!
In the end I went with root's plugin.

However I had a small problem :(
I tried to compile it (to see if I could add some changes) and I got a tonne of errors:

Mostly:sm_zones.sp(184) error 017: undefined symbol "Engine_CSS"

And so on.
All the undefined symbols :|


All times are GMT -4. The time now is 09:48.

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