Page 1 of 1

CS:GO Information Panel

Posted: Sun Aug 21, 2016 2:15 am
by decompile
Hey Guys,

I'm currently thinking about an alternative from the keyhint-text from CS:S and I thought about creating a (maybe self refreshing?) simple menu to show the keyhint-text.

I checked the forums already and saw 'register_build_callback' from this thread: viewtopic.php?p=8062#p8062
Sadly I have no clue how to use this properly, since this code gives me actually just the latest menu I opended (just visual, but buttons dont work etc).

I guess the first step would be:

Syntax: Select all

def hudLoop():
Delay(1, hudLoop)
for player in PlayerIter('human'):
sendInformationPanel(player.index)
hudLoop()

def sendInformationPanel(player_index):
player = Player(player_index) #I heard we need to re-create this for a new function, else a crash can happen if the player leaves?
p = SimpleMenu()
p.append("-Player: %s\n\nKills: %s\nDeaths: %s" % (player.name, player.kills, player.deaths))
p.send(player_index)


But ye, that doesnt update it.

Syntax: Select all

def sendInformationPanel(player_index):
player = Player(player_index) #I heard we need to re-create this for a new function, else a crash can happen if the player leaves?
p = SimpleMenu()
p.register_build_callback
p.send(player_index)
def my_build_callback(menu, index):
menu.clear()
menu.append(time.ctime())


This time nothing, what am I doing wrong?

As an addition, we probably need to subclass the SimpleMenu, so player's cant close it. Which means, we need to create a 'native', like CloseMenu & OpenMenu so we can use other menus during our hud loop.

Re: CS:GO Information Panel

Posted: Sun Aug 21, 2016 7:56 am
by Ayuto
decompile wrote:

Syntax: Select all

def hudLoop():
Delay(1, hudLoop)
for player in PlayerIter('human'):
sendInformationPanel(player.index)
hudLoop()

def sendInformationPanel(player_index):
player = Player(player_index) #I heard we need to re-create this for a new function, else a crash can happen if the player leaves?
p = SimpleMenu()
p.append("-Player: %s\n\nKills: %s\nDeaths: %s" % (player.name, player.kills, player.deaths))
p.send(player_index)


But ye, that doesnt update it.

It doesn't update it, because you can't send the menu twice. If it's already visible, the second call to send() is ignored.

decompile wrote:#I heard we need to re-create this for a new function, else a crash can happen if the player leaves?

No, you just should not cache BaseEntity, Entity and Player like storing it in a dict.

decompile wrote:

Syntax: Select all

def sendInformationPanel(player_index):
player = Player(player_index) #I heard we need to re-create this for a new function, else a crash can happen if the player leaves?
p = SimpleMenu()
p.register_build_callback
p.send(player_index)
def my_build_callback(menu, index):
menu.clear()
menu.append(time.ctime())


This time nothing, what am I doing wrong?

Just noticed I was missing the "@" sign in my post. Take a look at that post again. It will make much more sense now.

decompile wrote:As an addition, we probably need to subclass the SimpleMenu, so player's cant close it. Which means, we need to create a 'native', like CloseMenu & OpenMenu so we can use other menus during our hud loop.

Yes, you could simply subclass it and override _slots_to_bin and return 0.