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

Module: Ham Sandwich


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 03-02-2007 , 15:53   Re: Module: Ham Sandwich
#11

Owwww NICE

btw, newest tfc version is 1.5

Edit:
I'm testing it on tfc, but i cant get it to work, can anyone tell me whats wrong with this:
Code:
#include <amxmodx> #include <engine> #include <hamsandwich> new cvar public plugin_init() {     register_plugin("HS-TEST","1.00","NL)Ramon(NL")     register_use("func_button","func")     cvar = register_cvar("hs_return","1")     //  HAM_UNSET = 0,     //  HAM_IGNORED,     //  HAM_HANDLED,     //  HAM_OVERRIDE,     //  HAM_SUPERCEDE } public func(IDUsed, IDActivator, IDCaller, UseType, Float:UseValue) {     new name2[32],name[32],classname[32],classname2[32],classname3[32]     get_user_name(IDActivator,name,31)     get_user_name(IDCaller,name2,31)     entity_get_string(IDUsed,EV_SZ_classname,classname,31)     entity_get_string(IDActivator,EV_SZ_classname,classname2,31)     entity_get_string(IDCaller,EV_SZ_classname,classname3,31)     server_print("NAME=%s NAME2=%s CLASSNAME=%s",name,name2,classname)     server_print("CLASSNAME2=%s CLASSNAME3=%s",classname2,classname3)     server_print("IDUSED=%d IDACTIVATOR=%d IDCALLER=%d",IDUsed,IDActivator,IDCaller)     server_print("USETYPE=%d USEVALUE=%f",UseType,UseValue)     return get_pcvar_num(cvar) }

When i press a button, it doesnt show anything... Module running, Plugin running, Modname TFC

Edit: it does work with the newest/above version of HS.
__________________
Um, hi.

Last edited by Ramono; 03-10-2007 at 10:15.
Ramono is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-02-2007 , 17:14   Re: Module: Ham Sandwich
#12

register_takedamage and register_use work in Windows 32-bit Sven Co-op (the only build of Sven Co-op, as I'm sure you're aware of by now).

I managed to hook use on a monster_barney, and in the hook call a takedamage on the barney from the player with 0.0 damage. So players that attempted to get him to follow them would actually get shot at by him. :)

Anyway, I don't know if it would fit into your design at all, but if there was any way of implementing wildcards like in register_touch (ie: "monster_*"), it would be very nice.

Awesome work so far, sawcey.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 03-02-2007 at 18:24.
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-02-2007 , 21:37   Re: Module: Ham Sandwich
#13

Quote:
Originally Posted by Ramono View Post
Owwww NICE

btw, newest tfc version is 1.5

Edit:
I'm testing it on tfc, but i cant get it to work, can anyone tell me whats wrong with this:
Code:
#include <amxmodx> #include <engine> #include <hamsandwich> new cvar public plugin_init() {     register_plugin("HS-TEST","1.00","NL)Ramon(NL")     register_use("func_button","func")     cvar = register_cvar("hs_return","1")     //  HAM_UNSET = 0,     //  HAM_IGNORED,     //  HAM_HANDLED,     //  HAM_OVERRIDE,     //  HAM_SUPERCEDE } public func(IDUsed, IDActivator, IDCaller, UseType, Float:UseValue) {     new name2[32],name[32],classname[32],classname2[32],classname3[32]     get_user_name(IDActivator,name,31)     get_user_name(IDCaller,name2,31)     entity_get_string(IDUsed,EV_SZ_classname,classname,31)     entity_get_string(IDActivator,EV_SZ_classname,classname2,31)     entity_get_string(IDCaller,EV_SZ_classname,classname3,31)     server_print("NAME=%s NAME2=%s CLASSNAME=%s",name,name2,classname)     server_print("CLASSNAME2=%s CLASSNAME3=%s",classname2,classname3)     server_print("IDUSED=%d IDACTIVATOR=%d IDCALLER=%d",IDUsed,IDActivator,IDCaller)     server_print("USETYPE=%d USEVALUE=%f",UseType,UseValue)     return get_pcvar_num(cvar) }

