AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   creating forwards in plugins (https://forums.alliedmods.net/showthread.php?t=46456)

GHW_Chronic 10-27-2006 01:45

creating forwards in plugins
 
Let's say I have this function in a script:
Code:
public give_xp(id,amount,type,reason[]) {     xp[id][type] += amount     client_print(id,print_chat,"[AMXX] You have been given %d %s XP points for %s",amount,typestringconst[type],reason) }

Now that code is in plugin A. I want it so that someone can come along and make a plugin B and just hook when plugin A calls that function and be able to know what the parameters are.

Code:
_

teame06 10-27-2006 01:58

Re: creating forwards in plugins
 
Code:
#include <amxmodx> new fwd_give_xp = -1; public plugin_init() {     fwd_give_xp = CreateMultiForward("give_xp", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_STRING);     register_clcmd("say /forward", "cmdForward"); } public cmdForward(id) {     if(fwd_give_xp > -1)     {         new fwd_result;         ExecuteForward(fwd_give_xp, fwd_result, id, 100, 1, "ZOMG");     }     return PLUGIN_HANDLED; } public give_xp(id, amount, type, reason[]) {     client_print(id, print_chat, "%i %i %i %s", id, amount, type, reason); }

k007 10-27-2006 02:02

Re: creating forwards in plugins
 
wow this is sweaty.. so we are able to know when is a function called in other plugin if they have a multiforward? and those this goes for functions only? or stocks too..

GHW_Chronic 10-27-2006 02:02

Re: creating forwards in plugins
 
wow, thats so simple. that's f***ing awesome. thanks bro

GHW_Chronic 10-27-2006 02:04

Re: creating forwards in plugins
 
Quote:

Originally Posted by k007 (Post 395711)
wow this is sweaty.. so we are able to know when is a function called in other plugin if they have a multiforward? and those this goes for functions only? or stocks too..

i don't think you know what a stock is.
this:
allows a plugin creator to allow other plugin creators to create functions that are called whenever their function is called.

edit:
i don't think you know exactly what a function is either.

"set_user_name" is a native function, and when you put:
"public blah()" in a plugin, blah is now a function you made. (of course it doesn't need to be public to be a function)

k007 10-27-2006 02:11

Re: creating forwards in plugins
 
so a stock counts as a function?

teame06 10-27-2006 02:18

Re: creating forwards in plugins
 
It has to be a public function.

GHW_Chronic 10-27-2006 02:31

Re: creating forwards in plugins
 
Quote:

Originally Posted by k007 (Post 395714)
so a stock counts as a function?

a stock doesn't count as a function. read up on what a stock is.

and i guessed it had to be public to use this forwarding, what i was stating was that a function does not have to be public to be a function in general.

Greenberet 10-27-2006 04:08

Re: creating forwards in plugins
 
Quote:

Originally Posted by GHW_Chronic (Post 395717)
a stock doesn't count as a function. read up on what a stock is.

and i guessed it had to be public to use this forwarding, what i was stating was that a function does not have to be public to be a function in general.

a stock is a function.
it will just be only created when it is used.
and you can create forwards in any type of function.

VEN 10-27-2006 05:44

Re: creating forwards in plugins
 
Quote:

Originally Posted by Greenberet (Post 395729)
a stock is a function.

AFAIR, a stock is an "attribute", it can be used not only for functions but for example for constant as well.


All times are GMT -4. The time now is 04:50.

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