Raised This Month: $ Target: $400
 0% 

[TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)


Post New Thread Reply   
 
Thread Tools Display Modes
B_CANSIN
Senior Member
Join Date: Aug 2011
Location: B_CANSIN's SERVERS
Old 03-14-2014 , 12:49   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #71

Quote:
Originally Posted by MasterOfTheXP View Post
It's supposed to do that.

Not sure about your weapon models though Maybe make sure tf2items.randomizer.txt is installed properly? Never mind, I'm dumb. This can't be helping, though:Make sure your TF2Attributes gamedata is up-to-date as well. Although, similarly to TF2ItemsInfo, there seems to be quite a few people having problems with it recently...
Sorry I thougth update plunig but I think I miss the txt well thank you for helping me now its working ^ ^ and I lets see how can I add more mdoels to it lol ı got 250 skins now what will be happend if I put more lol

Last edited by B_CANSIN; 03-14-2014 at 12:49.
B_CANSIN is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-15-2014 , 00:07   Re: [TF2] Custom Weapons 2 (Beta)
Reply With Quote #72

Quote:
Originally Posted by B_CANSIN View Post
Note: I got 413 plunigs or more
pm me a sm plugins list, i can't believe this. Unless you're talking about ff2 bosses i just cant see this happening. especially since i thought there was a limit sourcemod could have loaded.
Mitchell is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 03-22-2014 , 01:17   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #73

For some reason when I use a weapon using one of my attributes I made, it toggles the attribute on everyone on the server.

Here's the code:

Code:
#pragma semicolon 1
#include <tf2_stocks>
#include <sdkhooks>
#include <customweaponstf>

#define PLUGIN_VERSION "beta 2"

public Plugin:myinfo = {
    name = "Custom Attributes",
    author = "Bitl",
    description = "Attributes for Custom Weapons",
    version = PLUGIN_VERSION,
    url = ""
};

new bool:HasAttribute[2049];
new bool:PowerPlayOnKill[2049];
new bool:BloodAndJarate[2049];
new bool:BloodAndMilk[2049];
new bool:PowerPlayOP[2049];
new bool:SkeleOnKill[2049];
new bool:HelpfulSkele[2049];
new Float:g_pos[3];

public OnPluginStart()
{
    HookEvent("player_death", event_PlayerDeath);
    //HookEvent("player_spawn", event_PlayerSpawn);
    
    for (new i = 1; i <= MaxClients; i++)
    {
        if (!IsClientInGame(i)) continue;
        OnClientPutInServer(i);
    }
}

public OnClientPutInServer(client)
{
    //SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
    SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePost);
    //SDKHook(client, SDKHook_TraceAttack, OnTraceAttack);
}

//Attributes In This Plugin:
//
//"powerplay on kill five secs"
//If you kill a player, you get powerplay for 5 seconds.
//
//"jarate and bleed"
//If you hit a player, they will get covered in jarate and bleed for 15 seconds.
//
//"mad milk and bleed"
//If you hit a player, they will get covered in mad milk and bleed for 15 seconds.
//
//"powerplay on kill op"
//If you kill a player, you get powerplay permanently for your current life.
//
//"skeleton on kill"
//If you kill a player, a skeleton pops out of your victim's body and KILLS YOU for 25 seconds.
//
//"friendly skeleton on kill"
//If you press ATTACK3, a skeleton spawns where you look and HELPS YOU KILL for 25 seconds.

public Action:CustomWeaponsTF_OnAddAttribute(weapon, client, const String:attrib[], const String:plugin[], const String:value[])
{
    if (!StrEqual(plugin, "customattributes")) return Plugin_Continue;
    
    new Action:action;
    
    if (StrEqual(attrib, "powerplay on kill five secs"))
    {
        PowerPlayOnKill[weapon] = true;
        action = Plugin_Handled;
    }
    else if (StrEqual(attrib, "jarate and bleed"))
    {
        BloodAndJarate[weapon] = true;
        action = Plugin_Handled;
    }
    else if (StrEqual(attrib, "mad milk and bleed"))
    {
        BloodAndMilk[weapon] = true;
        action = Plugin_Handled;
    }
    else if (StrEqual(attrib, "powerplay on kill op"))
    {
        PowerPlayOP[weapon] = true;
        action = Plugin_Handled;
    }
    else if (StrEqual(attrib, "skeleton on kill"))
    {
        SkeleOnKill[weapon] = true;
        action = Plugin_Handled;
    }
    else if (StrEqual(attrib, "friendly skeleton on kill"))
    {
        HelpfulSkele[weapon] = true;
        action = Plugin_Handled;
    }
    
    if (!HasAttribute[weapon]) HasAttribute[weapon] = bool:action;
    
    return action;
}
// ^ Remember, this is called once for every custom attribute (attempted to be) applied!

