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

[Resolved][REQ][TF2]Set weapon alpha


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sreaper
髪を用心
Join Date: Nov 2009
Old 09-17-2013 , 23:25   [Resolved][REQ][TF2]Set weapon alpha
Reply With Quote #1

If it's not too much trouble, I'd let to put in a request that enables me to set the alpha on all of my active weapons. I would very much appreciate it.

Last edited by Sreaper; 09-21-2013 at 16:07.
Sreaper is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-20-2013 , 13:44   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #2

Not sure if it's what you search but Friendly Plugin can fade weapons, not sure if it's with alpha or not.

Here is a link to Friendly plugin : http://forums.alliedmods.net/showthread.php?t=213205

Hope it's help...

EDIT :

Found this :

PHP Code:
stock SetWeaponInvis(clientbool:set true) {
    new 
alpha cvar_alpha_wep;
    for (new 
05i++) {
        new 
entity GetPlayerWeaponSlot(clienti);
        if (
entity != -1) {
            
SetEntityRenderMode(entityRENDER_TRANSCOLOR);
            
SetEntityRenderColor(entity___set alpha 255); // This should do what you want ;) !
        
}
    }

This code was stealed (:O) from friendly plugin.
__________________
Want to check my plugins ?

Last edited by Arkarr; 09-20-2013 at 13:53. Reason: failed something
Arkarr is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-20-2013 , 17:42   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #3

FuncommandsX
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-21-2013 , 01:15   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #4

Quote:
Originally Posted by friagram View Post
FuncommandsX
Yup, forget this possibility.
__________________
Want to check my plugins ?
Arkarr is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-21-2013 , 14:07   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #5

I tried to make it as a compilable plugin but I keep getting error 100 and tag mismatches on this

PHP Code:
#include <sourcemod>
#include <tf2_stocks> 
 
new Handle:cvar_alpha_wep INVALID_HANDLE
 
public 
Plugin:myinfo =
{
    
name "WepAlphanator",
    
author "Assyrian/Nergal",
    
description "makes weapons transparent",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"

 
public 
OnPluginStart()   
{
    
RegAdminCmd("sm_pro"Command_SetWepAlphaADMFLAG_GENERIC);
    
cvar_alpha_wep CreateConVar("sm_alpha_wep""128""Default alpha");
    
AutoExecConfig(true"plugin_alphaweapon"); 
}

public 
Action:Command_SetWepAlpha(client)
{
    if ((
cvar_alpha_wep >= 0) && (cvar_alpha_wep <= 255))
    { 
        
SetWeaponInvis(client); 
    }
}

stock SetWeaponInvis(clientbool:set true)

    new 
alpha cvar_alpha_wep
    for (new 
05i++)
    { 
        new 
entity GetPlayerWeaponSlot(clienti); 
        if (
entity != -1)
        { 
            
SetEntityRenderMode(entityRENDER_TRANSCOLOR); 
            
SetEntityRenderColor(entity___set alpha 255); 
        } 
    }
    return 
Plugin_Continue

__________________
nergal is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 09-21-2013 , 14:25   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #6

Fixed, should work now. Not tested :
PHP Code:
#include <sourcemod>
#include <tf2_stocks> 

new Handle:cvar_alpha_wep INVALID_HANDLE

public 
Plugin:myinfo =
{
    
name "WepAlphanator",
    
author "Assyrian/Nergal",
    
description "makes weapons transparent",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"


public 
OnPluginStart()   
{
    
RegAdminCmd("sm_pro"Command_SetWepAlphaADMFLAG_GENERIC);
    
cvar_alpha_wep CreateConVar("sm_alpha_wep""128""Default alpha");
    
AutoExecConfig(true"plugin_alphaweapon"); 
}

public 
Action:Command_SetWepAlpha(clientargs)
{
    new 
maxalpha GetConVarInt(cvar_alpha_wep);
    
    if ((
maxalpha >= 0) && (maxalpha <= 255))
    { 
        
SetWeaponInvis(client); 
    }
}

stock SetWeaponInvis(clientbool:set true)

    new 
alpha GetConVarInt(cvar_alpha_wep); 
    for (new 
05i++)
    { 
        new 
entity GetPlayerWeaponSlot(clienti); 
        if (
entity != -1)
        { 
            
SetEntityRenderMode(entityRENDER_TRANSCOLOR); 
            
SetEntityRenderColor(entity___set alpha 255); 
        } 
    }

Attached Files
File Type: smx SetWeaponAlpha.smx (4.8 KB, 158 views)
__________________
Want to check my plugins ?
Arkarr is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 09-21-2013 , 14:33   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #7

Seeing as how the code was borrowed from my Friendly Mode plugin...

cvar_alpha_wep is not a handle in the original code. In my original code, all cvars are cached and have their values verified before the rest of the plugin uses them. This prevents particularly moronic server ops from fucking up how the plugin operates by using cvar values that make no fucking sense (such as using a string in a cvar that only uses ints, or using values higher than 255 when setting alpha value, using negative values when only positives work, etc) and then complaing to my tired ears when my plugin "doesn't work" on their server.

At the beginning of your code, you are declaring cvar_alpha_wep as a handle, but you are using it as a standard integer variable later on. Either replace "cvar_alpha_wep >= 0" and such with more correct statements using GetConVarInt(), or (preferrably) cache the values as I have:

PHP Code:
#include <sourcemod>
#include <tf2_stocks> 

new Handle:hcvar_alpha_wep INVALID_HANDLE;
new 
_:cvar_alpha_wep;
 
public 
Plugin:myinfo =
{
    
name "WepAlphanator",
    
author "Assyrian/Nergal",
    
description "makes weapons transparent",
    
version 1.0.0.1,
    
url "http://www.sourcemod.net/"

 
public 
OnPluginStart()   
{
    
RegAdminCmd("sm_alphawep"Command_SetWepAlphaADMFLAG_GENERIC);
    
hcvar_alpha_wep CreateConVar("sm_alphawep""128""Default alpha");
    
HookConVarChange(hcvar_alpha_wepcvarChange);
}

public 
OnConfigsExecuted()
{
    
cvarChange(INVALID_HANDLE"0""0");
}

public 
Action:Command_SetWepAlpha(client)
{
    
SetWeaponInvis(client);
}

stock SetWeaponInvis(clientbool:set true)

    for (new 
05i++)
    { 
        new 
entity GetPlayerWeaponSlot(clienti); 
        if (
entity != -1)
        { 
            
SetEntityRenderMode(entityRENDER_TRANSCOLOR); 
            
SetEntityRenderColor(entity___set cvar_alpha_wep 255); 
        } 
    }
    return 
Plugin_Continue
}

public 
cvarChange(Handle:hHandle, const String:strOldValue[], const String:strNewValue[])
{
    if (
hHandle == hcvar_alpha_wep || hHandle == INVALID_HANDLE)
    {
        
cvar_alpha_wep GetConVarInt(hcvar_alpha_wep);
        if (
cvar_alpha_wep 255 || cvar_alpha_wep 0)
        {
            
cvar_alpha_wep 128;
            
LogError("Value of sm_alphawep is invalid. Plugin will behave as if value was 128.");
        }
    }

You might also want to put in a way to reset the weapons to standard opaqueness. This can be achieved by appending a second argument of "false" to whenever you call SetWeaponInvis()

Code:
SetWeaponInvis(client, false);
__________________

Last edited by ddhoward; 09-21-2013 at 14:39.
ddhoward is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-21-2013 , 14:44   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
Fixed, should work now. Not tested :
PHP Code:
#include <sourcemod>
#include <tf2_stocks> 

new Handle:cvar_alpha_wep INVALID_HANDLE

public 
Plugin:myinfo =
{
    
name "WepAlphanator",
    
author "Assyrian/Nergal",
    
description "makes weapons transparent",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"


public 
OnPluginStart()   
{
    
RegAdminCmd("sm_pro"Command_SetWepAlphaADMFLAG_GENERIC);
    
cvar_alpha_wep CreateConVar("sm_alpha_wep""128""Default alpha");
    
AutoExecConfig(true"plugin_alphaweapon"); 
}

public 
Action:Command_SetWepAlpha(clientargs)
{
    new 
maxalpha GetConVarInt(cvar_alpha_wep);
    
    if ((
maxalpha >= 0) && (maxalpha <= 255))
    { 
        
SetWeaponInvis(client); 
    }
}

stock SetWeaponInvis(clientbool:set true)

    new 
alpha GetConVarInt(cvar_alpha_wep); 
    for (new 
05i++)
    { 
        new 
entity GetPlayerWeaponSlot(clienti); 
        if (
entity != -1)
        { 
            
SetEntityRenderMode(entityRENDER_TRANSCOLOR); 
            
SetEntityRenderColor(entity___set alpha 255); 
        } 
    }

it's working, what was wrong with the way I did it?
__________________
nergal is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 09-21-2013 , 15:00   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #9

Quote:
Originally Posted by nergal View Post
it's working, what was wrong with the way I did it?
Please see my post, directly above yours.

Quote:
At the beginning of your code, you are declaring cvar_alpha_wep as a handle, but you are using it as a standard integer variable later on. Either replace "cvar_alpha_wep >= 0" and such with more correct statements using GetConVarInt(), or (preferrably) cache the values as I have:
__________________
ddhoward is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-21-2013 , 15:10   Re: [REQ][TF2]Set weapon alpha
Reply With Quote #10

Quote:
Originally Posted by ddhoward View Post
Please see my post, directly above yours.
ty howard, one more thing; the stock weapons like rocket launcher, stickybomb launcher, revolver and so on are not becoming transparent.

how do I fix this?

Also, I tried your edited code, it gave me an error 23 + 100 and a tag mismatch :/
__________________

Last edited by nergal; 09-21-2013 at 15:25.
nergal 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 17:44.


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