31.12.2012, 15:50
(
Последний раз редактировалось Gryphus One; 01.01.2013 в 23:50.
)
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:
If I'm going to call this custom function in OnPlayerSpawn, this is the first of the two mentioned ways:
And this is the second one:
So, what are the differences between one and the other? in what cases should I use one method over the other?
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;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
GiveSpawnWeapons(playerid);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
CallLocalFunction("GiveSpawnWeapons", "i", playerid);
return 1;
}