AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Ham Sandwich (https://forums.alliedmods.net/showthread.php?t=51824)

sawce 02-24-2007 14:55

Module: Ham Sandwich
 
4 Attachment(s)
newest version is in 1.8, if you're reading this before 1.8 is final released, then download it from here

This module allows you to call 2 private functions for entities, with some cross-mod compatibility.

There are just two natives currently; I may add more if I see some that could be useful.

hs_takedamage(idVictim,idInflictor,idAttacker , Float:damage, type);
hs_use(id,idActivator,idCaller, use_type, Float:use_value);

I have comments for the natives in the include file.

The mods supported:
  • cstrike
  • czero
  • dod
  • tfc
  • ns - 3.2 beta 2
  • ts - only tested on the ts_i386 binary (the default one) should work on the i686 one
  • sven

Note: these are all most recent version, and all are from legitimate versions eg: no steam is not and will never be supported, although it probably will still work


Note: czero support is assumed, I have not tested it.

Note: I only tested hs_takedamage, don't have time to test hs_use just yet.

Note: Most windows offsets are untested but should in theory be correct.

Note: Linux takedamages have all been tested.

Note: No 64 bit support. 64 bit can go to hell.

Read the include file for some more in depth explanations.

Attached is "test.sma", the plugin I used to test takedamage. It may help show it's usage, it may not! It's not meant for general servers, just an example.

edit: I should have a fixed release quality linux binary now; I will test more thoroughly when I get home later tonight. I also fixed it calling takedamage on NS.

Fixed sven coop directory too :o

XxAvalanchexX 02-24-2007 15:44

Re: Module: Ham Sandwich
 
hs_takedamage and hs_use are working fine on Windows 32-bit Sven Co-op (the only build of Sven Co-op).

hip_hop_x 02-24-2007 19:22

Re: Module: Ham Sandwich
 
great module, I'm going to use it in some plugins.

Hawk552 02-24-2007 20:02

Re: Module: Ham Sandwich
 
This should seriously be merged into core. It would be very very useful. I believe it should also retain its name.

FormulaZero 02-24-2007 20:12

Re: Module: Ham Sandwich
 
Ham Sandwich, classic. ;)

sawce 02-24-2007 22:16

Re: Module: Ham Sandwich
 
Quote:

Originally Posted by Hawk552 (Post 445053)
This should seriously be merged into core. It would be very very useful. I believe it should also retain its name.

Unfortunately I'm sure bail will say it's too hacky. I'd maintain it, but I'd understand him not wanting it :x

Also fixed the name of the windows binary so it loads w/o needed renamed, my bad D:

edit: he said "we'll see" but i have to make a few changes :(

commonbullet 02-24-2007 23:20

Re: Module: Ham Sandwich
 
this can't be replaced
Code:

#include <hamsandwich>

sawce 02-27-2007 01:06

Re: Module: Ham Sandwich
 
I've gotten the OK for submitting this in the base package (for 1.77), but there's a minor change of the module loading data from a config file, and the natives will be checking bounds then to try to make it a bit more safe (but obviously blatant misuse will be unable to be stopped).

I'm going to add these natives while I'm at it, since they deal with the same sort of thing this module does (even though they may not seem like it):

get_pdata_cbase(id,offset,linuxdiff=5);
set_pdata_cbase(id,offset,newid,linuxdiff=5);

(if I got the syntax wrong they're similar to the Fakemeta equivalents)

What it does is, if an offset in the private data is pointing to another entity's private data, it will return the index of what it's pointing to or set the new data to point to the new entity's private data.

I'm also working on hooking takedamage/use, but it's very, very difficult. No promises if it makes it in.

It's also been suggested I change the name unless I heavily document everything. I hate documenting. :|

Ramono 03-01-2007 05:53

Re: Module: Ham Sandwich
 
Very usefull module.

I realy hope hooking it works :)

sawce 03-02-2007 14:12

Re: Module: Ham Sandwich
 
1 Attachment(s)
I have what I believe to be a stable working version of the hooks (although they're not entirely feature complete just yet).

Would anybody be willing to try to break it for me? With normal usage, not blatant mis-use, that is.

Source is available here

Here's the binaries.

The hamdata.ini needs to go into your amxmodx/configs directory. If the module is unable to get the offsets for your mod from the data file, it will not register the natives.

Here's the example I used to test on CS: here. It makes players who damage hostages hurt themselves instead (blood still shows around hostages, need to add another hook for that). And spams a message whenever you use a hostage.

Tested on (I threw grenades at myself with a player takedamage hook):

CS 1.6, linux and windows
NS 3.2 linux
TS 2.1 linux
TFC ?? linux
DoD 1.2 linux

edit: fixed an access violation on winders


All times are GMT -4. The time now is 14:51.

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