Direct function call vs CallLocalFunction
#1

Hi, when I'm working on a gamemode or filterscript and I have a certain function (for example a custom one), I have noticed that there are at least two ways of calling it: one of them is to call that function directly, and the other is by CallLocalFunction. For example, imagine that I have a custom function to give players some weapons upon spawning:

pawn Код:
forward GiveSpawnWeapons(playerid);
public GiveSpawnWeapons(playerid)
{
    GivePlayerWeapon(playerid, 24, 500);
    GivePlayerWeapon(playerid, 26, 500);
    GivePlayerWeapon(playerid, 28, 500);
    GivePlayerWeapon(playerid, 31, 500);
    return 1;
}
If I'm going to call this custom function in OnPlayerSpawn, this is the first of the two mentioned ways:

pawn Код:
public OnPlayerSpawn(playerid)
{
    GiveSpawnWeapons(playerid);
    return 1;
}
And this is the second one:

pawn Код:
public OnPlayerSpawn(playerid)
{
    CallLocalFunction("GiveSpawnWeapons", "i", playerid);
    return 1;
}
So, what are the differences between one and the other? in what cases should I use one method over the other?
Reply


Messages In This Thread
Direct function call vs CallLocalFunction - by Gryphus One - 31.12.2012, 15:50
Respuesta: Direct function call vs CallLocalFunction - by Gryphus One - 01.01.2013, 23:51
AW: Direct function call vs CallLocalFunction - by IPrototypeI - 02.01.2013, 00:09

Forum Jump:


Users browsing this thread: 1 Guest(s)