CS:S send Buy Menu anytime/anywhere

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

CS:S send Buy Menu anytime/anywhere

Postby BackRaw » Thu Jan 11, 2018 12:27 pm

Hi,

I have a question about the the buy menu in CS:S. I want to simulate the behavior of mp_buy_anywhere for CS:GO. As I see it, those two things contribute to how buying is restricted by time/position in CS:S:
  • mp_buytime
  • "Range" of each of the func_buyzone entities
Is this assumption correct? If so, then I can set mp_buytime to 60 to be able to buy anytime.
Still, the "range" thing is a problem. Is there a way to somehow make it available across the whole map? If I can do this, I see one big problem: each map is different and I would need to know the boundaries of each map and set the buy zone properties accordingly.

There has to be another way. Can one buy zone be made accessible to all teams? This way I wouldn't need to have multiple buy zones.
Can I get rid of the buy zones entirely and just send the buy menu to the player when they press the buy button without sending the client command buy?

Thanks!!
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CS:S send Buy Menu anytime/anywhere

Postby Ayuto » Thu Jan 11, 2018 5:44 pm

I tried two things:
  1. Modify the existing buyzones (make them bigger).
  2. Create new buyzones.
Unfortunately, both didn't work, so here is the hacky solution:

Syntax: Select all

import memory

from entities.hooks import EntityPreHook
from entities.hooks import EntityCondition
from entities.entity import BaseEntity

@EntityPreHook(EntityCondition.is_player, 'post_think')
def pre_post_think(args):
player = memory.make_object(BaseEntity, args[0])
player.set_network_property_bool('m_bInBuyZone', True)
This solution doesn't require func_buyzone entities.

Edit:
I didn't test it, but I'm pretty sure that you can also send buy menus using VGUIMenu.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: CS:S send Buy Menu anytime/anywhere

Postby BackRaw » Sat Jan 13, 2018 7:35 am

Ayuto wrote:I tried two things:
  1. Modify the existing buyzones (make them bigger).
  2. Create new buyzones.
Unfortunately, both didn't work, so here is the hacky solution:

Syntax: Select all

import memory

from entities.hooks import EntityPreHook
from entities.hooks import EntityCondition
from entities.entity import BaseEntity

@EntityPreHook(EntityCondition.is_player, 'post_think')
def pre_post_think(args):
player = memory.make_object(BaseEntity, args[0])
player.set_network_property_bool('m_bInBuyZone', True)
This solution doesn't require func_buyzone entities.

That hook is sweet! I can't get rid of the shopping cart icon on the left, can I?

Ayuto wrote:Edit:
I didn't test it, but I'm pretty sure that you can also send buy menus using VGUIMenu.
This works when "you're in a buyzone", meaning the hook is needed for CS:S anyway:

Syntax: Select all

from messages import VGUIMenu

VGUIMenu('buy').send(player.index)
Maybe I could send another empty VGUIMenu to override the shopping cart icon? :D
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CS:S send Buy Menu anytime/anywhere

Postby Ayuto » Sat Jan 13, 2018 10:25 am

The only way I have found so far is using HideHudFlags.PLAYERDEAD. But that hides a lot more than just the shopping cart icon. :grin:
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: CS:S send Buy Menu anytime/anywhere

Postby BackRaw » Sat Jan 13, 2018 9:10 pm

Haha okay. Maybe I'll leave it for now. :D

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 38 guests