Raised This Month: $32 Target: $400
 8% 

Custom money amount?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GasmoN
Member
Join Date: Jul 2014
Old 08-01-2018 , 10:48   Custom money amount?
Reply With Quote #1

This plugin allow you to set custom money reward when you kill enemy, the problem is that it doesn't block default money reward on new round. I want to block default money reward on new round so the players will have only the amount they earned in previously round.

I tried with few other plugins but I just can't figure out this.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define VERSION "0.1.1"

enum
{    
    
DeathMsg_KillerID 1// byte
    
DeathMsg_VictimID// byte
    
DeathMsg_IsHeadshot// byte
    
DeathMsg_TruncatedWeaponName // string
}

#define Money_Amount 1

new g_iMaxPlayers
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

#define XTRA_OFS_PLAYER 5
#define m_iAccount 115
#define cs_set_money_value(%1,%2)    set_pdata_int(%1, m_iAccount, %2, XTRA_OFS_PLAYER)

new g_pCvarKillMoneyg_pCvarTkMoneyg_pCvarMaxMoneyg_pCvarKillMoneyHs

new g_iNewMoney
new g_iMsgHookMoney
new gmsgMoney

public plugin_init()
{
    
register_plugin("Kill Money"VERSION"ConnorMcLeod")

    
g_pCvarKillMoney register_cvar("amx_kill_money""300")
    
g_pCvarKillMoneyHs register_cvar("amx_kill_money_hs""1337")
    
g_pCvarTkMoney register_cvar("amx_teamkill_money""-1337")
    
g_pCvarMaxMoney register_cvar("amx_killmoney_maxmoney""16000")

    
register_event("DeathMsg""Event_DeathMsg""a")

    
g_iMaxPlayers get_maxplayers()
    
gmsgMoney get_user_msgid("Money")
    
}

public 
Event_DeathMsg()
{
    new 
iKiller read_data(DeathMsg_KillerID)
    if( 
IsPlayer(iKiller) && is_user_connected(iKiller) )
    {
        new 
iVictim read_data(DeathMsg_VictimID)
        if( 
iVictim != iKiller )
        {
            
g_iNewMoney clamp
                        

                            
cs_get_user_money(iKiller) + get_pcvar_numcs_get_user_team(iVictim) == cs_get_user_team(iKiller) ? g_pCvarTkMoney : (read_data(DeathMsg_IsHeadshot) ? g_pCvarKillMoneyHs g_pCvarKillMoney) ), 
                            
0
                            
get_pcvar_num(g_pCvarMaxMoney)
                        )
            
g_iMsgHookMoney register_message(gmsgMoney"Message_Money")
        }
    }
}

public 
Message_Money(iMsgIdiMsgDestid)
{
    
unregister_message(gmsgMoneyg_iMsgHookMoney)
    
cs_set_money_value(idg_iNewMoney)
    
set_msg_arg_int(Money_AmountARG_LONGg_iNewMoney)

GasmoN is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-01-2018 , 16:23   Re: Custom money amount?
Reply With Quote #2

You need to hook message money itself and check their parameters, better than use a death message..

Edit

Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("Test","0.2","SmileY");

	register_message(get_user_msgid("Money"),"MsgMoney");
}

public MsgMoney(Msg,Dest,id)
{
	switch(get_msg_arg_int(1)) // I'm not have sure how we can hook money changes, this is a test
	{
		case 300:
		{
			set_msg_arg_int(1,ARG_LONG,600); // Set 600 instead of 300
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_CONTINUE;
}
Not tested yet
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 08-01-2018 at 16:36.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 20:16.


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