PDA

View Full Version : Invisible weapon code snippet


NCrawler
02-13-2010, 20:43
The following code can be used to make all the players weapons invisible/visible:

public SetWeaponColor(client,r,g,b,o)
{
for(new i=0; i < 4; i++)
{
new entity = GetPlayerWeaponSlot(client,i);
if(entity != -1)
{
SetEntityRenderMode(entity,RENDER_TRANSCOLOR) ;
SetEntityRenderColor(entity,r,g,b,o);
}
}
}

For invisibility, call it with: SetWeaponColor(client,255,255,255,0);
and: SetWeaponColor(client,255,255,255,255); to make them visible again...




NC

rhelgeby
02-14-2010, 07:58
Thank you for contributing. This is done almost exactly the same way as we did it: http://code.google.com/p/zombiereloaded/source/browse/src/zr/weapons/weaponalpha.inc?repo=zr-3-0-b2#125

Our weapons actually do get invisible, so that part of our code works. However, there's a problem. It appears that only active weapons are invisible, not the weapons players carry. So weapons on your back are still visible, only the weapon you use is visible. If you drop them that works fine too, all turn invisible.

Apparently the weapons you see on the players' back are not the same entities as those they're holding in their hands. If you know anything about this we would like to know. You use RENDER_TRANSCOLOR and we use RENDER_TRANSALPHA. Maybe that's it?

Btw, you don't need to make your function public unless it's used as a callback function.

exvel
02-14-2010, 09:55
rhelgeby, if you will find a way how to get indexes of carried weapons please tell me. :) I know (from donor's forum) there is no way to change their transparency but I think it is possible to block their transmitting (like they are invisible). Anyway I have no idea how to get those indexes... maybe they are logical entities?

Greyscale
02-14-2010, 13:39
exvel: I did some tests trying to get their indexes, there are none. A friend and I made a list of entities, each bought a deagle, created a list of entities, holstered the deagle, and created another list of entities, and there was no difference in the lists at all besides the new deagle.

I think they are model attachments, but for some reason don't turn invisible with the player..

retsam
02-16-2010, 00:57
I noticed the same problem lately with one of my admin management plugins (godclip). Was testing on CSS and noticed the nonactive pistols that get added to the model or whatever, are never invis. Pretty sure this applies to any bomb defuser kit or grenades, etc... Kinda sucks since that means you can pretty much never have complete invisibility in CSS.

Fearts
02-22-2010, 15:46
Yea I was looking for a solution to this problem too. Not for ZM but for a solution to est_restrict breaking.

I figure if players already have a weapon then they wont be able to pick up any on the ground. But the problem is getting it so they are not visible.

Fearts
02-25-2010, 02:50
OK, I think I found a solution. This is what I did:

est_setmodel <player> props_c17/statue_horse
est_setplayercolor <player> 0 0 0 0 1

If you give weapons to the player before you turn invisible there will be no need for next step.

Once player switches weapons they turn invisible.

This will turn weapon that the player is holding invisible too.

rhelgeby
02-25-2010, 03:12
So this is some kind of a priority issue? Right now player alpha is applied before weapon alpha.

Fearts
02-25-2010, 03:19
I only made the post as a work around if you are trying to make holstered weapons invisible I have found a way to make it possible.

Greyscale
02-25-2010, 17:51
I'm not sure I understand what you mean, Fearts.

We set the alpha player and then all his weapons and that doesn't seem to work.

exvel
02-25-2010, 23:46
I'm not sure I understand what you mean, Fearts.

We set the alpha player and then all his weapons and that doesn't seem to work.
well, this will work only for fully invisible players... you just changes player's model to the random one and then changing transparency. Nice trick :)

Greyscale
02-26-2010, 00:12
Ohh, ok. Set to something other than a player model and then chance alpha. Makes sense, not the best solution, but the only solution.

Fearts
02-26-2010, 05:50
well, this will work only for fully invisible players... you just changes player's model to the random one and then changing transparency. Nice trick :)


Yea thanks. Also to anyone using my trick I would suggest using like crow model or a small model so it doesn't lag the server up.

rhelgeby
02-26-2010, 12:18
It might work with invisible weapons, but what about 50% transparent players? There must be a way to make this possible too.

Greyscale
02-26-2010, 17:49
Well as far as anyone knows right now, it isn't possible to change the model attachments' alpha. His trick would only work for fully invisible players. If you set it to 50% you would be a half visible pigeon walking around :P

exvel
02-27-2010, 03:13
Well as far as anyone knows right now, it isn't possible to change the model attachments' alpha. His trick would only work for fully invisible players. If you set it to 50% you would be a half visible pigeon walking around :P
For me is only problem to get those attached entities indexes. I could block their transmitting with SDKHooks and make player transparent as he should be. :)

Greyscale
02-27-2010, 04:22
There are no actual entities that are attached. It's part of the model, but the alpha property of the player doesn't affect it, so it seems.

I don't know anything for sure, but if they have an entity index, it's very hard to find.