Cs:go color & some weapons

Please post any questions about developing your plugin here. Please use the search function before posting!
MrMalina
Member
Posts: 53
Joined: Mon Apr 08, 2013 2:40 pm
Location: Russian Federation

Cs:go color & some weapons

Postby MrMalina » Thu Apr 16, 2015 4:16 pm

I was faced with the problem of color changes in cs go:

Syntax: Select all

import wcs

from events import Event
from players.helpers import index_from_userid
from players.entity import PlayerEntity

from colors import Color

from listeners.tick import tick_delays

@Event
def player_spawn(args):
userid = args.get_int("userid")

index = index_from_userid(userid)

player = PlayerEntity(index)

player.set_color(Color(255, 0, 0))


The attachment csgo err 1.jpg is no longer available


I got all the properties PlayerEntity and found:
render_mode and render_fx,
replaced in the. \packages\source-python\entities\entity.py rendermode on render_mode and render_fx, color change earned.
The question is: how do I change the transparency of the player?
And how do I give the players m4a1_silencer and usp silencer?
The list of weapons:
.\data\source-python\weapons\cs go.ini no such weapons
Attachments
csgo err 1.jpg
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Apr 16, 2015 5:00 pm

Thank you for reporting about the render properties. We will get that fixed as soon as possible.

As far as transparency, there is no really good way to do it in CS:GO, unfortunately. I will try to give more info tonight.

I am not fully sure on the weapons, will test some stuff tonight.
Image
MrMalina
Member
Posts: 53
Joined: Mon Apr 08, 2013 2:40 pm
Location: Russian Federation

Postby MrMalina » Thu Apr 16, 2015 5:51 pm

I found the name of these two weapons:
weapon_m4a1_silencer,
weapon_usp_silencer.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Apr 16, 2015 6:27 pm

Have you tried giving those items with those names? I remember doing some testing a couple months ago and finding that the extra weapons on the inventory screen are duplicates of other entities. Those entity names you mention do not print out with dumpentityfactories. I haven't tested to see if they are listed in the factory_dictionary, but I doubt they are listed there, either.
Image
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Thu Apr 16, 2015 10:18 pm

Unfortunately when it comes to CS:GO there's only three ways to set a client's visibility and none of them are that good.
  • Set the client's render_fx: https://sm.alliedmods.net/new-api/entit ... ocks/__raw has a list of the possible values.
  • Simply set them to not transmit (rendering them completely invisible).
  • Three is to compile models with different alpha values baked into them, preferably using the skin indices to avoid having massive numbers of models. This method WILL allow partial invisibility (and a few servers definitely use it) but requires a large amount of data to be downloaded to the client as well as any custom models having to be modified and recompiled AND not giving you very good resolution for alpha values (There's a maximum of 32 skins per model).
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Apr 16, 2015 10:40 pm

necavi wrote:

Hardcoding values in your code is a bad idea. Use the wrappers, instead. In this specific case: from entities.constants import RenderEffects
MrMalina
Member
Posts: 53
Joined: Mon Apr 08, 2013 2:40 pm
Location: Russian Federation

Postby MrMalina » Fri Apr 17, 2015 8:32 am

Satoon101, yes, i could give out this weapon to the player through player.give_named_item ("weapon_m4a1_silencer", 0, None, False).
I looked for the name of the weapon in server\csgo\csgo\scripts, there I found the weapon_m4a1.txt and game_sounds_weapons.txt file. I found in weapon_m4a1.txt:
"special1" "Weapon_M4A1.Silenced"

And in game_sounds_weapons.txt:
"Weapon_M4A1.SilencerWeaponMove1"

And in the server\csgo\csgo\scripts\items\game_items.txt file there is a mention
"[hy_varicamo]weapon_m4a1_silencer" "1"
"[hy_siege_bravo]weapon_usp_silencer" "1"

Then tried to write weapon_m4a1_silencer.

---
But after all at the beginning of warm-up, the player becomes a little more transparent:
2015-04-17_00001.jpg

2015-04-17_00001.jpg
Attachments
2015-04-17_00002.jpg
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Fri Apr 17, 2015 5:00 pm

If I remember correctly from my research a few years ago, that transparency was a client set value in relation to being sent an event like round_start or something similar and forced ALL players to be that set alpha value.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Postby arawra » Wed May 27, 2015 5:56 am

Does this mean the end of Rogues in my mod...?
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Wed May 27, 2015 5:58 am

Funny you should mention that, because as of today you CAN use transparency in CS:GO with two caveats:
- sv_disable_immunity_alpha has to be set to 1
- Teammates ALWAYS show up as 100% visible.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed May 27, 2015 5:59 am

I have read that the newest CS:GO update actually fixes the alpha issue. However, it requires the server to set a new cvar (sv_disable_immunity_alpha) to 1. I haven't tested myself to verify, but I have seen this posted elsewhere as working now.

*Edit: too slow, and did not know about the teammate issue...seriously Valve....
Image
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Wed May 27, 2015 6:02 am

Funnily enough, alpha values are correct for your own model when you're in thirdperson. Inconsistent as hell.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Postby arawra » Wed May 27, 2015 8:09 am

I've been playing around tonight seeing what I can do. I thought I had the alpha changing with this code:

Syntax: Select all

@Event
def player_spawn(game_event):
victim_userid = game_event.get_int('userid')
victim = PlayerEntity(index_from_userid(victim_userid))
victim.render_color = Color(255, 255, 255, 30)


Now, this *WAS* working. I made sure this was the right code by CTRL+Z'ing after trying to add this in to try and change weapon alpha:

Syntax: Select all

@Event
def item_equip(game_event):
weapon_index = game_event.get_int('index')
weapon = BaseEntity(weapon_index)
weapon.render_color = Color(255, 255, 255, 30)


I also tried again using Color(255,255,255).with_alpha(30)

I don't know why, but now I can't seem to reproduce the same results. I double checked, and "sv_disable_immunity_alpha 1" is in my autoexec and made sure that it was set to 1 via console.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Postby arawra » Wed May 27, 2015 11:05 am

I was also trying to test out giving players items, but I think the signature/offset may have changed with the latest update. No tracebacks.

Syntax: Select all

@Event
def player_say(game_event):
player = PlayerEntity(index_from_userid(game_event.get_int('userid')))
player.give_named_item(game_event.get_string('text'), 0, None, False)
msg(game_event.get_string('text'))
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Wed May 27, 2015 11:26 am

Yeh the offsets have changed, just check this website if you want the current up to date ones.

https://www.sourcemodplugins.org/vtableoffsets/csgo

GiveNamedItem is now 446 and 447 for windows and linux, respectively.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed May 27, 2015 1:44 pm

To set the alpha, you have to set the entity keyvalue renderamt's value. We will get those issues sorted out in due time.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 152 guests