Raised This Month: $ Target: $400
 0% 

players can destroy tripmine, any help ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
martoxs
Junior Member
Join Date: Dec 2012
Old 01-11-2013 , 02:39   players can destroy tripmine, any help ?
Reply With Quote #1

When i put !tripmine player, when he walks throw mine can destroy it, i want to just zombies can destroy the mine, how to make that ?
martoxs is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 01-11-2013 , 05:34   Re: players can destroy tripmine, any help ?
Reply With Quote #2

If you're a programmer you could modify the tripmines plugin to check if a player is a zombie (using ZR's API). I can't think of a way doing it without modifying it.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-12-2013 , 22:08   Re: players can destroy tripmine, any help ?
Reply With Quote #3

if you are talking about this plugin: http://forums.alliedmods.net/showthread.php?t=70782, i don't think you can check which player damaged it to turn it unbreakable when humans hit it. but you could let it unbreakable and just trigger its explosion when a player[zombie] pass in front of the laser.

Last edited by Bimbo1; 01-13-2013 at 16:11.
Bimbo1 is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 01-14-2013 , 15:03   Re: players can destroy tripmine, any help ?
Reply With Quote #4

Quote:
Originally Posted by Bimbo1 View Post
if you are talking about this plugin: http://forums.alliedmods.net/showthread.php?t=70782, i don't think you can check which player damaged it to turn it unbreakable when humans hit it. but you could let it unbreakable and just trigger its explosion when a player[zombie] pass in front of the laser.
using SDKHooks on the entity would do the trick like mine lasermines
Despirator is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-14-2013 , 15:32   Re: players can destroy tripmine, any help ?
Reply With Quote #5

Quote:
Originally Posted by Despirator View Post
using SDKHooks on the entity would do the trick like mine lasermines
oh, cool. i tested sdkhooks before posting, but i tried SDKHooks_TraceAttack and it didn't work for entities who weren't clients. i assumed, then, it wasn't work for any hook. i should have tested the other hooks too.
anyway, as it works, i might do it later.
just to be sure about it: the thread is about this plugin http://forums.alliedmods.net/showthread.php?t=70782, isn't it?
Bimbo1 is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 01-15-2013 , 00:53   Re: players can destroy tripmine, any help ?
Reply With Quote #6

about this one - http://forums.alliedmods.net/showthread.php?t=173632

Type of hook is SDKHook_OnTakeDamage
Despirator is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-15-2013 , 15:14   Re: players can destroy tripmine, any help ?
Reply With Quote #7

oh yes, i know it. i've already seen your code of the lasermines. thank you, either way.
what i wanted to know is if this thread is talking about the plugin at this link http://forums.alliedmods.net/showthread.php?t=70782, as it says tripmines and not lasermines.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 01-16-2013 , 02:26   Re: players can destroy tripmine, any help ?
Reply With Quote #8

ah, yes. exactly about that thread, sorry
Despirator is offline
eziukasish
BANNED
Join Date: Jan 2013
Old 01-16-2013 , 10:22   Re: players can destroy tripmine, any help ?
Reply With Quote #9

Yes, I need tripmines to be modded that only zombies could destroy them. For example if human walks on it or shoot it - It won't explode, only when zombie will get on that it must explode.
eziukasish is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-16-2013 , 13:38   Re: players can destroy tripmine, any help ?
Reply With Quote #10

Quote:
Originally Posted by Despirator View Post
ah, yes. exactly about that thread, sorry
don't need to feel sorry. you helped me.
Quote:
Originally Posted by eziukasish View Post
Yes, I need tripmines to be modded that only zombies could destroy them. For example if human walks on it or shoot it - It won't explode, only when zombie will get on that it must explode.
i've done that, but the code is as ugly as hell! i don't know why, but HookSingleEntityOutput("OnTouchedByEntity") for the beam was only getting fired once. so, i created another beam after every single touch. when i tested it, it would lag if there was a lot of tripmines, so i used a timer to create the beams.
Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <zombiereloaded>

#define PLUGIN_VERSION "1.0.0.4"

#define TRACE_START 24.0
#define TRACE_END 64.0

#define MDL_LASER "sprites/laser.vmt"

#define SND_MINEPUT "npc/roller/blade_cut.wav"
#define SND_MINEACT "npc/roller/mine/rmine_blades_in2.wav"

#define TEAM_T 2
#define TEAM_CT 3

#define COLOR_T "255 0 0"
#define COLOR_CT "0 0 255"
#define COLOR_DEF "0 255 255"

#define MAX_LINE_LEN 256

