Raised This Month: $51 Target: $400
 12% 

Callfunc Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 02-25-2018 , 15:41   Callfunc Problem
Reply With Quote #1

What's wrong with this code?

Knifes.amxx (works perfectly without any error)
PHP Code:
public SetKnifeiClient )
{
    if( 
is_user_aliveiClient ) && cs_get_user_weaponiClient ) == CSW_KNIFE )
        
set_peviClientpev_viewmodel2g_sModelsg_iKnifeiClient ] ] );

OtherPlugin.amxx (Inside ClCmdSayInvis(iClient))
PHP Code:
new iWeapon cs_get_user_weaponiClient );

if( 
iWeapon == CSW_KNIFE )
{
    new 
iLoaded is_plugin_loaded"CSGO Knifes"false );

    if( 
iLoaded )
    {
        new 
iCallFunc callfunc_begin"SetKnife""Knifes.amxx" );

        if( 
iCallFunc )
        {
            
callfunc_push_intiClient );

            
callfunc_end( );
        }
    }

AMX Plugins
PHP Code:

 
24Invis                 2.7     Unknown           Invis.amxx      debug
 
25CSGO Knifes             2.7        Unknown           Knifes.amxx      debug 
L 02/25/2018 - 17:297: callfunc_push_xxx called without callfunc_begin
L 02/25/2018 - 17:297: [AMXX] Run time error 10 (plugin "Invis.amxx") (native "callfunc_push_int") - debug not enabled!

is_plugin_loaded returns 1 and callfunc_begin also returns 1, but for some reason i keep getting this error

Currently using AMXX 1.8.3 dev5151

Last edited by marcelowzd; 02-25-2018 at 15:49.
marcelowzd is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-25-2018 , 15:44   Re: Callfunc Problem
Reply With Quote #2

You didnt even tried to enable debug have goodluck
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 02-25-2018 , 15:53   Re: Callfunc Problem
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
You didnt even tried to enable debug have goodluck
Instead of helping or saying anything useful you come here to say "Goodluck", ok.
marcelowzd is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-25-2018 , 15:58   Re: Callfunc Problem
Reply With Quote #4

Read what callfunc_begin returns: http://amxmodx.org/api/amxmodx/callfunc_begin
I don't know if that's your issue, but you need to check if it is equal to 1
Code:
if(iCallback == 1)
if(condition) is actually equal to if(condition != 0), so it will match negative numbers too.
__________________
klippy is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 02-25-2018 , 15:59   Re: Callfunc Problem
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
Read what callfunc_begin returns: http://amxmodx.org/api/amxmodx/callfunc_begin
I don't know if that's your issue, but you need to check if it is equal to 1
Code:
if(iCallback == 1)
if(condition) is actually equal to if(condition != 0), so it will match negative numbers too.
I didn't know that tbh, I'll try and update this with the result

UPDATE
Just doing this solved the problem entirely, thank you
if( iCallFunc == 1 )

Last edited by marcelowzd; 02-25-2018 at 16:14.
marcelowzd is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-26-2018 , 18:02   Re: Callfunc Problem
Reply With Quote #6

-1 means plugin not found, -2 means function not found.
If these return values was the problem then you obviously have a deeper issue and the code shouldn't work at all.
__________________
Black Rose is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 02-26-2018 , 19:45   Re: Callfunc Problem
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
-1 means plugin not found, -2 means function not found.
If these return values was the problem then you obviously have a deeper issue and the code shouldn't work at all.
Actually i'm using callfunc in many plugins already and all of them are calling each other correctly now just by changing the if statement. I don't know why but just doing that solved everything.

And just to let people know before someone asks: I'm using callfunc instead of natives because the intention is to make them work even if plugin x is not loaded or not working as expected (I tried it with natives first but if x plugin is not running then plugin y will also not work)
marcelowzd is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-27-2018 , 05:29   Re: Callfunc Problem
Reply With Quote #8

Quote:
Originally Posted by marcelowzd View Post
And just to let people know before someone asks: I'm using callfunc instead of natives because the intention is to make them work even if plugin x is not loaded or not working as expected (I tried it with natives first but if x plugin is not running then plugin y will also not work)
Native and module filters exist because of that. It's not the most intuitive thing but it works.

http://amxmodx.org/api/amxmodx/set_native_filter
http://amxmodx.org/api/amxmodx/set_module_filter
__________________
klippy is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 02-27-2018 , 08:16   Re: Callfunc Problem
Reply With Quote #9

Quote:
Originally Posted by KliPPy View Post
Native and module filters exist because of that. It's not the most intuitive thing but it works.

http://amxmodx.org/api/amxmodx/set_native_filter
http://amxmodx.org/api/amxmodx/set_module_filter
I didn't know about set_native_filter, I'm going to try it for sure, ty.

Last edited by marcelowzd; 02-27-2018 at 08:17.
marcelowzd is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 02-27-2018 , 15:32   Re: Callfunc Problem
Reply With Quote #10

Quote:
Originally Posted by KliPPy View Post
Native and module filters exist because of that. It's not the most intuitive thing but it works.

http://amxmodx.org/api/amxmodx/set_native_filter
http://amxmodx.org/api/amxmodx/set_module_filter
Can you provide a mini-turoial on how to use it?
I don't know why, but for me the description from /api/ is not clear.
Thank you.
__________________
My English is A0
E1_531G 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 11:50.


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