SA-MP Forums Archive
What is the point of using 'forward' - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What is the point of using 'forward' (/showthread.php?tid=500374)



What is the point of using 'forward' - K9IsGodly - 12.03.2014

I've been wondering this for a while, what exactly is the use of forwarding something in a script? Thanks to anyone who explains it!


Re: What is the point of using 'forward' - radyx - 12.03.2014

forward announce the compiler that you defined a function somewhere down in the code:
for example

THIS IS WRONG!!!
Код:
//somewhere in the code;
function(a,b);

//function is defined after the call
stock function()
{
// do something;
}

So you can't call a function if you didn't define it previously only if you use forward
This is correct
Код:
forward function(x,y);
//somewhere in the code;
function(x,y);

//function is defined after the call
stock function(a,b)
{
// do something;
}



Re: What is the point of using 'forward' - dannyk0ed - 12.03.2014

Quote:
Originally Posted by radyx
Посмотреть сообщение
forward announce the compiler that you defined a function somewhere down in the code:
for example

THIS IS WRONG!!!
Код:
//somewhere in the code;
function(a,b);

//function is defined after the call
stock function()
{
// do something;
}

So you can't call a function if you didn't define it previously only if you use forward
This is correct
Код:
forward function(x,y);
//somewhere in the code;
function(x,y);

//function is defined after the call
stock function(a,b)
{
// do something;
}
You only need to forward publics.


Re: What is the point of using 'forward' - AnonScripter - 12.03.2014

Forwarding helps you to make a new "public" in your script.
Example:

pawn Код:
forward SendClientMessageToAllAdmins(msg[]);
public SendClientMessageToAllAdmins(msg[])
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
            SendClientMessage(i,COLOR_YELLOW,msg);
        }
    }
}
Now you can use this function in your script just like the way you are using SendClientMessage or SendClientMessageToAll


Re: What is the point of using 'forward' - CuervO - 12.03.2014

Really, ******..

https://sampwiki.blast.hk/wiki/Keywords:...lisers#forward