This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Module: Okapi


Post New Thread Reply   
 
Thread Tools Display Modes
razermamba
Member
Join Date: Aug 2010
Old 06-13-2015 , 19:49   Re: Module: Okapi
Reply With Quote #81

Quote:
Originally Posted by Arkshine View Post
I think for method, you don't need to provide the object, so arg_cbase is not needed (it should be added internally).
Then why is it in native prototype?

PHP Code:
/**
 *  Attaches okapi to a method (class member function) so you can hook it and call it
 *  
 * @param ptr                the address of the method
 * @param okapi_arg:ret        the return type of the method
 * @param okapi_arg:arg        the type of the method class
 * @param okapi_arg:...        the rest of the types for the arguments of the function
 *
 * @return                    an handler to the function attached
 *
 */
native okapi_func:okapi_build_method(ptr,okapi_arg:ret,okapi_arg:class,okapi_arg:...) 
razermamba is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2015 , 20:03   Re: Module: Okapi
Reply With Quote #82

Ah, oops. I probably confused with something else.

The posted code doesn't work?

EDIT: Ah SetAnimation. The thing with this function is that because of optimization at compilation, function is split in two, and it's not really possible to hook that with Okapi. You can hook the original function, but this won't be called for all. Well, for this specific function you can probably use this module: https://forums.alliedmods.net/showpo...51&postcount=7
__________________

Last edited by Arkshine; 06-13-2015 at 20:08.
Arkshine is offline
razermamba
Member
Join Date: Aug 2010
Old 06-13-2015 , 20:36   Re: Module: Okapi
Reply With Quote #83

Quote:
Originally Posted by Arkshine View Post
Ah, oops. I probably confused with something else.

The posted code doesn't work?

EDIT: Ah SetAnimation. The thing with this function is that because of optimization at compilation, function is split in two, and it's not really possible to hook that with Okapi. You can hook the original function, but this won't be called for all. Well, for this specific function you can probably use this module: https://forums.alliedmods.net/showpo...51&postcount=7
Posted code works like a charm seems like just for func call does not matter if it is split or not. I need it for SetAnimation for player. I have not seen any problems with that yet. Animations are send to player properly. Just one more question. Is it possible to get the ID of weaponmodel(p_model) of the weapon?

Last edited by razermamba; 06-13-2015 at 20:39.
razermamba is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-14-2015 , 04:56   Re: Module: Okapi
Reply With Quote #84

Yes, the posted code will work, but you won't get the all the original calls. I've explained more here https://forums.alliedmods.net/showpo...72&postcount=2.

About calling the function, yes, doesn't matter, if you use the original function address.
__________________
Arkshine is offline
razermamba
Member
Join Date: Aug 2010
Old 06-14-2015 , 05:38   Re: Module: Okapi
Reply With Quote #85

Quote:
Originally Posted by Arkshine View Post
Yes, the posted code will work, but you won't get the all the original calls. I've explained more here https://forums.alliedmods.net/showpo...72&postcount=2.

About calling the function, yes, doesn't matter, if you use the original function address.
Is it possible to get the ID of weaponmodel(p_model) of the weapon?
razermamba is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 06-15-2015 , 00:27   Re: Module: Okapi
Reply With Quote #86

Quote:
Originally Posted by razermamba View Post
Is it possible to get the ID of weaponmodel(p_model) of the weapon?
Search, it's done by the client. You can't change client's p_ model entvars, you'll need to create another one separately.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
razermamba
Member
Join Date: Aug 2010
Old 06-15-2015 , 17:57   Re: Module: Okapi
Reply With Quote #87

Quote:
Originally Posted by meTaLiCroSS View Post
Search, it's done by the client. You can't change client's p_ model entvars, you'll need to create another one separately.
Do you have any piece of code for that please? I would like to get the muzzleflash origin using GetBonePosition or GetAttachment.
razermamba is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 06-17-2015 , 22:10   Re: Module: Okapi
Reply With Quote #88

