Raised This Month: $32 Target: $400
 8% 

Using CBaseEntity::Create from a server plugin (mini-tut)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 12-12-2004 , 23:04   Using CBaseEntity::Create from a server plugin (mini-tut)
Reply With Quote #1

I also posted this on HL2Coding.com, but originally from this IRC channel. This is for those who missed it.

Well (as we all know), Valve's server plugin interface sucks. Rather than bitch I'm being proactive and trying to make it suck less. I'm putting together a set of mod-independant server plugin interface extensions which give access to server.dll functions and singletons that you really shouldn't have access to. Here is a little preview - how to use CBaseEntity::Create. That function, obviously, creates an entity It isn't, however, exported by server.dll in any way, and hence usually cannot be used by anything but server.dll itself. Fuck that. The function is in memory, so you can call it. Here is how (on a windows hl2dm box, dedicated or server, as of 12/12/04):

Code:
typedef CBaseEntity* (__cdecl* CBaseEntity_CreateFunc)( const char *szName, const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner );
CBaseEntity_CreateFunc CBaseEntity_Create = (CBaseEntity_CreateFunc)0x22227F00;
Yeah - hacked, but works flawlessly. My code auto-derives this address based on a signature scan, but I don't feel like pasting it, and it needs polishing. I'll probably release it soon. As an example of how to use it, try this down in ClientCommand:

Code:
if(FStrEq(pcmd, "wtfhelp")){
	CBaseEntity* e = pEntity->GetUnknown()->GetBaseEntity();
	CBaseEntity_Create("item_healthvial", e->GetAbsOrigin(), e->GetAbsAngles(), NULL);
	return PLUGIN_STOP;
}
That spawns a little health vial on whoever types "wtfhelp" into their console. This is just the beginning guys: I'm working on hooking server messages, total ent control, ent class func overrides, and so, so much more. For the time being, play around with this
vancelorgin is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 12-12-2004 , 23:07  
Reply With Quote #2

Quote:
0x22227F00
*Runs away with tail between legs* Yikes, I did not know the SDK went down to that level.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 12-12-2004 , 23:10  
Reply With Quote #3

Well it gets compiled, so it goes down that low level. You can only do really cool stuff from a server plugin *if* you yourself go down that low, but Valve never intended for us to
vancelorgin is offline
BAILOPAN
Join Date: Jan 2004
Old 12-12-2004 , 23:16  
Reply With Quote #4

Good job lancevorigin.

This should be message to valve - that if you don't provide the interfaces, people will extract them anyway ;]
__________________
egg
BAILOPAN is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 12-13-2004 , 07:20  
Reply With Quote #5

Obviously this isn't the way to go. Valve just has to make something better.
Johnny got his gun is offline
Fruchtzwerg
Member
Join Date: Dec 2004
Old 12-13-2004 , 08:31  
Reply With Quote #6

You cant use the baseentity class in the future if it get changed, Valve warns about this in the hlcoders mailing list. MOD authors can easly change this class, but you will never get new header files for this.
Fruchtzwerg is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 12-13-2004 , 14:52  
Reply With Quote #7

Quote:
Originally Posted by Fruchtzwerg
You cant use the baseentity class in the future if it get changed, Valve warns about this in the hlcoders mailing list. MOD authors can easly change this class, but you will never get new header files for this.
Valve can warn, but we have been doing stuff mod dependent, with offsets and unpredictable messages and such for a long time at AMX / AMXX. It works well if you have someone interested enough to update the offsets

I think we will have to do it the same way here until they give us something better (or we will write our metamod!!111yams 0xBA1L style)
__________________
hello, i am pm
PM is offline
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 12-13-2004 , 15:14  
Reply With Quote #8

Whilst yes, CBaseEntity can change, we can compensate (as he pointed out).

And, Johnny: I hope all of this will be wasted time soon, but it probably will be ages before we see a decent plugin interface, and I want to see and do some dev in the mean time. Again, I hope to be wrong here.

Please note I've done this shit for years and years now. I didn't just start doing this weird shit yesterday
vancelorgin is offline
Eradicator
Junior Member
Join Date: Dec 2004
Location: Canada
Old 12-13-2004 , 15:51  
Reply With Quote #9

I get a use of undefined type error even though I defined the type using your code above o_O
Eradicator is offline
Send a message via MSN to Eradicator
BAILOPAN
Join Date: Jan 2004
Old 12-13-2004 , 16:32  
Reply With Quote #10

don;t use his code unless you know what you are doing
__________________
egg
BAILOPAN is offline
Reply


Thread Tools
Display Modes

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 22:26.


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