Give nightvision

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 417
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Give nightvision

Postby decompile » Mon Feb 08, 2016 11:19 pm

Hey,

Is it possible to give someone the nightvision screen ( the green overlay one ) with just a command?

So lets say the player has no nightvision goggles & if you would type !nvgs can you give him that nightvision view?

Sorry, im on my phone
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Feb 08, 2016 11:38 pm

has_nightvision and nightvision_on are already added as attributes for player entities for CS:S but not CS:GO. I am not sure if it even works for CS:GO, but if it does, we can add it.
Image
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Feb 09, 2016 4:10 am

Actually, had a bit of time to test CS:GO. It seems that the functionality still exists for this, but the item isn't included in the buy menu. If I use the following script:

Syntax: Select all

from commands.say import SayCommand
from players.entity import Player

@SayCommand('nvg')
def give_nvg(command, index, team_only):
Player(index).has_nightvision = True

then, I can use the following in my client console to activate the nightvision overlay:

Code: Select all

nightvision

That is, of course, after adding the properties to our data. You can also just set the nightvision_on attribute if you don't really want to worry about ownership of them:

Syntax: Select all

from commands.say import SayCommand
from players.entity import Player

@SayCommand('nvg')
def nvg_toggle(command, index, team_only):
player = Player(index)
player.nightvision_on = 1 - (player.nightvision_on % 2)

Both has_nightvision and nightvision_on are not 1/0 values the first time you retrieve them, which is why I used %2 and not just simply set to True/False on the toggle. The only exception to that is CS:GO's has_nightvision. I think we should probably fix that internally to pass back either 1/0 or True/False in these situations. Setting to 1/0 or True/False works just fine, though.

I will go ahead and add those to CS:GO's data and we will make the other adjustments when we get the chance.
Image
decompile
Senior Member
Posts: 417
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Tue Feb 09, 2016 11:14 am

satoon101 wrote:Actually, had a bit of time to test CS:GO. It seems that the functionality still exists for this, but the item isn't included in the buy menu. If I use the following script:

Syntax: Select all

from commands.say import SayCommand
from players.entity import Player

@SayCommand('nvg')
def give_nvg(command, index, team_only):
Player(index).has_nightvision = True

then, I can use the following in my client console to activate the nightvision overlay:

Code: Select all

nightvision

That is, of course, after adding the properties to our data. You can also just set the nightvision_on attribute if you don't really want to worry about ownership of them:

Syntax: Select all

from commands.say import SayCommand
from players.entity import Player

@SayCommand('nvg')
def nvg_toggle(command, index, team_only):
player = Player(index)
player.nightvision_on = 1 - (player.nightvision_on % 2)

Both has_nightvision and nightvision_on are not 1/0 values the first time you retrieve them, which is why I used %2 and not just simply set to True/False on the toggle. The only exception to that is CS:GO's has_nightvision. I think we should probably fix that internally to pass back either 1/0 or True/False in these situations. Setting to 1/0 or True/False works just fine, though.

I will go ahead and add those to CS:GO's data and we will make the other adjustments when we get the chance.


Perfect! Exactly what I wanted. Thank you
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Re:

Postby satoon101 » Tue Apr 26, 2016 10:12 pm

satoon101 wrote:Both has_nightvision and nightvision_on are not 1/0 values the first time you retrieve them, which is why I used %2 and not just simply set to True/False on the toggle. The only exception to that is CS:GO's has_nightvision. I think we should probably fix that internally to pass back either 1/0 or True/False in these situations. Setting to 1/0 or True/False works just fine, though.


Just wanted to note that we just fixed the above issue with SendProps!! We now use the <SendProp>.bits to determine the size of SendPropType.INT properties.

A big thank you to your-name-here for pointing us in this direction!

For the above example, it would now simply look like:

Syntax: Select all

from commands.say import SayCommand
from players.entity import Player

@SayCommand('nvg')
def nvg_toggle(command, index, team_only):
player = Player(index)
player.nightvision_on = not player.nightvision_on

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 69 guests