Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Starman
Junior Member
Join Date: Dec 2013
Old 06-08-2014 , 20:00   [HELP] How to call a function from another plugin.
Reply With Quote #1

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
Starman is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-08-2014 , 20:26   Re: [HELP] How to call a function from another plugin.
Reply With Quote #2

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!
__________________
Black Rose is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-08-2014 , 20:52   Re: [HELP] How to call a function from another plugin.
Reply With Quote #3

Based on the simply example, you should use dynamic natives.
__________________
fysiks is offline
Starman
Junior Member
Join Date: Dec 2013
Old 06-08-2014 , 22:09   Re: [HELP] How to call a function from another plugin.
Reply With Quote #4

Quote:
Originally Posted by Black Rose View Post
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 View Post
Based on the simply example, you should use dynamic natives.
I'll take that into account, I'll take note of it ..

Last edited by Starman; 06-08-2014 at 22:10.
Starman 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 09:40.


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