// globals
new gRemaining[MAXPLAYERS+1];        // how many tripmines player has this spawn
new gCount = 1;
new String:mdlMine[256];
new String:Beam[2048][64];
new Float:beamPos[2048][3];
new Float:endPos[2048][3];
new targetMine[2048];
new targetBeam[2048];
new Handle:beamTimer[2048] = {INVALID_HANDLE, INVALID_HANDLE, ...};

// convars
new Handle:cvNumMines = INVALID_HANDLE;
new Handle:cvActTime = INVALID_HANDLE;
new Handle:cvModel = INVALID_HANDLE;
new Handle:cvTeamRestricted = INVALID_HANDLE;

public Plugin:myinfo = {
    name = "Tripmines",
    author = "L. Duke (mod by user)",
    description = "Plant a trip mine",
    version = PLUGIN_VERSION,
    url = "http://www.lduke.com/"
};


public OnPluginStart() 
{
    // events
    HookEvent("player_death", PlayerDeath);
    HookEvent("player_spawn",PlayerSpawn);
    
    // convars
    CreateConVar("sm_tripmines_version", PLUGIN_VERSION, "Tripmines", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    cvNumMines = CreateConVar("sm_tripmines_allowed", "3");
    cvActTime = CreateConVar("sm_tripmines_activate_time", "2.0");
    cvModel = CreateConVar("sm_tripmines_model", "models/props_lab/tpplug.mdl");
    cvTeamRestricted = CreateConVar("sm_tripmines_restrictedteam", "0");

    // commands
    RegConsoleCmd("sm_tripmine", Command_TripMine);
}

public OnEventShutdown(){
    UnhookEvent("player_death", PlayerDeath);
    UnhookEvent("player_spawn",PlayerSpawn);
}

public OnMapStart()
{
    // set model based on cvar
    GetConVarString(cvModel, mdlMine, sizeof(mdlMine));
    
    // precache models
    PrecacheModel(mdlMine, true);
    PrecacheModel(MDL_LASER, true);
    
    // precache sounds
    PrecacheSound(SND_MINEPUT, true);
    PrecacheSound(SND_MINEACT, true);
}

// When a new client is put in the server we reset their mines count
public OnClientPutInServer(client){
    if(client && !IsFakeClient(client)) gRemaining[client] = 0;
}

public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client;
    client = GetClientOfUserId(GetEventInt(event, "userid"));
    gRemaining[client] = GetConVarInt(cvNumMines);
    return Plugin_Continue;
}

public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast){
    new client;
    client = GetClientOfUserId(GetEventInt(event, "userid"));
    gRemaining[client] = 0;
    return Plugin_Continue;
}

public Action:Command_TripMine(client, args)
{    
    // make sure client is not spectating
    if (!IsPlayerAlive(client))
        return Plugin_Handled;
        
    // check restricted team 
    new team = GetClientTeam(client);
    if(team == GetConVarInt(cvTeamRestricted))
    { 
        PrintHintText(client, "Your team does not have access to this equipment.");
        return Plugin_Handled;
    }
    
    // call SetMine if any remain in client's inventory
    if (gRemaining[client]>0) {
        SetMine(client);
    }
    else {
        PrintHintText(client, "You do not have any tripmines.");
    }
    return Plugin_Handled;
}

