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

Call a function within a plugin from included file


Post New Thread Reply   
 
Thread Tools Display Modes
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-04-2014 , 14:34   Re: Call a function within a plugin from included file
Reply With Quote #11

So what you wish to do is cut one big plugin into .inc files?
.Dare Devil. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-04-2014 , 14:47   Re: Call a function within a plugin from included file
Reply With Quote #12

Quote:
Originally Posted by .Dare Devil. View Post
So what you wish to do is cut one big plugin into .inc files?
Nope, it will be just a header file for querying some stuff with sockets, and I just didn't want to create another plugin that will be required for subplugins to work. All it is needed now is just to include that file and that's it. And it's not big, it only has like 250-300 lines. And I think I got it to work with creating one-plugin forwards. All that forward has to do is inform the plugin that query response has arrived.

Last edited by klippy; 08-04-2014 at 14:48.
klippy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-05-2014 , 00:00   Re: Call a function within a plugin from included file
Reply With Quote #13

tl;dr

Quote:
Originally Posted by KliPPy View Post
Hello there, I was wondering if it is possible to call a function in a plugin from included file. If you don't understand what I mean by that, here's an example.
That is counter-intuitive and not what include files are used for. Include files should be completely independent from the code within the plugin that is using the include file. If you do, then you create a circular dependency (an infinite loop so to speak).
__________________
fysiks is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-05-2014 , 07:01   Re: Call a function within a plugin from included file
Reply With Quote #14

Quote:
Originally Posted by fysiks View Post
tl;dr



That is counter-intuitive and not what include files are used for. Include files should be completely independent from the code within the plugin that is using the include file. If you do, then you create a circular dependency (an infinite loop so to speak).
Yeah, I know what include file's role, but I was just curious about this one... So I am using one-plugin forward now and it works flawlessly.
klippy is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-05-2014 , 08:38   Re: Call a function within a plugin from included file
Reply With Quote #15

Did you try your code? I don't know if stock functions have any specific access, but since the included file is basically copied to the source code, it will work unless stock doesn't have access to the function. If it compiles, it will work.

Either way, not using stock will work just fine. I don't know what you're trying to achieve, but it doesn't seem like you need to use a stock to begin with.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 08-05-2014 at 08:39.
Backstabnoob is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-05-2014 , 08:42   Re: Call a function within a plugin from included file
Reply With Quote #16

No, I haven't tried calling a function from include file, and the fact that include file is entirely copied to plugin source is the reason I thought about this. But I already switched it with one plugin forward.
My goal is to create all within one include file, so putting one more plugin on a server is unnecessary. I know it may sound strange and is probably not a standard, but whatever, I like it the way it is now.
klippy is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-05-2014 , 08:49   Re: Call a function within a plugin from included file
Reply With Quote #17

The main problem with that approach is re-defining symbols. You are unable to use forwards as they might be re-defined in the plugin file itself, but if you got around that then it doesn't really matter.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-05-2014 , 09:07   Re: Call a function within a plugin from included file
Reply With Quote #18

Well most of the things in my .inc file are static, or not accessible out of the include file scope. The only things visible to other plugins are functions which users should use, so symbol redefinition shouldn't be a problem.
klippy 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 16:04.


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