Raised This Month: $32 Target: $400
 8% 

Setting entity render alpha to 0 on weapons (knife)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JZServices
Member
Join Date: Jul 2013
Old 01-05-2021 , 00:27   Setting entity render alpha to 0 on weapons (knife)
Reply With Quote #1

I am trying to set a bots (not sure if it makes a difference) knife entity render color to 0 (or another way to make it invisible).

I have tried the following:

Code:
CreateTimer(2.0, Timer_Alphaknife, client);

public Action Timer_Alphaknife(Handle timer, any client)
{
    // Loop through array slots and set alpha.
    // x = weapon slot.
    for (int x = 0; x < 5; x++)
    {
        int weapons = GetPlayerWeaponSlot(client, x);
        // If weapon is invalid, then stop.
        if (weapons == -1)
        {
            continue;
        }
        
        if(!HasEntProp(weapons, Prop_Send, "m_nRenderMode"))
            continue;
            
            
        // Turn rendermode on, on the weapon.
        SetEntityRenderMode(weapons, RENDER_TRANSALPHA);
        
        // Set alpha value on the weapon.
        SetEntityRenderColor(weapons, _, _, _, 0);
    }
}
The above a timer delay after spawn to set the render color (thinking maybe the entity didn't exist yet or something)

Also:

Code:
 int knife = GivePlayerItem(client, "weapon_knife", 0);
    if (knife != -1)
    {
        PrintToServer("Knife entity %d",knife);
        //SetEntityRenderMode(knife, RENDER_TRANSALPHA);
        //SetEntityRenderColor(knife, 255, 255, 255, 0);
        //SetEntData(knife, 127, 0, 4, true);
        SetEntityRenderMode(knife, RENDER_TRANSALPHA);
        SetEntityRenderColor(knife, _, _, _, 50);


//SetEntityRenderMode(knife, RENDER_TRANSCOLOR);
        //SetEntityRenderColor(knife, 255, 255, 255, 0);
        
    }
If I grab entities such as players the above code seems to work fine. The //commented out with transalpha method was what worked to begin with years ago and I'm working on getting the plugin working again. Anyone have any ideas on this?

Thank you!
JZServices is offline
AePT
Member
Join Date: Jan 2016
Old 01-05-2021 , 04:06   Re: Setting entity render alpha to 0 on weapons (knife)
Reply With Quote #2

You can use this, it works. (I didn't test it with bots.)

Code from here: https://forums.alliedmods.net/showthread.php?t=239132


PHP Code:
public void OnClientPutInServer(int iClient) {

    
SDKHook(iClientSDKHook_WeaponSwitchPostOnWeaponSwitchPost);
}

public 
void OnClientDisconnect(int iClient) {

    
SDKUnhook(iClientSDKHook_WeaponSwitchPostOnWeaponSwitchPost);
}

public 
void OnWeaponSwitchPost(int iClientint iWeapon) {

    
char sWeaponName[64];
    
GetEntityClassname(iWeaponsWeaponNamesizeof(sWeaponName));

    if(
StrContains(sWeaponName"knife"false) != -1)
        
SetViewmodelVisibility(iClientfalse);

    
SetViewmodelVisibility(iClienttrue);
}

void SetViewmodelVisibility(int iClientbool bVisible) {

    
SetEntProp(iClientProp_Send"m_bDrawViewmodel"bVisible);

AePT is offline
JZServices
Member
Join Date: Jul 2013
Old 01-05-2021 , 15:25   Re: Setting entity render alpha to 0 on weapons (knife)
Reply With Quote #3

I disabled the other code setting the knife color and hooked to just the bots.
I created a print statement in "void SetViewmodelVisibility(int iClient, bool bVisible) {" and it is running the code but the models still seem to be holding a visible knife.

I only have a few plugins running but I'm going to double check that they aren't trying to set the render color. I double checked one but didn't see anything yet.

Otherwise I might try to run on a blank server with no other plugins/custom models and build up.

Thank you. I'll respond when I get the chance to do this I got a few other bugs that are a little higher priority with the amount of time that I've put into this and what's needed to troubleshoot. Thanks!
JZServices is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 01-06-2021 , 05:47   Re: Setting entity render alpha to 0 on weapons (knife)
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=273578
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
Reply


Thread Tools
Display Modes

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 22:42.


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