SetMine(client)
{
    
    // setup unique target names for entities to be created with
    new String:beam[64];
    Format(beam, sizeof(beam), "tmbeam%d", gCount);
    gCount++;
    if (gCount>10000)
    {
        gCount = 1;
    }
    
    // trace client view to get position and angles for tripmine
    
    decl Float:start[3], Float:angle[3], Float:end[3], Float:normal[3], Float:beamend[3];
    GetClientEyePosition( client, start );
    GetClientEyeAngles( client, angle );
    GetAngleVectors(angle, end, NULL_VECTOR, NULL_VECTOR);
    NormalizeVector(end, end);

    start[0]=start[0]+end[0]*TRACE_START;
    start[1]=start[1]+end[1]*TRACE_START;
    start[2]=start[2]+end[2]*TRACE_START;
    
    end[0]=start[0]+end[0]*TRACE_END;
    end[1]=start[1]+end[1]*TRACE_END;
    end[2]=start[2]+end[2]*TRACE_END;
    
    TR_TraceRayFilter(start, end, CONTENTS_SOLID, RayType_EndPoint, FilterAll, 0);
    
    if (TR_DidHit(INVALID_HANDLE))
    {
        // update client's inventory
        gRemaining[client]-=1;
        
        // find angles for tripmine
        TR_GetEndPosition(end, INVALID_HANDLE);
        TR_GetPlaneNormal(INVALID_HANDLE, normal);
        GetVectorAngles(normal, normal);
        
        // trace laser beam
        TR_TraceRayFilter(end, normal, CONTENTS_SOLID, RayType_Infinite, FilterAll, 0);
        TR_GetEndPosition(beamend, INVALID_HANDLE);
        
        // create tripmine model
        new ent = CreateEntityByName("prop_physics_override");
        SetEntityModel(ent,mdlMine);

        DispatchKeyValue(ent, "spawnflags", "3");
        DispatchSpawn(ent);
        
        SetEntityMoveType(ent, MOVETYPE_NONE);
        TeleportEntity(ent, end, normal, NULL_VECTOR);
        DispatchKeyValue(ent, "ExplodeRadius", "256");
        DispatchKeyValue(ent, "ExplodeDamage", "400");
        SetEntProp(ent, Prop_Data, "m_CollisionGroup", 11);
        AcceptEntityInput(ent, "DisableMotion");
        SetEntProp(ent, Prop_Data, "m_takedamage", 2);
        AcceptEntityInput(ent, "Enable");
        
        
        SDKHook(ent, SDKHook_OnTakeDamage, OnTakeDamage);
        

        
        // create laser beam
        new beament = CreateEntityByName("env_beam");
        TeleportEntity(beament, beamend, NULL_VECTOR, NULL_VECTOR);
        SetEntityModel(beament, MDL_LASER);
        DispatchKeyValue(beament, "texture", MDL_LASER);
        DispatchKeyValue(beament, "targetname", beam);
        DispatchKeyValue(beament, "TouchType", "4");
        DispatchKeyValue(beament, "LightningStart", beam);
        DispatchKeyValue(beament, "BoltWidth", "4.0");
        DispatchKeyValue(beament, "life", "0");
        DispatchKeyValue(beament, "rendercolor", "0 0 0");
        DispatchKeyValue(beament, "renderamt", "0");
        DispatchKeyValue(beament, "HDRColorScale", "1.0");
        DispatchKeyValue(beament, "decalname", "Bigshot");
        DispatchKeyValue(beament, "StrikeTime", "0");
        DispatchKeyValue(beament, "TextureScroll", "35");
        HookSingleEntityOutput(beament, "OnTouchedByEntity", onTouchTripmine, false);
        SetEntPropVector(beament, Prop_Data, "m_vecEndPos", end);
        SetEntPropFloat(beament, Prop_Data, "m_fWidth", 4.0);
        AcceptEntityInput(beament, "TurnOff");
        
        
        Beam[beament] = beam;
        endPos[beament] = end;
        beamPos[beament] = beamend;
        targetMine[beament] = ent;
        targetBeam[ent] = beament;
        

        new Handle:data = CreateDataPack();
        CreateTimer(GetConVarFloat(cvActTime), TurnBeamOn, data);
        WritePackCell(data, client);
        WritePackCell(data, beament);
        WritePackFloat(data, end[0]);
        WritePackFloat(data, end[1]);
        WritePackFloat(data, end[2]);
        
        // play sound
        EmitSoundToAll(SND_MINEPUT, beament, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, 100, beament, end, NULL_VECTOR, true, 0.0);
        
        // send message
        PrintHintText(client, "Tripmines remaining: %d", gRemaining[client]);
    }
    else
    {
        PrintHintText(client, "Invalid location for Tripmine");
    }
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if(ZR_IsClientHuman(attacker)){
    //if(GetClientTeam(attacker) == 3){
        
        return Plugin_Handled;
        
    }
    
    new entity = targetBeam[victim];
    if(beamTimer[entity] != INVALID_HANDLE){
        
        KillTimer(beamTimer[entity]);
        beamTimer[entity] = INVALID_HANDLE;
        
    }
    AcceptEntityInput(targetBeam[victim], "Kill");
    return Plugin_Continue;
    
}

