What is the point of using 'forward'
#1

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!
Reply
#2

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;
}
Reply
#3

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.
Reply
#4

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
Reply
#5

Really, ******..

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


Forum Jump:


Users browsing this thread: 1 Guest(s)