AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   callfunc_begin (https://forums.alliedmods.net/showthread.php?t=228549)

CHE4TER 10-22-2013 09:47

callfunc_begin
 
Hi there! I'm triying to call a func from another plugin, but there's an error!
Maybe you can tell me what I'm doing bad?

My code:

PHP Code:

        case 0:
        {
            if( 
is_user_connected(id) && is_user_alive(id) )
                {
                    
client_print(idprint_chat"You must be dead to become invisible spectator!")
                }

                else

                {
                    if( 
callfunc_begin("amx_spectate""invisible_spectator.amxx") == )
                    
client_print(idprint_chat"You are now invisible spectator!")
                    
callfunc_end()
                    
                    
menu_destroy(menu)
                    return 
PLUGIN_HANDLED
                
}
        } 
// case 0 


L 10/22/2013 - 14:41:05: callfunc_end called without callfunc_begin
L 10/22/2013 - 14:41:05: [AMXX] Displaying debug trace (plugin "am.amxx")
L 10/22/2013 - 14:41:05: [AMXX] Run time error 10: native error (native "callfunc_end")
L 10/22/2013 - 14:41:05: [AMXX] [0] am.sma::adminMenu_handler (line 41)

pokemonmaster 10-22-2013 12:35

Re: callfunc_begin
 
You can only do callfunc_end() when there is an successfull function called.

You didn't put { and } to define the code of ( if ( ) ) check, so the compiler will only consider the client_print function as the only function of the if check. Therefore, when the check fails, callfunc_end will throw an error as the function call failed.

So you could do (Also you could check for errors for debugging ...)
Code:
switch(callfunc_begin("amx_spectate", "invisible_spectator.amxx")) {     case 1:     {         client_print(id, print_chat, "You are now invisible spectator!")         callfunc_end()     }         case 0:     {         log_error(AMX_ERR_GENERAL, "Runtime error")     }         case -1:     {         log_error(AMX_ERR_GENERAL, "Plugin not found")     }         case -2:     {         log_error(AMX_ERR_GENERAL, "Function not found")     } }

ConnorMcLeod 10-22-2013 14:31

Re: callfunc_begin
 
amx_spectate is the command, not the public function.

Use this :

PHP Code:

CallSpectateFunction(id)
{
    static 
plugin = -1func = -1pluginType 0;
    if( 
plugin == -)
    {
        
plugin is_plugin_loaded("Invisible Spectator");
        if( 
plugin )
        {
            
func get_func_id("make_invis"plugin); // old version
            
if( func == -)
            {
                
func get_func_id("ClCmd_Spectate"plugin); // orpheu version
                
if( func != -)
                {
                    
// ops, something went wrong !!
                    
pluginType 2// orpheu
                
}
            }
            else
            {
                
pluginType 1;
            }
        }
    }

    if( 
func != -)
    {
        if( 
callfunc_begin_i(funcplugin) )
        {
            
callfunc_push_int(id);
            if( 
pluginType == )
            {
                
callfunc_push_int(ADMIN_BAN);
            }
            
callfunc_end();
        }
    }




All times are GMT -4. The time now is 23:13.

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