Raised This Month: $51 Target: $400
 12% 

Can somebody fix this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 07-02-2017 , 01:47   Can somebody fix this plugin
Reply With Quote #1

https://forums.alliedmods.net/showpo...1&postcount=53
I'd like to put a price on the shield, I don't believe it's been done before.

THANKS.
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 07-02-2017 , 06:37   Re: Can somebody fix this plugin
Reply With Quote #2

Quote:
Originally Posted by FR0NTLINE View Post
Can somebody fix this plugin
Use descriptive topic names
__________________
Rohanlogs is offline
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 07-02-2017 , 09:29   Re: Can somebody fix this plugin
Reply With Quote #3

Oh I'm so sorry I just joined this site the other day.
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-02-2017 , 09:31   Re: Can somebody fix this plugin
Reply With Quote #4

Quote:
Originally Posted by FR0NTLINE View Post
Oh I'm so sorry I just joined this site the other day.
Lmao. Try hooking AddAccount and altering the ammount param.
__________________

Last edited by HamletEagle; 07-02-2017 at 09:32.
HamletEagle is offline
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 07-02-2017 , 09:48   Re: Can somebody fix this plugin
Reply With Quote #5

Surprise me hamlet and where is your donation link?
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 07-02-2017 , 10:12   Re: Can somebody fix this plugin
Reply With Quote #6

Quote:
Originally Posted by FR0NTLINE View Post
Oh I'm so sorry I just joined this site the other day.
Join Date: Apr 2006... ?
__________________
Ayman Khaled is offline
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 07-02-2017 , 10:25   Re: Can somebody fix this plugin
Reply With Quote #7

Have you ever told a riddle where nobody laughed?
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 07-02-2017 , 10:36   Re: Can somebody fix this plugin
Reply With Quote #8

Quote:
Originally Posted by FR0NTLINE View Post
Oh I'm so sorry I just joined this site the other day.
You're being sarcastic and trying to make a point that you know the rules?
__________________
Rohanlogs is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-02-2017 , 13:28   Re: Can somebody fix this plugin
Reply With Quote #9

Quote:
Originally Posted by Rohanlogs View Post
You're being sarcastic and trying to make a point that you know the rules?
If that is the case, it just makes him look much worse: purposefully ignoring the rules.
__________________
fysiks is online now
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-02-2017 , 13:47   Re: Can somebody fix this plugin
Reply With Quote #10

Quote:
Originally Posted by FR0NTLINE View Post
Surprise me hamlet and where is your donation link?
Try this:
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <fakemeta>

#define PluginName    "Price changer"
#define PluginVersion "0.0.2"
#define PluginAuthor  "HamletEagle"

#define CSW_SHIELD_ORIG 99
#define CSW_GLOCK       2

enum
{
    
CSW_DEFUSER 33,
    
CSW_NVGS,
    
CSW_SHIELD,
    
CSW_PRIMAMMO,
    
CSW_SECAMMO
}

new const 
ExtraItemNames[][] =
{
    
"vest",
    
"vesthelm",
    
"defuser",
    
"nvgs",
    
"shield",
    
"primammo",
    
"secammo"
}

new const 
ItemsFromMenu[] = 
{
    
CSW_VEST
    
CSW_VESTHELM
    
CSW_FLASHBANG
    
CSW_HEGRENADE
    
CSW_SMOKEGRENADE
    
CSW_NVGS
    
CSW_DEFUSER
    
CSW_SHIELD 
}

new const 
AmmoType[] = 
{
    
CSW_PRIMAMMO,
    
CSW_SECAMMO
}

const 
SecondaryWeaponBitsum = (1<<CSW_P228 1<<CSW_ELITE 1<<CSW_FIVESEVEN 1<<CSW_USP 1<<CSW_GLOCK18 1<<CSW_DEAGLE)
const 
m_iId             43
const XoCBasePlayerItem 4
const NoItem            = -1

new HandleCvars[CSW_SECAMMO 1]
new 
ItemToBuy[33] = {NoItem, ...}