Quote:
Originally Posted by razermamba View Post
Do you have any piece of code for that please? I would like to get the muzzleflash origin using GetBonePosition or GetAttachment.
What do you want to do?

______________________

***waiting for Okapi update***
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-30-2015 , 14:32   Re: Module: Okapi
Reply With Quote #89

I'm trying to hook CHostage::RePosition, this function reset the hostage to their previous position, no matter if they are killed/rescued/somewhere in the map. In the plugin I need to use okapi to hook a function that has vector as param, so I can't use orpheu, because using both okapi and orpheu doesn't seem resonable to me.

Quote:
You can hook any function that uses a combination of these types:
We can't hook functions that have as arguments: CHostage *const this ? With orpheu it's easy, just need to pass a valid hostage index when calling the function.

Orpheu code which works:
Code:
{
	"name"    : "RePosition",
	"class"   : "CHostage",
	"library" : "mod",
	"identifiers" : 
	[
		{
			"os"    : "windows",
			"mod"   : "cstrike",
			"value" : [0x83,"*","*",0x56,0x8B,"*",0x57,0x33,"*",0x8B,"*","*",0x57,0x89,"*","*","*" ,0x89,"*","*","*",0x8B]
		},
		{
			"os"    : "linux",
			"mod"   : "cstrike",
			"value" : "_ZN8CHostage10RePositionEv"
		}
	]
}
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <engine>
#include <fakemeta>

public OrpheuFunction:CHostage_RePosition

public plugin_init()
{
    
CHostage_RePosition OrpheuGetFunction("RePosition""CHostage")
    
register_clcmd("test""test")
}

public 
test(id)
{
    new 
HostageEnt = -1
    
while((HostageEnt find_ent_by_class(HostageEnt"hostage_entity")))
    {
        if(
pev_valid(HostageEnt))
        {
            
OrpheuCall(CHostage_RePositionHostageEnt)
        }
    }

Then, when trying to convert it to okapi I fail:
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <okapi>

new okapi_func:CHostage_RePosition

public plugin_precache()
{
    
register_clcmd("test""test")
    
    new const 
CHostageRePositionSignature[] = {0x83,0xDEF,0xDEF,0x56,0x8B,0xDEF,0x57,0x33,0xDEF,0x8B,0xDEF,0xDEF,0x57,0x89,0xDEF,0xDEF,0xDEF ,0x89,0xDEF,0xDEF,0xDEF,0x8B}
    new const 
CHostageRePositionSymbol   [] = "_ZN8CHostage10RePositionEv"

    
new OkapiHandle
    
if
    (
        (
OkapiHandle okapi_mod_get_symbol_ptr(CHostageRePositionSymbol)) || 
        (
OkapiHandle okapi_mod_find_sig(CHostageRePositionSignaturesizeof CHostageRePositionSignature))
    )
    {
        
CHostage_RePosition okapi_build_function(OkapiHandlearg_void)
    }


public 
test(id)
{
    new 
HostageEnt = -1
    
while((HostageEnt find_ent_by_class(HostageEnt"hostage_entity")))
    {
        if(
pev_valid(HostageEnt))
        {
            
okapi_call(CHostage_RePositionHostageEnt)
        }
    }

When using it like this it throw an error like: "expected 1 arg", which seems logical because on okapi_build_function I don't pass any args, but this is fine in orpheu, so I'm confused. The object from function header is refered in pawn as an entity index, right ?

I've also tried to add arg_int after arg_void(the function does not return anything) but this results in a crash. Sorry if I didn't explain well, but I'm pretty nervous right now.
__________________

Last edited by HamletEagle; 07-30-2015 at 14:32.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-31-2015 , 03:46   Re: Module: Okapi
Reply With Quote #90

RePosition is a member of CHostage class, so, you need to build the okapi function using okapi_build_method.
okapi_build_function is essentially for functions without class or static.
__________________

Last edited by Arkshine; 08-01-2015 at 11:38.
Arkshine is offline
Reply



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 13:28.


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