AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [CS] Change cost of SGren (https://forums.alliedmods.net/showthread.php?t=253442)

Phant 12-22-2014 07:03

[CS] Change cost of SGren
 
Hello. Noob question, but I can't find solution: how to change cost of default Smoke Grenade (B85, 300$)?
Without fake's buy-menu and other bullshit.

NiHiLaNTh 12-22-2014 10:37

Re: [CS] Change cost of SGren
 
If you don't mind using Oprheu, than you can try looking here. It doesn't support grenades but I think you got the idea.

Phant 12-22-2014 12:03

Re: [CS] Change cost of SGren
 
Oh, would not like to install Orpheu only for that thing :(. Anyway, I can't add grenades to this code (signatures, etc.) :(.
Another ideas?

Jhob94 12-22-2014 12:20

Re: [CS] Change cost of SGren
 
Quote:

Originally Posted by Phant (Post 2238510)
Oh, would not like to install Orpheu only for that thing :(. Anyway, I can't add grenades to this code (signatures, etc.) :(.
Another ideas?

I know one way that doesnt requires orpheu. Orpheu is better, but i know one way without create new menus. Anyway, even not being better than orpheu, it's not bad. Will do it when i am home.

Jhob94 12-22-2014 16:03

Re: [CS] Change cost of SGren
 
Sorry for delay, was searching for messages codes so it will look more realistic :)
(not tested but should work)

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

#define VERSION "0.0.1"

new price 300

public plugin_init() {
    
register_plugin("SmokeGrenade Price Change"VERSION"Jhob94")
    
    
register_clcmd("sgren""Buy_Smoke")
}

public 
Buy_Smoke(id)
{
    new 
cur_money cs_get_user_money(id)
    
    if(
cur_money price)
        
client_print(idprint_center"#Not_Enough_Money")
    
    else
    {
        if(
user_has_weapon(idCSW_SMOKEGRENADE))
            
client_print(idprint_center"#Cannot_Carry_Anymore")
        
        else
        {
            
give_item(id"weapon_smokegrenade")
            
cs_set_user_money(idcur_money price1)
        }
    }
    
    return 
PLUGIN_HANDLED



Phant 12-22-2014 16:17

Re: [CS] Change cost of SGren
 
Jhob94, thank you, but it's does not work when I buy SGren via classic buy-menu :(.
Works only when I buy via "sgren" console command or VGUI buy-menu :(.

Jhob94 12-22-2014 16:19

Re: [CS] Change cost of SGren
 
Quote:

Originally Posted by Phant (Post 2238619)
Jhob94, thank you, but it's does not work when I buy SGren via classic buy-menu :(.
Works only when I buy via "sgren" console command or VGUI buy-menu :(.

I will take look at it

NiHiLaNTh 12-22-2014 16:46

Re: [CS] Change cost of SGren
 
Yes, because buying with classic menu is performed w/o sending 'sgren' command.

Spoiler


Probably best way apart from using modules like Oprheu is to hook "sgren" command + hook client_buy forward or whatever it's name (it has been integrated in amxx 1.8.3). Like this

Spoiler


Jhob94 12-22-2014 17:05

Re: [CS] Change cost of SGren
 
I am not sure if he wants to use a beta version of amxx. Anyway, took some time searching the damn menuid name, but here you go:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

#define VERSION "0.0.1"

new price 300

public plugin_init() {
    
register_plugin("SmokeGrenade Price Change"VERSION"Jhob94")
    
    
register_clcmd("sgren""Buy_Smoke"0// VGUI Menu
    
register_menucmd(register_menuid("BuyItem"),(1<<4),"OS_Smoke"// Old-Style Menu
}

public 
OS_Smoke(idkey)
{
    if(
key == 4)
        
Buy_Smoke(id1)
}

public 
Buy_Smoke(idOS)
{
    new 
cur_money cs_get_user_money(id)
    
    if(
cur_money price)
        
client_print(idprint_center"#Not_Enough_Money")
    
    else
    {
        if(
user_has_weapon(idCSW_SMOKEGRENADE))
            
client_print(idprint_center"#Cannot_Carry_Anymore")
        
        else
        {
            
give_item(id"weapon_smokegrenade")
            
cs_set_user_money(idcur_money price1)
        }
    }
    
    if(
OS)
        
engclient_cmd(id"menuselect" ,"10")
    
    return 
PLUGIN_HANDLED


Edit:
Will add the task for check about buy time. But, i need to know one thing. The buy time starts at same time as freeze time or when freeze time ends? (cant test since haven't cs at this pc)

NiHiLaNTh 12-22-2014 17:32

Re: [CS] Change cost of SGren
 
that function is supported by the older versions of amx mod x too. Its just not integrated. Here it is.


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

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