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

Change Points Awarded


Post New Thread Reply   
 
Thread Tools Display Modes
Ajaxx
Senior Member
Join Date: Oct 2009
Old 10-21-2009 , 22:26   Re: Change Points Awarded
Reply With Quote #21

I'm not using SourceMod I'm trying to write my own plugin for CSS. To use the CBaseEntity class I would have to include baseentity.h. Earlier you recommended against this. Is there a best practice to modify a players score via a CSS plugin without using SourceMod?

I assume sm_sendprop_info_t is from SourceMod.
Ajaxx is offline
pRED*
Join Date: Dec 2006
Old 10-22-2009 , 00:01   Re: Change Points Awarded
Reply With Quote #22

I told you the exact location of the function required for you to use that in your own project...

You don't need the full definition of CBaseEntity if you aren't trying to access members or methods, just

Code:
class CBaseEntity;
will suffice.
pRED* is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 10-22-2009 , 15:32   Re: Change Points Awarded
Reply With Quote #23

Ok so I’m trying to follow your directions the best I can. I copied a couple functions from SourceMod to my plugin. I have “class ServerClass;” at the top of my file, but I’m getting the following error “error C2027: use of undefined type 'ServerClass'”. How should I correctly reference ServerClass?
Ajaxx is offline
pRED*
Join Date: Dec 2006
Old 10-22-2009 , 15:38   Re: Change Points Awarded
Reply With Quote #24

public/server_class.h
pRED* is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 10-22-2009 , 19:07   Re: Change Points Awarded
Reply With Quote #25

I'd like to say thanks for all the help. I'm sure my C++ questions are trivial. I have another one

I have the following in my plugin:

Code:
IServerGameDLL *gamedll = NULL;
And the next line, from my plugin Load function , doesn't seem to work:
Code:
if(!(gamedll = (IServerGameDLL*)interfaceFactory(INTERFACEVERSION_SERVERGAMEDLL, NULL)))
...
Am I initializing gamedll wrong?
Ajaxx is offline
Keeper
Senior Member
Join Date: Nov 2006
Old 10-22-2009 , 20:10   Re: Change Points Awarded
Reply With Quote #26

The INTERFACEVERSION_SERVERGAMEDLL is probably no longer valid. There are several routines you can use to discover which version is valid. I'll look and post a link...

In the SDK it's defined as "ServerGameDLL005".

But with updates, the current interface version is "ServerGameDLL006".

Here's what I used to use ... I'm sure it could be different, but it's derived from the SourceMM files (I take ZERO credit for the following).

used like this:
Code:
if(!(gamedll = (IServerGameDLL*)GetAnyInterface ( gameServerFactory, INTERFACEVERSION_SERVERGAMEDLL)))
Code:
int CPlugin::FormatIface(char iface[], unsigned int maxlength) {
    int length = (int)strlen(iface);
    int i;
    int num = 0;

    for (i=length-1; i>=0; i--) {
        if (!isdigit(iface[i])) {
            if (i != length-1) {
                num = 1;
            }
            break;
        }
    }

    if ( (num && ((int)maxlength <= length)) || (!num && ((int)maxlength <= length+3)) ) 
        return -1;

    if (i != length-1)
        num = atoi(&(iface[++i]));

    num++;

    Q_snprintf(&(iface[i]), 4, "%03d", num);

    return num;
}

void *CPlugin::InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) {
    char _if[257];    /* assume no interface goes beyond this */
    size_t len = strlen(iface);
    int num = 0;
    void *pf = NULL;

    if (max > IFACE_MAXNUM)
        max = IFACE_MAXNUM;

    if (len + 4 > sizeof(_if)) {
        if (ret) 
            *ret = IFACE_FAILED;
        return NULL;
    }

    strcpy(_if, iface);

    do {
        if ( (pf = (fn)(_if, ret)) != NULL ) 
            break;

        if (num > max)
            break;
    } while (( num = FormatIface(_if, len+1) ));

    return pf;
}

void *CPlugin::GetAnyInterface(CreateInterfaceFn fn, const char *iface, int min) {
    char buffer[257];
    int len = static_cast<int>(strlen(iface));
    int ret;

    if (len > static_cast<int>(sizeof(buffer) - 4)) 
        return NULL;

    strcpy(buffer, iface);

    if (min != -1) {
        char *ptr = &buffer[len-1];
        int digits = 0;

        while (isdigit(*ptr) && digits <=3) {
            *ptr = '\0';
            digits++;
            ptr--;
        }

        if (digits != 3) {
            /* for now, assume this is an error */
            strcpy(buffer, iface);
        } else {
            char num[4];
            min = (min == 0) ? 1 : min;
            Q_snprintf(num, sizeof(num), "%03d", min);
            strcat(buffer, num);
        }
    }
    return InterfaceSearch(fn, buffer, IFACE_MAXNUM, &ret);
}

Last edited by Keeper; 10-22-2009 at 20:43.
Keeper is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 10-24-2009 , 22:22   Re: Change Points Awarded
Reply With Quote #27

It seems like with the following code:
Code:
CBaseEntity *pEntity = /* your player entity */
  int* m_iScore = ( int* )(((unsigned char*)pEntity) + offset);
  *m_iScore++;
All I would need to know is the CBaseEntity, which I have, and the offset. The offset for m_iScore is 1108. But it's the offset from "CPlayerResource". The CBaseEntity I get is from my "player" edict_t. So
Code:
CBaseEntity *pEntity = /* your player entity */
  int* m_iScore = ( int* )(((unsigned char*)pEntity) + 1108);
  *m_iScore++;
Does not seem to work. How do I match CPlayerResource to CBaseEntity for my player?

P.S. Thanks Keeper, "ServerGameDLL006" was a winner
Ajaxx is offline
pRED*
Join Date: Dec 2006
Old 10-25-2009 , 00:46   Re: Change Points Awarded
Reply With Quote #28

The SourceMod code for looking up props is recursive so it will find the offset of CPlayerResource (it's contained within the main entity class for players) and add that to the relative offset of m_iScore.
pRED* is offline
Ajaxx
Senior Member
Join Date: Oct 2009
Old 10-25-2009 , 01:04   Re: Change Points Awarded
Reply With Quote #29

How do I retrieve the offset of CPlayerResource from the player entity? Better yet what is it so I can add it to the m_iScore offset of 1108?
Ajaxx is offline
punisher_vip
Junior Member
Join Date: Jan 2012
Old 09-08-2012 , 15:03   Re: Change Points Awarded
Reply With Quote #30

Is there any other way to change team's scores in CS:S? I also tryed to change player's scores and seems it is not working either...
punisher_vip 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 18:12.


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