AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   CS_OnBuyAttempt (https://forums.alliedmods.net/showthread.php?t=279010)

^SmileY 02-13-2016 10:21

CS_OnBuyAttempt
 
Hi i am again here :D

A player have reported to me that function is broken:

PHP Code:

public CS_OnBuyAttempt(id,iItem)
{
    if((
iItem == CSI_DEFUSER) && !cs_get_user_defuse(id))
    {
        new 
iMoney cs_get_user_money(id);
        
        if(
iMoney >= 200)
        {
            
cs_set_user_money(id,iMoney 200);
        }
    }


This is a small fix to discount money if player will buy a defuse, but the problem is for Team TR side.
The money will be deduced if TR not have defuse, and i know that i can add a team check to fix that.

But the real problem is that player have defuser command in autobuy.txt, and CS is trying to buy a defuse even if he is TR.

Ps. It is possible to add a team in function header, soo i not need to retreive cs_get_user_team?

Thanks for read, and sorry if is not a valid issue here.

:bee:

xPaw 02-13-2016 12:49

Re: CS_OnBuyAttempt
 
Have you tried using CS_OnBuy instead?

Arkshine 02-13-2016 12:56

Re: CS_OnBuyAttempt
 
Can you try to rephraze your issue? I really don't get.

Remember this:

- CS_OnBuyAttempt: called when player issue a command (basically that would be the same as using ClientCommand). So, it's called before anything else, before any game checks to see if you can actually buy the item and such.

- CS_OnBuy: called when player is about to get the item. Game checks are done, and you can sure to receive what you bought. Money is not yet taken.


So, what are you trying to do, what is the actual issue with those two forwards?

Cryptix 02-13-2016 14:25

Re: CS_OnBuyAttempt
 
He's trying to reduce $200 for those who purchase defuse-kit (CTs Only). As he states, for some reason T-Side can simulate a defuse-kit purchase through "autobuy". So it would just keep reducing $200 each time a T-side player autobuys.

Arkshine 02-13-2016 15:05

Re: CS_OnBuyAttempt
 
I don't see how it can happen. Server-side, there is a team check, whatever you're using old-menu with or alias "defuser".

I've tried myself, putting autobuy.txt in my Steam\steamapps\common\Half-Life\czero ; then typing "autobuy" in the console, result: I can buy it when I'm CT, I can't when I'm T (and money is not taken)

Did I miss something?

Netsys 02-13-2016 18:06

Re: CS_OnBuyAttempt
 
Smiley you must use CS_OnBuy instead of CS_OnBuyAttempt

^SmileY 02-13-2016 19:56

Re: CS_OnBuyAttempt
 
Quote:

Originally Posted by Netsys (Post 2392670)
Smiley you must use CS_OnBuy instead of CS_OnBuyAttempt

Same result bro, the problem is try to buy a item that can used only by CT team like defuser.
I am simple checking if user has defuse or not, but if he is tr i need to add a check to team until here ok.

But in CstrikeHacks.cpp

Code:

if (HasInternalCommandForward && *UseBotArgs && MF_ExecuteForward(ForwardInternalCommand, client, *BotArgs) > 0)
  {
    return;
  }

  if (HasOnBuyAttemptForward && CurrentItemId && MF_ExecuteForward(ForwardOnBuyAttempt, client, CurrentItemId) > 0)
  {
    return;
  }

Someone can try to pass TeamId to forward? that will be welcome in this cases not?
@Arkshine the real problem is case if you will deduce money from player, or cs_get_user_defuse function need to always return FALSE in case of teamTR player.

Sorry again if i cannot explain better.

Arkshine 02-14-2016 04:25

Re: CS_OnBuyAttempt
 
Quote:

Originally Posted by Arkshine (Post 2392628)
I've tried myself, putting autobuy.txt in my Steam\steamapps\common\Half-Life\czero ; then typing "autobuy" in the console, result: I can buy it when I'm CT, I can't when I'm T (and money is not taken)

Could you tell me how to reproduce the issue? because I can't.

Or are you trying to give free defuser or something? if so, then use CS_OnBuy, forward will not be called if you are T and you try to buy defuser.

^SmileY 02-14-2016 06:20

Re: CS_OnBuyAttempt
 
I will test it again, but basically is using autobuy.txt

^SmileY 02-18-2016 13:33

Re: CS_OnBuyAttempt
 
here is a fix for my problem, a guy that tested this have not used lest amxx dev versions.

https://github.com/alliedmodders/amx...c81c2b658d7905

Ps. Thanks for help


All times are GMT -4. The time now is 21:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.