public event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "attacker"));
    new victim = GetClientOfUserId(GetEventInt(event, "userid"));
    if (!IsClientInGame(client)) return;
    if (!IsPlayerAlive(client)) return;
    new wep = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
    if (wep == -1) return;
    if (!HasAttribute[wep]) return;
    
    if (wep > -1)
    {
        if (HasAttribute[wep])
        {
            if (PowerPlayOnKill[wep])
            {
                CreateTimer(0.1, Timer_PowerPlay, client);
            }
    
            if (PowerPlayOP[wep])
            {
                TF2_SetPlayerPowerPlay(client, true);
            }
    
            if (SkeleOnKill[wep])
            {
                SpawnSkeleton(victim);
            }
            
            if (HelpfulSkele[wep])
            {
                SpawnSkeletonAtClientPoint(client);
            }
        }
    }
}

//public event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
//{
    //new client = GetClientOfUserId(GetEventInt(event, "userid"));
    //if (!IsClientInGame(client)) return;
    //if (!IsPlayerAlive(client)) return;
    //new wep = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
    //if (wep == -1) return;
    //if (!HasAttribute[wep]) return;
//}

public OnTakeDamagePost(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3])
{
    if (attacker <= 0 || attacker > MaxClients) return;
    if (weapon == -1) return;
    if (!HasAttribute[weapon]) return;
    
    if (weapon > -1)
    {
        if (HasAttribute[weapon])
        {
            if (BloodAndJarate[weapon] && victim != attacker && HasAttribute[weapon])
            {
                TF2_MakeBleed(victim, attacker, 15.0);
                TF2_AddCondition(victim, TFCond_Jarated, 15.0);
            }
    
            if (BloodAndMilk[weapon] && victim != attacker && HasAttribute[weapon])
            {
                TF2_MakeBleed(victim, attacker, 15.0);
                TF2_AddCondition(victim, TFCond_Milked, 15.0);
            }
        }
    }
}

public Action:Timer_PowerPlay(Handle:timer, any:client)
{
    TF2_SetPlayerPowerPlay(client, true);
    CreateTimer(5.0, Timer_PowerPlayEnd, client);
    return Plugin_Stop;
}

public Action:Timer_PowerPlayEnd(Handle:timer, any:client)
{
    TF2_SetPlayerPowerPlay(client, false);
    return Plugin_Stop;
}

SpawnSkeletonAtClientPoint(client)
{
    if(!SetTeleportEndPoint(client))
    {
        PrintToChat(client, "[SM] Could not find spawn point.");
    }
    if(GetEntityCount() >= GetMaxEntities()-32)
    {
        PrintToChat(client, "[SM] Entity limit is reached. Can't spawn anymore pumpkin lords. Change maps.");
    }
    new entity = CreateEntityByName("tf_zombie");
    if(IsValidEntity(entity))
    {
        g_pos[2] -= 10.0;
        TeleportEntity(entity, g_pos, NULL_VECTOR, NULL_VECTOR);
        
        SetEntProp(entity, Prop_Send, "m_iTeamNum", GetClientTeam(client));
        SetEntProp(entity, Prop_Send, "m_nSkin", GetClientTeam(client) - 2);
        
        CreateTimer(1.0, Timer_SpawnDelay, entity);
    }
}

SpawnSkeleton(client)
{
    new Float:vecOrigin[3];
    new Float:vecAngles[3];
    GetClientAbsOrigin(client, vecOrigin);
    
    new entity = CreateEntityByName("tf_zombie"); // Skeleton
    
    if(IsValidEntity(entity))
    {
        vecAngles[1] = GetRandomFloat(1.0, 360.0);
        TeleportEntity(entity, vecOrigin, vecAngles, NULL_VECTOR);
        
        SetEntProp(entity, Prop_Send, "m_iTeamNum", GetClientTeam(client));
        SetEntProp(entity, Prop_Send, "m_nSkin", GetClientTeam(client) - 2);
        
        CreateTimer(1.0, Timer_SpawnDelay, entity);
    }
}

public Action:Timer_SpawnDelay(Handle:timer, any:entity)
{
    DispatchSpawn(entity);
    CreateTimer(24.0, Timer_KillSkeleton, entity);
    return Plugin_Stop;
}

public Action:Timer_KillSkeleton(Handle:timer, any:entity)
{
    if(IsValidEntity(entity))
    {
        AcceptEntityInput(entity, "Kill");
    }
    return Plugin_Stop;
}

