|
View previous topic :: View next topic |
| Author |
Message |
KinkyMunkey New User
Joined: 26 Aug 2006 Posts: 18
|
Posted: Sat Aug 26, 2006 1:28 am Post subject: How can i use BaseEntity->SetHealth now after last update |
|
|
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 |
|
 |
|
 |
OPCAdmin Experienced
Joined: 04 Jul 2005 Posts: 340
|
Posted: Sat Aug 26, 2006 2:05 am Post subject: |
|
|
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 |
|
 |
CoolPeter New User
Joined: 04 Aug 2005 Posts: 11
|
Posted: Sat Aug 26, 2006 11:37 am Post subject: |
|
|
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 |
|
 |
OPCAdmin Experienced
Joined: 04 Jul 2005 Posts: 340
|
Posted: Sat Aug 26, 2006 12:45 pm Post subject: |
|
|
| Thank you! |
|
| Back to top |
|
 |
KinkyMunkey New User
Joined: 26 Aug 2006 Posts: 18
|
Posted: Sat Aug 26, 2006 5:42 pm Post subject: |
|
|
First Off, THANK YOU, i think you just fixed like 4 mods if this works
(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 |
|
 |
CoolPeter New User
Joined: 04 Aug 2005 Posts: 11
|
Posted: Sat Aug 26, 2006 7:35 pm Post subject: |
|
|
| Mhhhh... try to include windows.h for windows. |
|
| Back to top |
|
 |
KinkyMunkey New User
Joined: 26 Aug 2006 Posts: 18
|
Posted: Sat Aug 26, 2006 8:58 pm Post subject: |
|
|
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 |
|
 |
KinkyMunkey New User
Joined: 26 Aug 2006 Posts: 18
|
Posted: Sun Aug 27, 2006 2:27 am Post subject: |
|
|
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 |
|
 |
KinkyMunkey New User
Joined: 26 Aug 2006 Posts: 18
|
|
| Back to top |
|
 |
CoolPeter New User
Joined: 04 Aug 2005 Posts: 11
|
Posted: Tue Sep 05, 2006 5:57 pm Post subject: |
|
|
No problem
I got this method from Knagg0
He also gave me all cs:s props in a list  |
|
| Back to top |
|
 |
stig New User
Joined: 12 May 2007 Posts: 5
|
Posted: Sat May 12, 2007 12:10 pm Post subject: |
|
|
Link don't work
can someone give me a new one? _________________ ~Stig |
|
| Back to top |
|
 |
|