When i press a button, it doesnt show anything... Module running, Plugin running, Modname TFC
Make sure it's a valid entity name.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-02-2007 , 21:38   Re: Module: Ham Sandwich
#14

Quote:
Originally Posted by XxAvalanchexX View Post
Anyway, I don't know if it would fit into your design at all, but if there was any way of implementing wildcards like in register_touch (ie: "monster_*"), it would be very nice.
It would not be possible to do it like that.

It doesn't do string comparisons on all takedamages/uses that get called. Rather it spawns an entity of the matching type, and inserts the hook into that entity type's virtual table, and then destroys the entity. This way there is very little overhead for a hook. If you're not too familiar with the inner workings of C++ don't worry about what I just said :o


@romano i'll look into it. I only really tested takedamage :x

I can't reproduce :O

On hunted, hitting the button the hunted starts at:

Quote:
NAME=sawce NAME2=sawce CLASSNAME=func_button
CLASSNAME2=player CLASSNAME3=player
IDUSED=36 IDACTIVATOR=1 IDCALLER=1
USETYPE=2 USEVALUE=1.000000


hs_return
"hs_return" is "1"
hs_return 4
NAME=sawce NAME2=sawce CLASSNAME=func_button
CLASSNAME2=player CLASSNAME3=player
IDUSED=36 IDACTIVATOR=1 IDCALLER=1
USETYPE=2 USEVALUE=1.000000
After changing it to 4 it would not allow the hunted to leave.

... oh you might be on windows, lemme check that


On windows: Some stupid bug caused an access violation (I fixed that, will reupload in a sec), but after fixing that it worked fine O_o what OS do you use?

Last edited by sawce the snail; 03-02-2007 at 23:42.
sawce is offline
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 03-03-2007 , 08:50   Re: Module: Ham Sandwich
#15

I used Windows XP prof, standalone HLDS. ill retry it when i get back home.

Edit: It works all fine now with the new update Thanks, and GJ

btw, this would be very nice if it can be a part of an amxx module, and not a custom one.
__________________
Um, hi.

Last edited by Ramono; 03-03-2007 at 13:23.
Ramono is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-04-2007 , 01:04   Re: Module: Ham Sandwich
#16

The current plan is to add it to the 1.77 base package, but it will remain it's own module. So everybody who installs 1.77 will have it.
sawce is offline
sprintboy
BANNED
Join Date: Mar 2007
Old 03-04-2007 , 08:16   Re: Module: Ham Sandwich
#17

thank you sawce, so this can be used for tfc?
sprintboy is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-04-2007 , 12:13   Re: Module: Ham Sandwich
#18

I have support for NS, CS (and CZero since they're the same binary), DoD, TFC, TS, SvenCoop and ESF for these two virtual function calls/hooks.
sawce is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-07-2007 , 05:19   Re: Module: Ham Sandwich
#19

Indeed a very useful functions. I'm going to request (in AMBugs section) a native get_classname(iIndex, szClassname, iLen) - if used in loop this would help to get all of the classnames that is supported by the mod.

EDIT: http://bugs.alliedmods.net/?do=details&task_id=75

I believe that this should be rather requested for this module because it's seems too hackish.
I know that i could just hardcode all of the classnames but how complicated it would be to retrieve a list of all of the classnames dynamically? Do we need a single pointer to the classnames array or... ?

Last edited by VEN; 03-07-2007 at 13:21.
VEN is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-07-2007 , 13:59   Re: Module: Ham Sandwich
#20

There is no way I know of to get the list of used entities for a game dll without just hardcoding the list myself for each mod.

And since I am trying to make this module pseudo-cross mod, I don't think it would be unreasonable to leave this up to the plugin creator to do the listing of ents they want hooked.
sawce is offline
Old 03-08-2007, 03:36
VEN
This message has been deleted by VEN. Reason: nvm, this will not work for all of the cases...
Closed Thread



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 16:08.


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