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

(Question) What could be the cause of crash? (Kill Money)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-21-2020 , 00:43   (Question) What could be the cause of crash? (Kill Money)
Reply With Quote #1

Hello

I'm in need of help because i have tried several plugins that modifies the money you get after you get a kill.

My goal is simple: i want to earn only $100 when killing someone no matter if it's headshot or not.

The shortest and simpler( i think ) code is from kill money from ConnorMcleod:

HTML Code:
/*	Formatright © 2010, ConnorMcLeod

	Kill Money is free software;
	you can redistribute it and/or modify it under the terms of the
	GNU General Public License as published by the Free Software Foundation.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Kill Money; if not, write to the
	Free Software Foundation, Inc., 59 Temple Place - Suite 330,
	Boston, MA 02111-1307, USA.
*/

#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_pCvarKillMoney, g_pCvarTkMoney, g_pCvarMaxMoney, g_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_num( cs_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(iMsgId, iMsgDest, id)
{
	unregister_message(gmsgMoney, g_iMsgHookMoney)
	cs_set_money_value(id, g_iNewMoney)
	set_msg_arg_int(Money_Amount, ARG_LONG, g_iNewMoney)
}
What inside this code could be the cause of crash? there is nothing in the log report that indicates an error!

Thanks

Last edited by Ark_Procession; 11-21-2020 at 00:45.
Ark_Procession is offline
Old 11-21-2020, 04:53
ho83
This message has been deleted by ho83.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-21-2020 , 07:36   Re: (Question) What could be the cause of crash? (Kill Money)
Reply With Quote #2

Quote:
Originally Posted by ho83 View Post
Hi . You Must Change
PHP Code:
g_pCvarKillMoney register_cvar("amx_kill_money""300")
    
g_pCvarKillMoneyHs register_cvar("amx_kill_money_hs""1337"
To:
PHP Code:
    g_pCvarKillMoney register_cvar("amx_kill_money""100")
    
g_pCvarKillMoneyHs register_cvar("amx_kill_money_hs""100"
First of all, that's not how you change cvars.
Second, that's not something that would cause a crash.
You haven't even read the thread, not to mention its title, and are suggesting dumb ideas.

@Ark_Procession - pretty sure the reason for the crash is using "cs_set_money_value" inside the "Money" event which causes an infinite loop because it's calling the event again and again.
__________________

Last edited by OciXCrom; 11-21-2020 at 07:37.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-21-2020 , 11:34   Re: (Question) What could be the cause of crash? (Kill Money)
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
First of all, that's not how you change cvars.
Second, that's not something that would cause a crash.
You haven't even read the thread, not to mention its title, and are suggesting dumb ideas.

@Ark_Procession - pretty sure the reason for the crash is using "cs_set_money_value" inside the "Money" event which causes an infinite loop because it's calling the event again and again.
Thanks for the swift answer, OciXCrom, would you help me with the coding?
this is no lazy request, i've been looking and trying testing lots of plugins for like a year, but never could make killing players give less money.

I really would like a mod that brings money to a smaller scale, like changing weapons cost, money you earn per round and frags.

But i would settle with have this plugin working!
Ark_Procession is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-21-2020 , 13:45   Re: (Question) What could be the cause of crash? (Kill Money)
Reply With Quote #4

Have you tried it without "cs_set_money_value"? Maybe "set_msg_arg_int" will be enough?

If not, I'm not sure if it can be done properly without Orpheu.
I have a plugin like this made some time ago but it requires ReGameDLL - https://forums.alliedmods.net/showthread.php?t=296847
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-21-2020 , 14:53   Re: (Question) What could be the cause of crash? (Kill Money)
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
Have you tried it without "cs_set_money_value"? Maybe "set_msg_arg_int" will be enough?

If not, I'm not sure if it can be done properly without Orpheu.
I have a plugin like this made some time ago but it requires ReGameDLL - https://forums.alliedmods.net/showthread.php?t=296847
Really interested!! , i downloaded the master from https://github.com/s1lentq/ReGameDLL_CS

but i dont understand how to implement it on my game.
Ark_Procession 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 23:35.


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