public onTouchTripmine(const String:output[], caller, activator, Float:delay){
    
    if(ZR_IsClientZombie(activator)){
    //if(GetClientTeam(activator) == 2){    
        
        AcceptEntityInput(targetMine[caller], "Break");
        AcceptEntityInput(caller, "Kill");
        return;
        
    }
    beamTimer[caller] = CreateTimer(0.1, createBeam, caller);
    /*AcceptEntityInput(caller, "Kill");
    RemoveEdict(caller);
    PrintToChatAll("%d", caller);
    new ent = CreateEntityByName("env_beam");
    TeleportEntity(ent, beamPos[caller], NULL_VECTOR, NULL_VECTOR);
    SetEntityModel(ent, MDL_LASER);
    DispatchKeyValue(ent, "texture", MDL_LASER);
    DispatchKeyValue(ent, "targetname", Beam[caller]);
    DispatchKeyValue(ent, "TouchType", "4");
    DispatchKeyValue(ent, "LightningStart", Beam[caller]);
    DispatchKeyValue(ent, "BoltWidth", "4.0");
    DispatchKeyValue(ent, "life", "0");
    DispatchKeyValue(ent, "rendercolor", "0 0 0");
    DispatchKeyValue(ent, "renderamt", "0");
    DispatchKeyValue(ent, "HDRColorScale", "1.0");
    DispatchKeyValue(ent, "decalname", "Bigshot");
    DispatchKeyValue(ent, "StrikeTime", "0");
    DispatchKeyValue(ent, "TextureScroll", "35");
    HookSingleEntityOutput(ent, "OnTouchedByEntity", onTouchTripmine, false);
    SetEntPropVector(ent, Prop_Data, "m_vecEndPos", endPos[caller]);
    SetEntPropFloat(ent, Prop_Data, "m_fWidth", 4.0);
    DispatchKeyValue(ent, "rendercolor", "0 0 255");
    AcceptEntityInput(ent, "TurnOn");
    Beam[ent] = Beam[caller];
    endPos[ent] = endPos[caller];
    beamPos[ent] = beamPos[caller];
    targetMine[ent] = targetMine[caller];
    targetBeam[targetMine[ent]] = ent;
    PrintToChatAll("activator: %N", activator);*/
    
}

public Action:createBeam(Handle:timer, any:caller){
    
    AcceptEntityInput(caller, "Kill");
    new ent = CreateEntityByName("env_beam");
    TeleportEntity(ent, beamPos[caller], NULL_VECTOR, NULL_VECTOR);
    SetEntityModel(ent, MDL_LASER);
    DispatchKeyValue(ent, "texture", MDL_LASER);
    DispatchKeyValue(ent, "targetname", Beam[caller]);
    DispatchKeyValue(ent, "TouchType", "4");
    DispatchKeyValue(ent, "LightningStart", Beam[caller]);
    DispatchKeyValue(ent, "BoltWidth", "4.0");
    DispatchKeyValue(ent, "life", "0");
    DispatchKeyValue(ent, "rendercolor", "0 0 0");
    DispatchKeyValue(ent, "renderamt", "0");
    DispatchKeyValue(ent, "HDRColorScale", "1.0");
    DispatchKeyValue(ent, "decalname", "Bigshot");
    DispatchKeyValue(ent, "StrikeTime", "0");
    DispatchKeyValue(ent, "TextureScroll", "35");
    HookSingleEntityOutput(ent, "OnTouchedByEntity", onTouchTripmine, false);
    SetEntPropVector(ent, Prop_Data, "m_vecEndPos", endPos[caller]);
    SetEntPropFloat(ent, Prop_Data, "m_fWidth", 4.0);
    DispatchKeyValue(ent, "rendercolor", "0 0 255");
    AcceptEntityInput(ent, "TurnOn");
    new target = targetMine[caller];
    Beam[ent] = Beam[caller];
    endPos[ent] = endPos[caller];
    beamPos[ent] = beamPos[caller];
    targetMine[ent] = target;
    targetBeam[target] = ent;
    beamTimer[caller] = INVALID_HANDLE;
    
}


public Action:TurnBeamOn(Handle:timer, Handle:data)
{
    decl String:color[26];

    ResetPack(data);
    new client = ReadPackCell(data);
    new ent = ReadPackCell(data);

    if (IsValidEntity(ent))
    {
        new team = GetClientTeam(client);
        if(team == TEAM_T) color = COLOR_T;
        else if(team == TEAM_CT) color = COLOR_CT;
        else color = COLOR_DEF;

        DispatchKeyValue(ent, "rendercolor", color);
        AcceptEntityInput(ent, "TurnOn");

        new Float:end[3];
        end[0] = ReadPackFloat(data);
        end[1] = ReadPackFloat(data);
        end[2] = ReadPackFloat(data);

        EmitSoundToAll(SND_MINEACT, ent, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, 100, ent, end, NULL_VECTOR, true, 0.0);
    }

    CloseHandle(data);
}

public mineBreak (const String:output[], caller, activator, Float:delay)
{
    UnhookSingleEntityOutput(caller, "OnBreak", mineBreak);
    AcceptEntityInput(caller,"kill");
}

public bool:FilterAll (entity, contentsMask)
{
    return false;
}
http://pastie.org/private/hamsi6uimxbnhyk655dgtw
i hope it works without lagging.
Bimbo1 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 12:01.


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