Just try it, don't question how it works amd what I did there. If it works I'll explain it to you.
Lol, don't act like that. You should explain what you did in the first place. When people understand what they are using and doing, there are less chances of error.
@Craxor, ham allows you to hook virtual functions from a table. View this table as an array, which has an unique entry for each of it's functions. You can adress this entry by it's index, which starts from the base of the class and it's incremented by one with every function.
As an example, here's the virtual table for player class(CBasePlayer):
Here, you can see that the index of OnTouchingWeapon is 87. What Klippy did is basically to find another ham function that has the index of 87. That is not necessary, you could simply do that:
PHP Code:
new Ham:Ham_CS_Player_OnTouchingWeapon = 87
He picked up the function CBasePlayerWeapon:: PrimaryAttack(), which is a member of CBasePlayerWeapon class. You see, both have same index, but from different classes.
I hope you get that. Anyway, I doubt it will work. Why you don't simply hook touch as per usual?
this should allow you to use it in lower versions than 1.8.3. Just try it, don't question how it works amd what I did there. If it works I'll explain it to you.
It won't work, because Ham requires the same argcount on Windows. (but I'm not sure about Linux)
Lol, don't act like that. You should explain what you did in the first place. When people understand what they are using and doing, there are less chances of error.
Yes, correct, but it didn't seem like he tried what I proposed and started finding reasons why it wouldn't work (even though what he said wasn't the reason).
Quote:
Originally Posted by HamletEagle
That is not necessary, you could simply do that:
PHP Code:
new Ham:Ham_CS_Player_OnTouchingWeapon = 87
Ham_Weapon_PrimaryAttack's value isn't 87, it depends on hamdata.ini. You can't hook a function by its vtable index, so you have to find another function which has the same index (but for another class obviously) on the game you are running. I don't like that with Ham though, a new module (or new API for ham) that gets rid of some many hardcoded stuff would be really welcome.
Quote:
Originally Posted by PRoSToTeM@
It won't work, because Ham requires the same argcount on Windows. (but I'm not sure about Linux)
In every post I wrote "try" because I wasn't sure either if it would work. Arkshine already pointed the argcount problem to me. Thanks for mentioning here though.
Ham_Weapon_PrimaryAttack's value isn't 87, it depends on hamdata.ini. You can't hook a function by its vtable index, so you have to find another function which has the same index (but for another class obviously) on the game you are running. I don't like that with Ham though, a new module (or new API for ham) that gets rid of some many hardcoded stuff would be really welcome.
Forgot that ham is not working in orpheu style, my bad.
I'm already use register_touch' my original question was about Ham_CS_Player_OnTouchingWeapon if is integreted in 1.8.3 or i'm doing something wrong with my code, wich arkshine give me the answer, anyway about how ham it's working i will try to read more times the hamlet answer, seems very useful
Sorry i'm still beginner but just by curiosity, where i can find a list with all classes like CBasePlayer ?
holyshit i never know about that link with hlsdk :O , thanks klippty
Keep in mind that hlsdk has generic code, this means there are no cs specific stuff. Check ReGameDLL project on github for cs source code.
You can also get IDA and decompile cs.so/mp.dll, after you get used with it's output it's easy to find what you need.