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

[TUT] Plugin API


Post New Thread Reply   
 
Thread Tools Display Modes
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-25-2006 , 21:43   Re: Plugin API
Reply With Quote #11

Quote:
Originally Posted by nver_been_hit View Post
just there so people dont steal try to steal it and release it for them selves .
No offense, but I doubt that's ever going to happen ;]

Your comment about "being sued" is not only very barbaric, it's also kind of ironic considering making a plugin closed source means the AMXX team can prosecute you.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-25-2006 , 21:52   Re: Plugin API
Reply With Quote #12

Quote:
Originally Posted by nver_been_hit View Post
i could care less . . and i take no offense . it was jsut a way to protect my idaes .
If you want to add the GPL and repaste it then I will help you.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-25-2006 , 22:14   Re: Plugin API
Reply With Quote #13

Now, what you probably want is something like,

Code:
#define MAX_OPTIONS 9 new g_MenuOptions[MAX_OPTIONS][32] new g_MenuNum //... new Forward = CreateMultiForward("BF_Menu",ET_IGNORE),Return if(Forward < 0)    return if(!ExecuteForward(Forward,Return))    return new Menu[512],Pos Pos += format(Menu[Pos],511 - Pos,"Battlefield Menu^n^n") for(new Count;Count < g_MenuNum;Count++)   Pos += format(Menu[Pos],511 - Pos,"%d. %s^n",Count + 1,g_MenuOptions[Count]) Pos += format(Menu[Pos],511 - Pos,"^n0. Exit") show_menu(id,g_Keys,Menu,-1,"my_menu_name") // ... register_native("BF_AddMenuOption","_BF_AddMenuOption") //... public _BF_AddMenuOption(Plugin,Params) {    if(Params != 1)        return 0    get_string(1,g_MenuOptions[g_MenuNum],31)        return 1 }

Then in another script:

Code:
public BF_Menu()    BF_AddMenuOption("EXPLOSIVE EXPLOSION")

Assuming you change a bit of that and implement it correctly, it should turn out like:

Code:
Battlefield Menu

1. EXPLOSIVE EXPLOSION

0. Exit
I'm not totally sure that's what you want, but that's my guess.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-25-2006 , 22:16   Re: Plugin API
Reply With Quote #14

Sorry, that should be:

Code:
get_string(1,g_MenuOptions[g_MenuNum++],31)

I don't want to edit it, since the indentation gets all screwy if I do.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-25-2006 , 22:30   Re: Plugin API
Reply With Quote #15

Quote:
Originally Posted by nver_been_hit View Post
cool thanks HAWK!
EDIT also i have aquestion abot the include file ? ive never used one before . can you eplaine what it is an how to use it ?
Umm... alright.

An include file is generally a file where you insert data that a plugin as well as other plugins associated with it need. Things like an enum of classes, or any constant data as well as native and forwards should go in it.

In terms of technically what it is, an include file is essentially a header (which is the proper term for it) that, when included, has its contents directly inserted into the place where the including file has the reference.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-27-2006 , 10:02   Re: Plugin API
Reply With Quote #16

Quote:
Originally Posted by nver_been_hit View Post
can you explaine whats happeing in the above script ? I have no idea whats going on in there . Maybee its because my menus are set up diferant .
Basically, here's the sequence of events:

a) Plugin A throws out a forward notifying all plugins that it wants them to add menu items now
b) Plugin B gets this forward called on it and throws back a native saying that it wants to add "EXPLOSIVE EXPLOSION"
c) After the forward is done, Plugin A shows the menu with all the menu items.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 12:17   Re: Plugin API
Reply With Quote #17

What if I want to pass client_PreThink two arguments?
Like clent_PreThink(id, random_num)
I really need to know that ;)
__________________
Sig(h)!
Obbin is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-02-2006 , 20:09   Re: Plugin API
Reply With Quote #18

Quote:
Originally Posted by Obbin View Post
What if I want to pass client_PreThink two arguments?
Like clent_PreThink(id, random_num)
I really need to know that ;)
I already covered that...
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-03-2006 , 00:22   Re: Plugin API
Reply With Quote #19

great tutorial. +karma
This is defenatly a way to go for plugins. Creating a centralized API is a very effective way to connect other plugins together.
Freecode is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 09-03-2006 , 00:26   Re: Plugin API
Reply With Quote #20

Its not very helpful not being able to read thru others posts when they no longer exist to the common user

But I like the tutorial and I hope I can use it some day.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Reply


Thread Tools
Display Modes

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 06:47.


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