CS:GO Information Panel

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

CS:GO Information Panel

Postby decompile » Sun Aug 21, 2016 2:15 am

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CS:GO Information Panel

Postby Ayuto » Sun Aug 21, 2016 7:56 am

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 26 guests