public 
plugin_init()
{
    
register_plugin
    
(
        .
plugin_name PluginName,
        .
version     PluginVersion,
        .
author      PluginAuthor
    
)
    
    
OrpheuRegisterHook(OrpheuGetFunction("CanBuyThis"), "OnCanBuyThis"OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("BuyItem"   ), "OnBuyItem"   OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("BuyGunAmmo"), "OnBuyGunAmmo"OrpheuHookPre)
    
    
OrpheuRegisterHook(OrpheuGetFunction("AddAccount"  "CBasePlayer"), "CBasePlayer_AddAccount"OrpheuHookPre)
    
    new 
WeaponName[32], CvarName[64]
    for(new 
CSW_P228<= CSW_SECAMMOi++)
    {
        if(
== CSW_GLOCK)
        {
            continue
        }
        
        
get_weaponname_ex(iWeaponNamecharsmax(WeaponName))
        
        
formatex(CvarNamecharsmax(CvarName), "%s_price"WeaponName)
        
HandleCvars[i] = register_cvar(CvarName"-1")
    }
}

public 
OrpheuHookReturn:OnCanBuyThis(const id, const WeaponId

    if(
is_user_alive(id))
    {
        
ItemToBuy[id] = WeaponId
    
}


public 
OrpheuHookReturn:OnBuyItem(const id, const Slot

    if(
is_user_alive(id))
    {
        
ItemToBuy[id] = ItemsFromMenu[Slot 1]
        
        new 
name[32]
        
get_weaponname_ex(ItemToBuy[id], namecharsmax(name))
    }


public 
OrpheuHookReturn:OnBuyGunAmmo(const id, const entity, const bool:blinkMoney

    if(
is_user_alive(id))
    {
        if(
pev_valid(entity))
        {
            new 
weaponId get_pdata_int(entitym_iIdXoCBasePlayerItem)

            if((
<< weaponId) & SecondaryWeaponBitsum)
            {
                
ItemToBuy[id] = AmmoType[1]
            }
            else 
            {
                
ItemToBuy[id]= AmmoType[0]
            }
        }
    }


public 
CBasePlayer_AddAccount(const id, const Ammount, const bool:TrackChange)
{
    if(
ItemToBuy[id] != NoItem)
    {
        
//In game CSW_SHIELD has index 99, the best solution is to check and adjust it instead of sizing the array by 99.
        
if(ItemToBuy[id] == CSW_SHIELD_ORIG)
        {
            
ItemToBuy[id] = CSW_SHIELD
        
}
        
        new 
CvarValue get_pcvar_num(HandleCvars[ItemToBuy[id]])
        if(
CvarValue != -1)
        {
            
OrpheuSetParam(2, (-1) * CvarValue)
            
ItemToBuy[id] = NoItem
        
}
    }
}

get_weaponname_ex(const WeaponIndexWeaponName[], const Size)
{
    if(
CSW_P228 <= WeaponIndex <= CSW_P90)
    {
        
get_weaponname(WeaponIndexWeaponNameSize)
        
replace(WeaponNameSize"weapon_""")
    }
    else 
    {
        
copy(WeaponNameSizeExtraItemNames[WeaponIndex CSW_VEST])
    }

And the needed signatures:
Spoiler

First 3 must be put directly in "functions", the last one must be inside orpheu/functions/CBasePlayer.

Set the new prices by cvars. The patter it's weaponname_price. weaponname is without weapon_.
For the less common stuff use this names:
Code:
"vest",
"vesthelm",
"defuser",
"nvgs",
"shield",
"primammo",
"secammo"
For example: p228_price or primammo_price.

A full list of cvars:
Code:
p228_price
scout_price
hegrenade_price
xm1014_price
c4_price
mac10_price
aug_price
smokegrenade_price
elite_price
fiveseven_price
ump45_price
sg550_price
galil_price
famas_price
usp_price
glock18_price
awp_price
mp5navy_price
m249_price
m3_price
m4a1_price
tmp_price
g3sg1_price
flashbang_price
deagle_price
sg552_price
ak47_price
knife_price
p90_price
vest_price
vesthelm_price
defuser_price
nvgs_price
shield_price
primammo_price
secammo_price
Cvars are by default -1, which means: use default value. So when you want an item to use it's default price, simply set the cvar to -1.

I did not test much, it's up to you to make sure it works in all cases.

About the donation, I never asked for money for plugins. It does not feel right, so I don't do it.
__________________

Last edited by HamletEagle; 07-04-2017 at 08:51. Reason: Fixed a bug with shield.
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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