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

Connect Separate Plugins?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mirun.Frontier
Member
Join Date: Aug 2008
Old 04-25-2011 , 23:10   Connect Separate Plugins?
Reply With Quote #1

Well I'm creating a small custom shop plugin, containing various custom items from other plugins, such as a bazooka from ADV Baz/GiveBaz.

The problem is that I don't know how to connect one plugin to another for it to work, for instance:

=====================
I want my shop plugin to give the player a bazooka
=====================
I have my menu set up in the shop plugin and money, but I want it to give the player a bazooka without bringing the whole code from ADV Bazooka, instead just sending the function to the ADV Bazooka plugin to do it.

*Problem Fixed. No need to post.
__________________
I can't believe I wasted 5 years of my life not knowing how to program correctly. Went too deep into advanced coding before even learning the basics correctly. :c

Last edited by Mirun.Frontier; 04-29-2011 at 02:47.
Mirun.Frontier is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-25-2011 , 23:21   Re: Connect Separate Plugins?
Reply With Quote #2

You could create dynamic natives in the bazooka plugin then use those natives in the other one. Last resort is to use callfunc natives.
__________________
fysiks is offline
Mirun.Frontier
Member
Join Date: Aug 2008
Old 04-26-2011 , 00:27   Re: Connect Separate Plugins?
Reply With Quote #3

I added a native to the bazooka plugin ( native give_item_bazooka(id,ammo,sound) ) and used it into the shop plugin, but when i tried to compile, it did not work. The bazooka plugin itself had a few errors without me touching its other coding.

there were also 2 separate sources for bazooka advanced (to me, reasons unknown), but the way both of them give a bazooka is different.
One uses the C4, and the other has the give_item_bazooka(which is the same thing i think but shorter)

*EDIT: I got it to compile but i made give_item_bazooka its own .inc because when i tried in the bazooka plugin, it didn't compile due to 1 random error that popped up after i did add it in the plugin. But now that i added it as a .inc and then included it with my shop plugin, it compiles, but then when i tested in-game, my plugin wasn't working, i get bad load when i check it in amx_plugins.

*EDIT #2: Problem with my shop plugin( i think ) is due to the bazooka .inc native, but im trying to add the native into the bazooka plugin and im getting error messages. Im setting the native up like this:
PHP Code:
public native_give_item_bazooka(id)
{
    return 
give_item_bazooka[id];

and then i get invalid subscript, token, and expression.
__________________
I can't believe I wasted 5 years of my life not knowing how to program correctly. Went too deep into advanced coding before even learning the basics correctly. :c

Last edited by Mirun.Frontier; 04-26-2011 at 01:27.
Mirun.Frontier is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-27-2011 , 21:17   Re: Connect Separate Plugins?
Reply With Quote #4

PHP Code:
public native_give_item_bazooka(id)
{
     return 
give_item_bazookaid );

Is give_item_bazooka an array or function?
__________________
Bugsy is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-27-2011 , 21:19   Re: Connect Separate Plugins?
Reply With Quote #5

https://forums.alliedmods.net/showthread.php?t=123445
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Mirun.Frontier
Member
Join Date: Aug 2008
Old 04-28-2011 , 01:35   Re: Connect Separate Plugins?
Reply With Quote #6

thanks Emp, I didn't really take a look at that thread nor found it in the first page of a search.

Ok I tried to follow that, but the plugin still doesn't load.

PHP Code:
public plugin_natives()
{
    
register_library("bazookamod")
    
    
register_native("give_item_bazooka","give_item_bazooka")

The native registered in the bazooka adv plugin.

PHP Code:
public give_item_bazooka(id,ammo,sound) {
    
give_item(id"weapon_c4"// give actual weapon
    
hasBazooka[id] = true // the plugin now knows they have a bazooka
    
Munni[id] = ammo //set ammunition
    
CanShoot[id] = true // they can shoot now
    
cs_set_user_plant(id,0,0//they can't plant unless they switch to bomb
    
mode[id] = //mode = normal
    
modetext[id] = 1
    check_model
(id// refresh model
    
ammo_hud(id0)
    
ammo_hud(id1// refresh hud info
    
if (sound) {
        
//audio notification
        
emit_sound(idCHAN_ITEM"items/gunpickup2.wav"VOL_NORMATTN_NORM0PITCH_NORM)
    }

this is the function that give the bazooka.

PHP Code:
// Advanced Bazooka Include File //
#if defined _bazookamod_included
  #endinput
#endif
#define _bazookamod_included

#pragma reqlib "dyn_test"


native give_item_bazooka(id,ammo,sound
and this is the include file im using (It is included in the shop plugin)
@Bugsy, its a function within Bazooka Advanced.
__________________
I can't believe I wasted 5 years of my life not knowing how to program correctly. Went too deep into advanced coding before even learning the basics correctly. :c

Last edited by Mirun.Frontier; 04-28-2011 at 19:28.
Mirun.Frontier is offline
Nyuszy
Senior Member
Join Date: Apr 2009
Old 04-28-2011 , 04:28   Re: Connect Separate Plugins?
Reply With Quote #7

http://forums.alliedmods.net/showthread.php?t=41251
Nyuszy is offline
Mirun.Frontier
Member
Join Date: Aug 2008
Old 04-28-2011 , 19:26   Re: Connect Separate Plugins?
Reply With Quote #8

I already got it from here Nyuszy.

Its confusing/makes little sense to me from Hawk's tut.
I don't know what im doing wrong with the natives. My Shop plugin DOES NOT LOAD when i use the natives.
__________________
I can't believe I wasted 5 years of my life not knowing how to program correctly. Went too deep into advanced coding before even learning the basics correctly. :c
Mirun.Frontier is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 04-28-2011 , 19:58   Re: Connect Separate Plugins?
Reply With Quote #9

Well, firstly, if it's register_library("bazookamod"), then you should be using #pragma reqlib "bazookamod". This way the plugin will at least load. Maybe reread the tutorial carefully?

Secondly, you should use register_native("give_item_bazooka","give_item_bazooka", 1) if you don't want to go through a rather messy process of reading params. It's deprecated, but in this case would be much easier. If you don't want to use this, then read the tutorial for how to read params and pass them properly to the give_item_bazooka function.

And lastly, I'm not sure you should name the native the same as the function, and I have no idea if it works at all like that.
Elusive138 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-28-2011 , 22:07   Re: Connect Separate Plugins?
Reply With Quote #10

I wouldn't even use an include. Just put the native at the top of the plugin if it's going to be the only one and you never plan on using it without both plugins together. I did it this way for one of my example Polymorph add-on plugins so that it would compile online.

It's really up to you in this respect though. Just my two cents.

The style 0 native method is not really all that confusing.
__________________

Last edited by fysiks; 04-28-2011 at 22:10.
fysiks 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:15.


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