Raised This Month: $ Target: $400
 0% 

MemHack - Switch TeamScore


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Sleepwalker
Member
Join Date: Dec 2006
Old 01-22-2009 , 16:10   MemHack - Switch TeamScore
Reply With Quote #1

Would this code work? I only got one server and wouldn't like to test this code on that one if there is no way of it to work.

This is not all of the code but you would se all code necessary.
Code:
#include <amxmodx>
#include <memhack>

#define TEAMDATA_EBX        0x1E25D8    // unsigned dword (Value of EBX register at CHalflifeMultiplay::Think)
#define POINTER_TEAMDATA    0x3519A8    // unsigned dword (Pointer to team data?)
#define PLAYERCOUNT_T        0x5C        // signed byte
#define PLAYERCOUNT_CT        0x60        // signed byte
#define SCORE_T            0x82        // signed word
#define SCORE_CT        0x80        // signed word

#define MEMTYPE_CODE        0            // Code (usually .text segment, requires mprotect or VirtualProtect)
#define MEMTYPE_DATA        1            // Data (usually .data segment, writable by default)
#define MEMTYPE_RODATA        2            // Read-Only Data (usually .rodata on Linux, .rdata on Windows)

//=====================================================================================================
//== Check Teams
//=====================================================================================================
public check_team(team) {
    sTeam = team;
    if (sTeam = CS_TEAM_T || sTeam = CS_TEAM_CT) {
        return 1;
    }
}

//=====================================================================================================
//== Get Team Score
//=====================================================================================================
public get_team_score(team) {
    sTeam = team;
    // Validate team
    check_team(sTeam);

    // Get starting address of team data
    offset        = memhack_get_realaddr(TEAMDATA_EBX + POINTER_TEAMDATA, MEMTYPE_CODE);
    eax        = memhack_get_pointer(offset, MEM_DLLBASE, MEMTYPE_DATA);
    addrTeamData    = memhack_get_pointer(eax, MEM_DLLBASE, MEMTYPE_DATA);

    new score = 0;

    // Get score for specified team
    switch (sTeam) {
        case CS_TEAM_T:
            score = memhack_get_short(addrTeamData + SCORE_T);
            break;
        case CS_TEAM_CT:
            score = memhack_get_short(addrTeamData + SCORE_CT);
            break;
    }

    return score;
}

//=====================================================================================================
//== Set Team Score
//=====================================================================================================
public set_team_score(team, score) {
    sTeam    = team;
    sScore    = score;

    // Validate team
    check_team(sTeam);

    // Get starting address of team data
    offset        = memhack_get_realaddr(TEAMDATA_EBX + POINTER_TEAMDATA, MEMTYPE_CODE);
    eax        = memhack_get_pointer(offset, MEM_DLLBASE, MEMTYPE_DATA);
    addrTeamData    = memhack_get_pointer(eax, MEM_DLLBASE, MEMTYPE_DATA);

    // Set score for specified team and update scoreboard
    switch (sTeam) {
        case CS_TEAM_T:
            memhack_set_short(addrTeamData + SCORE_T, MEM_DLLBASE, sScore);

            message_begin(MSG_ALL, get_user_msgid("TeamScore"));
            write_string ("TERRORIST");
            write_short(sScore);
            message_end();

            break;
        case CS_TEAM_CT:
            memhack_set_short(addrTeamData + SCORE_T, MEM_DLLBASE, sScore);

            message_begin(MSG_ALL, get_user_msgid("TeamScore"));
            write_string ("CT");
            write_short(sScore);
            message_end();
            break;
    }
}
My first guess is that I need to convert all the hex to int.
Sleepwalker is offline
 



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 01:52.


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