SourcePlugins Index SourcePlugins
All Plugins for Valve's Source - Hosted by Mattie
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Board Navigation
Home
Forum
Search

Plugins:
All Plugins
Mattie's Plugins

Web Tools:
VDF Creator

Randomness:
Flash game for CS:S
ThinkGeek PC Mods ThinkGeek Computing

Browse Source Plugins
[View all]
access(1) admin(7) anti-camp(3) anti-cheat(2) chat(2) clan(1) database(1) deathmatch(3) dods(2) international(1) leveling(1) lite(3) management(1) map-management(3) metamod(10) metaplugin(3) mod(3) models(1) perspective(1) players(1) popular(9) punishment(1) respawn(3) rpg(1) scheduling(1) scripting(4) sounds(6) source-code(4) special-effects(1) stats(3) user:McFly(1) war(1) weapons(5) web(1) zombie(1)

Who is Online

In total there are 3 users online :: 0 Registered, 0 Hidden and 3 Guests

Registered Users: None

[ View complete list ]


Most users ever online was 62 on Mon Jun 08, 2009 5:04 am


Search

Advanced Search

How can i use BaseEntity->SetHealth now after last update
  Description:
  Tags: (none)

 
Post new topic   Reply to topic    SourcePlugins Index -> Plugin Coding Questions
View previous topic :: View next topic  
Author Message
KinkyMunkey
New User


Joined: 26 Aug 2006
Posts: 18

PostPosted: Sat Aug 26, 2006 1:28 am    Post subject: How can i use BaseEntity->SetHealth now after last update Reply with quote

Hi, as i'm sure all of you know the last server update broke alot of stuff... I haven't noticed any update to the SDK so i have no idea how to go about fixing this....

(engine->PEntityOfEntIndex(pIndex)->GetUnknown()->GetBaseEntity())->SetHealth(pHealth);

Used to work, Now it crashes the server... Tried referencing it a couple different ways but to no avail...

Can Anybody point me in the right direction?

