Page 1 of 1

Radar possebilities?

Posted: Sun May 11, 2014 11:28 am
by Tuck
Is there anyway to call a method, for showing a enemy on the radar? such as a decoy would do

I'm thinking there might be some engine method to do so

thanks in advance :)

Posted: Mon May 12, 2014 10:14 am
by L'In20Cible
Something like this should works:

Syntax: Select all

from entities import EntityGenerator
from filters.players import PlayerIter
from listeners.tick import Tick

for player_manager in EntityGenerator('cs_player_manager'):
break

@Tick
def tick_listener():
for index in PlayerIter('alive'):
player_manager.set_prop_int('m_bPlayerSpotted.%03d' % index, True)

Posted: Mon May 12, 2014 8:15 pm
by devilsnake88
It's awesome! And it's give me some scripts ideas ^^

Posted: Fri Oct 10, 2014 6:31 am
by 8guawong

Syntax: Select all

@Tick
def tick_listener():
for index in PlayerIter('alive'):
player_manager.set_prop_int('m_bPlayerSpotted.%03d ' % index, False)


is this how to disable radar??

Posted: Fri Oct 10, 2014 7:02 am
by L'In20Cible
To disable the radar on CS:GO check out the following.

Syntax: Select all

from filters.players import PlayerIter

HIDEHUD_RADAR = 1 << 12

@Event
def round_start(game_event):
# Loop through all living players...
for edict in PlayerIter('alive', return_types=['edict']):

# Get the player's hidden huds...
hidehud = edict.get_prop_int('m_iHideHud')

# Is the player already have the radar disabled?
if hidehud & HIDEHUD_RADAR:

# If so, no need to go further...
continue

# Hide the player's radar...
edict.set_prop_int('m_iHideHud', hidehud | HIDEHUD_RADAR)

Posted: Fri Oct 10, 2014 7:19 am
by 8guawong
L'In20Cible wrote:To disable the radar on CS:GO check out the following.

Syntax: Select all

from filters.players import PlayerIter

HIDEHUD_RADAR = 1 << 12

@Event
def round_start(game_event):
# Loop through all living players...
for edict in PlayerIter('alive', return_types=['edict']):

# Get the player's hidden huds...
hidehud = edict.get_prop_int('m_iHideHud')

# Is the player already have the radar disabled?
if hidehud & HIDEHUD_RADAR:

# If so, no need to go further...
continue

# Hide the player's radar...
edict.set_prop_int('m_iHideHud', hidehud | HIDEHUD_RADAR)


thank you! really need to learn bout bitwise opertaions

Posted: Fri Oct 10, 2014 7:31 am
by L'In20Cible
I may add that this won't work on CS:S, tho. While this flag is available, it is just ignored when rendering the radar. They did fix it on CS:GO (at least, it was when I was testing a while back). On CS:S, it requires to hack a bit.

Posted: Fri Oct 10, 2014 9:08 am
by 8guawong
L'In20Cible wrote:I may add that this won't work on CS:S, tho. While this flag is available, it is just ignored when rendering the radar. They did fix it on CS:GO (at least, it was when I was testing a while back). On CS:S, it requires to hack a bit.


i wanted to know for csgo so you read my mind!

Posted: Wed Jun 03, 2015 9:02 pm
by Doldol
L'In20Cible wrote:Something like this should works:

Syntax: Select all

from entities import EntityGenerator
from filters.players import PlayerIter
from listeners.tick import Tick

for player_manager in EntityGenerator('cs_player_manager'):
break

@Tick
def tick_listener():
for index in PlayerIter('alive'):
player_manager.set_prop_int('m_bPlayerSpotted.%03d' % index, True)


Tried updating this piece of code, can't get it to work.

Syntax: Select all

from entities.entity import BaseEntity
from entities import EntityGenerator
from filters.players import PlayerIter
from listeners import Tick

for edict in EntityGenerator('cs_player_manager'):
player_manager = BaseEntity(index_from_edict(edict))
break


@Tick
def tick_listener():
for index in PlayerIter('alive', return_types='index'):
player_manager.set_key_value_bool("m_bPlayerSpotted.{0:03d}".format(index), True)

Posted: Wed Jun 03, 2015 9:07 pm
by satoon101
You want set_property_bool not set_key_value_bool. That was part of the entities changes when we merged SendProps with DataMaps.

Edit: also, you want Entity and not BaseEntity.
Edit2: though, you could also use EntityIter instead of using EntityGenerator directly:
http://wiki.sourcepython.com/pages/filters.entities

Posted: Wed Jun 03, 2015 9:58 pm
by Doldol
Thanks, this ended up working:

Syntax: Select all

for player_manager in EntityIter('cs_player_manager', return_types="entity"):
break


@Tick
def tick_listener():
for index in PlayerIter('alive', return_types='index'):
player_manager.set_property_int("m_bPlayerSpotted.{0:03d}".format(index), 1)

Posted: Wed Jun 03, 2015 10:09 pm
by satoon101
Oh yeah, int not bool. That is a SendProp and there is no boolean SendPropType.

Posted: Thu Jun 04, 2015 12:13 pm
by BackRaw
L'In20Cible wrote:To disable the radar on CS:GO check out the following.

Syntax: Select all

from filters.players import PlayerIter

HIDEHUD_RADAR = 1 << 12

@Event
def round_start(game_event):
# Loop through all living players...
for edict in PlayerIter('alive', return_types=['edict']):

# Get the player's hidden huds...
hidehud = edict.get_prop_int('m_iHideHud')

# Is the player already have the radar disabled?
if hidehud & HIDEHUD_RADAR:

# If so, no need to go further...
continue

# Hide the player's radar...
edict.set_prop_int('m_iHideHud', hidehud | HIDEHUD_RADAR)


OT question: What is this exactly?

Syntax: Select all

HIDEHUD_RADAR = 1 << 12

# ....

hidehud & HIDEHUD_RADAR
hidehud | HIDEHUD_RADAR
The << and | symbols.

I know in C++ << and >> on variables is bit shifting. How do you call that, and | & etc. in Python? :)

Posted: Thu Jun 04, 2015 12:24 pm
by satoon101

Posted: Thu Jun 04, 2015 12:31 pm
by BackRaw
Thanks a bunch!

Posted: Thu Jun 04, 2015 12:37 pm
by satoon101
I should probably also mention the there is a HideHudFlags enum class in players.constants.