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

help with okapi


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-24-2017 , 07:08   Re: help with okapi
Reply With Quote #31

Stop assuming that entities have a predefined index. Index will vary.

Please explain properly what are you trying to do. Giving a weapon like give_item or give a weapon from the ground?
__________________
HamletEagle is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-24-2017 , 07:42   Re: help with okapi
Reply With Quote #32

It doesn't realy matter, i'm trying to make an example using okapi_call() by calling a function to learn, that's all. Can you provide any example ?

Example with TouchItem, as i say in function reference when id touch the entity then the function Respawn() will be called, i want to use okapi_call() to Call ItemTouch for Id, like that Id is realy touching the an item and happen what is suppose to happen when is touching that item.
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Old 06-24-2017, 13:02
HamletEagle
This message has been deleted by HamletEagle.
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-24-2017 , 17:59   Re: help with okapi
Reply With Quote #33

Now should i press View deleted comment¤ so i can fully take revenge
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2017 , 09:26   Re: help with okapi
Reply With Quote #34

I don't have time to explain why it does not work, maybe later. Items are contained in an armoury_entity, so the proper function to call is CArmoury::Touch. Find and play with that function.
ItemTouch does not work as you think.

*I saw your previous post before you deleted it*
__________________

Last edited by HamletEagle; 06-25-2017 at 09:27.
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-26-2017 , 10:30   Re: help with okapi
Reply With Quote #35

Ok, so here we go.

In order to understand why it's crashing you need to understand what the game does and what happens.
As you have already discovered, ItemTouch is not called for weapons, only for items(such as item_assaultsuit).

Items are contained in an armoury_entity, they are not a stand alone entity(what you see on the ground is an armoury_entity, not an item_assaultsuit). When you touch an armoury_entity CArmoury::Touch is called and based on m_iType offset the proper weapon/item is given to player by calling GiveNamedItem. GiveNamedItem creates the item and force touch with the player. That's the moment when ItemTouch is called.

The flow is like that:
CArmoury::Touch -> GiveNamedItem -> DispatchTouch -> ItemTouch.

So 2 touch events happen:
Firstly, a player touch an armoury_entity, then the new item that was created touch the player. ItemTouch handles the second touch and you tried to use it to handle the first touch.

It crashes because you were providing an invalid entity index, because the item was not yet created and you were passing it's index to ItemTouch.

Now, about what you tried to do:
CArmoury::Touch is basically Ham_Touch with an armoury_entity index, so okapi is not really needed for that. If you still want to use okapi(and you should only for learning, not for using in a plugin that you plan to release, always go with ham if you can) then find CArmoury::Touch.
__________________
HamletEagle is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-26-2017 , 20:11   Re: help with okapi
Reply With Quote #36

Edit:Works!!! (map: fy_snow)

PHP Code:
#include <amxmodx> 
#include <okapi> 

new const Symb[] = "?ArmouryTouch@CArmoury@@QAEXPAVCBaseEntity@@@Z" 
new okapi_func:test

public 
plugin_init() 

    new 
Handle okapi_mod_get_symbol_ptrSymb ); 
    
test okapi_build_methodHandlearg_voidarg_cbasearg_cbase ); 

    
register_clcmd"say /test""testp" ); 


public 
testp(id

    
okapi_calltest100id ); 

https://github.com/s1lentq/ReGameDLL...pons.cpp#L2301
__________________
Project: Among Us

Last edited by Craxor; 06-26-2017 at 20:23.
Craxor is offline
Send a message via ICQ to Craxor
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 00:25.


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