AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   setting/getting cash (https://forums.alliedmods.net/showthread.php?t=39546)

Ahrex 12-31-2005 08:33

setting/getting cash
 
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. :roll:

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 12-31-2005 09:15

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 01-03-2006 02:51

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.

showdax 01-03-2006 05:11

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);
}



All times are GMT -4. The time now is 12:58.

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