stock bool:IsValidClient(client)
{
    if (client <= 0 || client > MaxClients) return false;
    if (!IsClientInGame(client)) return false;
    if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
    return true;
}

SetTeleportEndPoint(client)
{
    decl Float:vAngles[3];
    decl Float:vOrigin[3];
    decl Float:vBuffer[3];
    decl Float:vStart[3];
    decl Float:Distance;
    
    GetClientEyePosition(client,vOrigin);
    GetClientEyeAngles(client, vAngles);
    
    //get endpoint for teleport
    new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);

    if(TR_DidHit(trace))
    {        
            TR_GetEndPosition(vStart, trace);
        GetVectorDistance(vOrigin, vStart, false);
        Distance = -35.0;
            GetAngleVectors(vAngles, vBuffer, NULL_VECTOR, NULL_VECTOR);
        g_pos[0] = vStart[0] + (vBuffer[0]*Distance);
        g_pos[1] = vStart[1] + (vBuffer[1]*Distance);
        g_pos[2] = vStart[2] + (vBuffer[2]*Distance);
    }
    else
    {
        CloseHandle(trace);
        return false;
    }
    
    CloseHandle(trace);
    return true;
}

public bool:TraceEntityFilterPlayer(entity, contentsMask)
{
    return entity > GetMaxClients() || !entity;
}
__________________
My Plugins
Modified Plugins:
Building Spawner
Monster
It's Raining Men!
Tutorials:
Custom Gamemode

I DON'T DO PLUGIN REQUESTS.

Last edited by Bitl; 03-22-2014 at 14:26.
Bitl is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-23-2014 , 18:33   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #74

Sorry for the delayed response Your attributes seem fine to me, I tested each one and they all worked only on me.

Although:
  • You should pass user ids (GetClientUserId/GetClientOfUserId) to timers instead of client indexes, or at the very least verify that the client is still in-game for extremely short timers like 0.1 seconds.
  • You ought to combine "powerplay on kill five secs" and "powerplay on kill op" into one attribute; that's what the "value" parameter is for!
  • Lastly, you probably shouldn't call it "Custom Attributes" to avoid confusion with my default ones. I know, mine are badly named (those names worked perfectly in CS:GO) but it's a bit late to change them now.

EDIT: Oh, oh, you didn't include the OnEntityDestroyed bit, that's why the attributes are sticking. You gotta reset the attribute variables to 0/whatever's default when the weapon entity is destroyed.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 03-23-2014 at 18:36.
MasterOfTheXP is offline
ZooL
Member
Join Date: Apr 2013
Location: France
Old 03-25-2014 , 13:05   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #75

Found an other bug D:

when you have the HighFive equiped, if the weapon isn't a weapon that the class normaly have (pipebomblauncher for pyro for exemple) the player will have his hand up like of he was doing a HF, but if the HF isn't equiped, it works

Could u fix this ?
ZooL is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-25-2014 , 13:08   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #76

D'you mean for the HUD 3D character icon?

Bawwwww. There's a fix for that, but it's pretty bad. It requires the use of SendProxy to fake the item's definition index to one that the class actually has (like pretending that a sticky launcher is actually the stock Fire Axe)

In a bit, I'll check to see if doing that would cause any major issues, like the viewmodel animations changing. Hopefully, it won't.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
ZooL
Member
Join Date: Apr 2013
Location: France
Old 03-25-2014 , 13:41   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #77

nonono, it happens to the hud indeed, but when you go in Thirdperson, on YOUR side its allright but on the OTHERS client side, it does the highfive thing D:

ask a friend to come and see.

Last edited by ZooL; 03-25-2014 at 13:41.
ZooL is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-25-2014 , 13:53   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #78

could you add a new keyvalue for faking the item index? i think that'd be fun to mess with, haha.
Mitchell is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-25-2014 , 14:43   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #79

Quote:
Originally Posted by ZooL View Post
nonono, it happens to the hud indeed, but when you go in Thirdperson, on YOUR side its allright but on the OTHERS client side, it does the highfive thing D:

ask a friend to come and see.
Weird, I'll check again later; though I've never seen it in multiplayer testing on either of my servers.
Quote:
Originally Posted by Mitchell View Post
could you add a new keyvalue for faking the item index? i think that'd be fun to mess with, haha.
Ooh, even better
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-25-2014 , 15:04   Re: [TF2] Custom Weapons 2 (Beta 2, Mar 12 2014)
Reply With Quote #80

will you be adding auto-updater to this, or not even gunna play with it? lol

I can already think of a few gamemodes that would use this.
Mitchell 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 14:21.


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