AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How to call a function from another plugin. (https://forums.alliedmods.net/showthread.php?t=241774)

Starman 06-08-2014 20:00

[HELP] How to call a function from another plugin.
 
Well, the truth is that I have searched several things on this subject on the internet, however, I can not make it work, it should be noted that all the codes that show them, are pure examples of something simple that I want to do.

In my research, I came across a native particle (callfunc_begin), however, did several tests using this but without any positive result, below, show you something I want to do.

PHP Code:

/* First plugin, since this function is called from another. */

public plugin_init()
{
    
register_plugin(BLA... BLA... BLA)
    
    
register_clcmd("say /call""CallFunction")
}

public 
CallFunction(id)
{
    new 
Settings callfunc_begin("Testing""UserAlive.amxx")
    
    if(
Settings 0)
    {
        
callfunc_push_int(id)
        
callfunc_end()
    }


In the code above, which would be the function would call another plugin:

PHP Code:

/* This is UserAlive.amxx */

public Testing(id)
{
    if(
is_user_alive(id))
    {
        
client_print(idprint_chat"You're alive.")
    }


In theory, I want to do is something very simple, I want to say a comment "say" the Call, which will produce the function of another plugin is occurring.

Do not know if I will understand, but I think the code should know what I want more age or younger, obviously this is something to try later. Actually, I need you to tell me I'm doing wrong, and how I must.

Thanks, and hopefully help someone :D

Black Rose 06-08-2014 20:26

Re: [HELP] How to call a function from another plugin.
 
That code should work as far as I can see.
You could also look in to Create*Forward() functions.

Here's my test:
Code:
    if ( callfunc_begin("testfunc321", "test8.amxx") )         callfunc_end();

Code:
public testfunc321()     server_print("Hello world!");

Code:

Hello world!

fysiks 06-08-2014 20:52

Re: [HELP] How to call a function from another plugin.
 
Based on the simply example, you should use dynamic natives.

Starman 06-08-2014 22:09

Re: [HELP] How to call a function from another plugin.
 
Quote:

Originally Posted by Black Rose (Post 2148602)
That code should work as far as I can see.
You could also look in to Create*Forward() functions.

Here's my test:
Code:
    if ( callfunc_begin("testfunc321", "test8.amxx") )        &nb sp;callfunc_end();


Code:
public testfunc321()     server_print("Hello world!");


Code:

Hello world!

Well, the truth is that at first I also thought that the first officer as I take the time to look like this native is used, and the methods in which they could use, and believes that code as proof. However, I have several, theories that does not work.

You need to place the exact location of the plugin?

Quote:

Originally Posted by fysiks (Post 2148608)
Based on the simply example, you should use dynamic natives.

I'll take that into account, I'll take note of it ..


All times are GMT -4. The time now is 09:40.

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