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

setting/getting cash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ahrex
Junior Member
Join Date: Dec 2005
Location: Perth, Australia
Old 12-31-2005 , 08:33   setting/getting cash
Reply With Quote #1

Hey all,

I'm trying to write a basic SourceMM CS:S plugin to set a player's cash to 0 if they switch to spectator and back to get more money. It's just the setting cash part left at this stage.

How is this best done? I've read through BAILOPAN's "finding functions" devlog tutorials, but I'm not sure if this is actually how I should do it, or if I'm looking in the wrong place.

I saw a thread regarding money offsets. I assume that's for just editing the relevant memory location directly? If so, is the offset from each player's edict_t*?

I also have included cbase.h just to see if I could; I doubt this will help though, since cash is a CS:S specific property, right?

Any help will be greatly appreciated.
Ahrex is offline
Ahrex
Junior Member
Join Date: Dec 2005
Location: Perth, Australia
Old 12-31-2005 , 09:15  
Reply With Quote #2

Ok, after a bit more looking around I've got:

Code:
edict_t *pEntity = m_Engine->PEntityOfEntIndex(index);
int *pCash = (reinterpret_cast<int*>(pEntity->GetUnknown()) + 907);
*pCash = 0;
Looking forward to testing tomorrow...
Ahrex is offline
Ahrex
Junior Member
Join Date: Dec 2005
Location: Perth, Australia
Old 01-03-2006 , 02:51  
Reply With Quote #3

Ok, I got a setcash function working fine.

However, there's a problem. It appears the correct player_team event is fired when the user chooses a team, but the player is only given the amount of money specified in mp_startmoney when he or she selects a model. Which would be fine except that no event seems to be fired when a model is selected.

I'll have to just do -800 cash on round_start.
Ahrex is offline
showdax
Senior Member
Join Date: Dec 2004
Old 01-03-2006 , 05:11  
Reply With Quote #4

You could use ClientCommand() and listen for "joinclass":
Code:
void Whatever::ClientCommand(edict_t *entity)
{
	if (!entity || m_Engine->Cmd_Argc() < 1)
		RETURN_META(MRES_HANDLED);

	index = g_Engine->IndexOfEdict(g_ClientEntity);
	if (index < 1 || index > g_Globals->maxClients
	    || Q_strcmp(m_Engine->Cmd_Argv(0), "joinclass") != 0)
		RETURN_META(MRES_IGNORED);

	/* do whatever */

	RETURN_META(MRES_HANDLED);
}
showdax is offline
Send a message via MSN to showdax
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 18:16.


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