Raised This Month: $ Target: $400
 0% 

Need explanations about forward declaration


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-06-2007 , 19:44   Need explanations about forward declaration
Reply With Quote #1

What's the purpose using 'forward' ?
For example:

Code:
forward bool:isnominated(map[]);
forward public handle_nominate(id,map[]);

[...]

bool:isnominated(map[])
{ 
     //
}

public handle_nominate(id,map[]
{
      //
}
It's a more faster way?
__________________
Arkshine is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 11-07-2007 , 03:45   Re: Need explanations about forward declaration
Reply With Quote #2

Well, as I'm sure you've noticed, the latter of the two provides the 'id' parameter. This requires it being a public function so as to pass such as parameter, which you should use if you need the soldier who nominated it's id.

The former of the two is simpler and quicker. It's not even public. But it doesn't pass the id parameter, which may be disadvantageous.

I'd imagine they do the same exact thing, and the only difference is whether or not you need the id parameter. It's odd that someone made both, but eh.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 11-07-2007 , 03:56   Re: Need explanations about forward declaration
Reply With Quote #3

forward is a keyword that indicates the function may be called from the outside, ie, another plugin or the core.

it is more of a useful hint to the programmer than anything else.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-07-2007 , 05:34   Re: Need explanations about forward declaration
Reply With Quote #4

But called how?

This would be very useful for me.
purple_pixie is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 11-07-2007 , 08:06   Re: Need explanations about forward declaration
Reply With Quote #5

Jesus, I'm sorry, I totally misread your question.

Twilight Suzuka explained it pretty straightforward...if you want an example, go check out WeaponMod from SpaceHead productions...they create forwards in one plugin and use the forward in another.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 11-07-2007 , 08:41   Re: Need explanations about forward declaration
Reply With Quote #6

Or ATAC from the same place.
__________________
Brad is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-07-2007 , 09:15   Re: Need explanations about forward declaration
Reply With Quote #7

Thanks, people.

I have weaponmod ... I'm impressed I didn't notice that.

EDIT: OK ... now I'm just very confused. I might use natives instead. Still confused though.

Last edited by purple_pixie; 11-07-2007 at 09:32.
purple_pixie is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 11-07-2007 , 09:41   Re: Need explanations about forward declaration
Reply With Quote #8

The forward keyward DOES NOTHING. It is a HINT to the PROGRAMMER that the function should probably be public, and will most likely be called from an outside source.

It is also used for some other things (such as forbidding operations on tags) but you will never ever see it used for that ever. Usually it is only used as a hint to the programmer that, hey, some other plugin is going to call this function.

NOTHING ELSE.

Nothing confusing at all.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-07-2007 , 09:55   Re: Need explanations about forward declaration
Reply With Quote #9

I meant the whole forwards concept.

As in "CreateMultiForward" et c.

But now I think I get it.
I haven't got my natives to work yet, but I wrote a teeny plugin and made a plugin for my plugin with forwards.

EDIT: Scrap that, I'm fairly sure I get both now.
I was confused again until I realised you have to register them *before* plugin_init() ...

Last edited by purple_pixie; 11-07-2007 at 10:06.
purple_pixie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-07-2007 , 11:46   Re: Need explanations about forward declaration
Reply With Quote #10

Thanks.
__________________
Arkshine 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 01:17.


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