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

[Sketch] CSO Like Money System Prototype


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 09-21-2022 , 10:38   [Sketch] CSO Like Money System Prototype
Reply With Quote #1

A reapi approach for a money system like in cso which was pretty popular back then.

Code:
#include <amxmodx>
#include <reapi>

#define MONEY_MULHEAD 1.0
#define MONEY_MULLEG 0.75
#define MONEY_MULARM 0.75
#define MONEY_MULSTOMACH 0.6
#define MONEY_MULCHEST 0.65

#define MONEY_KILL 500
#define MONEY_HIT 2

#define MONEY_START 2000

#define MONEY_MULVIC 0.65

public plugin_init()
{
	register_plugin("Money", "-", "-")

	for(new RewardRules:i = RR_CTS_WIN; i < RR_END+RewardRules:1; i++)
		rg_set_account_rules(i, 0)

	RegisterHookChain(RG_CBasePlayer_Killed, "ReHook_Killed", 1)
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "ReHook_TakeDamage_Post", 1)
        RegisterHookChain(RG_CBasePlayer_AddAccount, "ReHook_AddAccount_Pre")
}

public ReHook_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, dmgBits)
{
	if(iVictim == iAttacker)
		return HC_CONTINUE;

	if(get_user_team(iVictim) == get_user_team(iAttacker))
		return HC_CONTINUE;

	if(!is_user_alive(iVictim))
		return HC_CONTINUE;

	if(!(0 < iAttacker < 33) || !(0 < iVictim < 33))
		return HC_CONTINUE;

	new addMoney = floatround(flDamage*MONEY_HIT)

	switch(get_member(iVictim, m_LastHitGroup))
	{
		case HIT_STOMACH: addMoney = floatround(addMoney*MONEY_MULSTOMACH)
		case HIT_CHEST: addMoney = floatround(addMoney*MONEY_MULCHEST)
		case HIT_LEFTLEG, HIT_RIGHTLEG: addMoney = floatround(addMoney*MONEY_MULLEG)
		case HIT_LEFTARM, HIT_RIGHTARM: addMoney = floatround(addMoney*MONEY_MULARM)
		case HIT_HEAD: addMoney = floatround(addMoney*MONEY_MULHEAD)
	}

	rg_add_account(iAttacker, addMoney, AS_ADD)
	rg_add_account(iVictim, floatround(addMoney*MONEY_MULVIC), AS_ADD)

	return HC_CONTINUE;
}

public ReHook_Killed(iId, iAttacker)
{
	rg_add_account(iAttacker, MONEY_KILL, AS_ADD)
}

public ReHook_AddAccount_Pre(id, amount, RewardType:type, bool:bTrackChange)
{
	if(type == RT_NONE)
		return HC_CONTINUE;

	return HC_SUPERCEDE;
}

GetMoney(iId) return get_member(iId, m_iLastAccount)
SetMoney(iId, amount) rg_add_account(iId, amount, AS_SET)
AddMoney(iId, amount) rg_add_account(iId, amount)

Last edited by AnimalMonster; 09-23-2022 at 10:12.
AnimalMonster is offline
McTavish
Senior Member
Join Date: May 2021
Old 01-15-2023 , 15:21   Re: [Sketch] CSO Like Money System Prototype
Reply With Quote #2

Quote:
Originally Posted by AnimalMonster View Post
A reapi approach for a money system like in cso which was pretty popular back then.
Yes, that's correct. The plugin uses the REAPI (ReGameDLL API) to create a money system for the game, similar to the one used in the popular CSO (Counter-Strike Online) mod. The REAPI is a set of functions and macros that extend the capabilities of AMX Mod X and can be used to create custom game modes, manage player rewards, and perform other tasks. The plugin uses the REAPI functions to register hooks, set rules for rewards, and manage player money.
__________________
No Steam = No Support.
McTavish is offline
Reply


Thread Tools
Display Modes

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 11:43.


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