AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Connect Separate Plugins? (https://forums.alliedmods.net/showthread.php?t=155725)

Mirun.Frontier 04-25-2011 23:10

Connect Separate Plugins?
 
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.

fysiks 04-25-2011 23:21

Re: Connect Separate Plugins?
 
You could create dynamic natives in the bazooka plugin then use those natives in the other one. Last resort is to use callfunc natives.

Mirun.Frontier 04-26-2011 00:27

Re: Connect Separate Plugins?
 
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.

Bugsy 04-27-2011 21:17

Re: Connect Separate Plugins?
 
PHP Code:

public native_give_item_bazooka(id)
{
     return 
give_item_bazookaid );


Is give_item_bazooka an array or function?

Emp` 04-27-2011 21:19

Re: Connect Separate Plugins?
 
https://forums.alliedmods.net/showthread.php?t=123445

Mirun.Frontier 04-28-2011 01:35

Re: Connect Separate Plugins?
 
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.

Nyuszy 04-28-2011 04:28

Re: Connect Separate Plugins?
 
http://forums.alliedmods.net/showthread.php?t=41251

Mirun.Frontier 04-28-2011 19:26

Re: Connect Separate Plugins?
 
Quote:

Originally Posted by Emp` (Post 1459230)

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.

Elusive138 04-28-2011 19:58

Re: Connect Separate Plugins?
 
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.

fysiks 04-28-2011 22:07

Re: Connect Separate Plugins?
 
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.


All times are GMT -4. The time now is 19:47.

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