It seems like source hook won't work on entities since how would you find them... and i assume calling the function directly is out since we don't know what it looks like anymore? (tho i can't see how it changed that much)

I haven't heard anybody saying it's broken in mani-events... how do you do it? (I can't find the source code anywhere, i would LOVE to see it tho)

Thanks in Advance
Back to top
View user's profile Send private message



OPCAdmin
Experienced


Joined: 04 Jul 2005
Posts: 340

PostPosted: Sat Aug 26, 2006 2:05 am    Post subject: Reply with quote

I'm in the same boat - was using the same function. Mattie's latest plugin calls something about player properties... don't know what the underlying code is though. It apparently can set health as well as many other properties.

http://forums.mattie.info/cs/forums/viewtopic.php?p=36416
Back to top
View user's profile Send private message
CoolPeter
New User


Joined: 04 Aug 2005
Posts: 11

PostPosted: Sat Aug 26, 2006 11:37 am    Post subject: Reply with quote

Here is a small example...

Code:
int GetOffset(const char *ClassName, const char *PropName) {

  int i = 0, props = 0, offset = 0;
  ServerClass *sc = g_EmtpyServerPlugin.servergamedll->GetAllServerClasses();

  while(sc) {
    if(FStrEq(sc->GetName(), ClassName)) {

      props = sc->m_pTable->GetNumProps();

      for(i = 0; i < props; i++) {
        if(FStrEq(sc->m_pTable->GetProp(i)->GetName(), PropName)) {
          if((offset = sc->m_pTable->GetProp(i)->GetOffset()) < 0) offset = offset * -1;
          return offset;
        }
      }

      return 0;
    }

    sc = sc->m_pNext;
  }

  return 0;
}
..
..
// GetOffset
iHealthOffset = GetOffset("CBasePlayer", "m_iHealth");
..
// GetBaseEntity
CBaseEntity *pBase = pEntity->GetUnknown()->GetBaseEntity();
..
// GetHealth
iHealth = *(int *)((char *)pBase + iHealthOffset)
..
// SetHealth
*(int *)((char *)pBase + iHealthOffset) = 200;
Back to top
View user's profile Send private message
OPCAdmin
Experienced


Joined: 04 Jul 2005
Posts: 340

PostPosted: Sat Aug 26, 2006 12:45 pm    Post subject: Reply with quote

Thank you!
Back to top
View user's profile Send private message
KinkyMunkey
New User


Joined: 26 Aug 2006
Posts: 18

PostPosted: Sat Aug 26, 2006 5:42 pm    Post subject: Reply with quote

First Off, THANK YOU, i think you just fixed like 4 mods if this works Smile
(and oooooooooooooohhh.. es_dumpserverclasses makes more sense now)

I am having a problem tho...

#include "server_class.h"
#include "dt_send.h"

What else? i'm getting a compile error:
error C2039: 'GetPropA' : is not a member of 'SendTable'

on these two lines

if(FStrEq(sc->m_pTable->GetProp(i)->GetName(), PropName)) {
if((offset = sc->m_pTable->GetProp(i)->GetOffset()) < 0) offset = offset * -1;

Only i can't find "GetPropA" anywhere in the SDK so who's calling it?
Back to top
View user's profile Send private message
CoolPeter
New User


Joined: 04 Aug 2005
Posts: 11

PostPosted: Sat Aug 26, 2006 7:35 pm    Post subject: Reply with quote

Mhhhh... try to include windows.h for windows.
Back to top
View user's profile Send private message
KinkyMunkey
New User


Joined: 26 Aug 2006
Posts: 18

PostPosted: Sat Aug 26, 2006 8:58 pm    Post subject: Reply with quote

You are my Hero-

For the record- you need:

#include "windows.h"
#include "server_class.h"

Make sure they are in that order, it seems to matter.

And will i need something Different for linux?? Right now i have it as:

#ifdef _WIN32
#include "windows.h"
#endif
#include "server_class.h"

I can also confirm that both SetHealth and GetHealth Working Correctly in CSS:RPG mod thanks to this...

How should i credit you in the source code mr CoolPete? Right now i have a name and a link to this thread.

Also, Can i call functions a similar way??

How do i use SetMoveType:
void SetMoveType( MoveType_t val, MoveCollide_t moveCollide = MOVECOLLIDE_DEFAULT );

And SetRenderMode:
SetRenderMode( RenderMode_t nRenderMode );

void CBaseEntity::SetRenderColor( byte r, byte g, byte b, byte a )

Or should i just look up what they change and modify it directly like in the examples you have?
Back to top
View user's profile Send private message
KinkyMunkey
New User


Joined: 26 Aug 2006
Posts: 18

PostPosted: Sun Aug 27, 2006 2:27 am    Post subject: Reply with quote

Alright i got all that working Great

Now i need to figure out how to get a the velocity of the person

Prop: baseclass
Prop: pl
Prop: m_hVehicle
Prop: m_hUseEntity
Prop: m_iHealth
Prop: m_lifeState
Prop: m_flMaxspeed
Prop: m_fFlags
Prop: m_iObserverMode
Prop: m_hObserverTarget
Prop: m_hViewModel
Prop: m_hViewModel
Prop: m_szLastPlaceName
Prop: localdata

It's in the localdata....

called m_vecBaseVelocity
m_vecVelocity[2]

but how do i get to the sub properties?
Back to top
View user's profile Send private message
KinkyMunkey
New User


Joined: 26 Aug 2006
Posts: 18

PostPosted: Sun Aug 27, 2006 7:11 am    Post subject: Reply with quote

Thanks, I got it....

Couldn't have done it without your help coolpete

if somebody needs it they can get the source code at:
http://cssrpg.sourceforge.net/forums/viewtopic.php?t=488

It's in cssrpg_modcompatibility.cpp
Back to top
View user's profile Send private message
CoolPeter
New User


Joined: 04 Aug 2005
Posts: 11

PostPosted: Tue Sep 05, 2006 5:57 pm    Post subject: Reply with quote

No problem Wink
I got this method from Knagg0
He also gave me all cs:s props in a list Smile
Back to top
View user's profile Send private message
stig
New User


Joined: 12 May 2007
Posts: 5

PostPosted: Sat May 12, 2007 12:10 pm    Post subject: Reply with quote

Link don't work Sad
can someone give me a new one?

_________________
~Stig
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SourcePlugins Index -> Plugin Coding Questions All times are GMT - 5 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB.