10.02.2011, 20:45
If I create a variable within a stock function, will it only be valid in that stock and for that player? Or will it interact with other players using the same stocks?
stock myFunc(playerid)
{
//Since playerid is part of the function parameters, you can basically use it for any playerid.
//So we can do this:
SetPlayerHealth(playerid, 0);
//And anywhere in the script we can do myFunc(1) for playerid 1 or myFunc(10) for playerid 10
}
stock myFunc2()
{
new playerid = 5;
//Since we created playerid inside the function and it's not part of the parameters
// It can only do stuff for playerid 5 unless we set 'playerid' to something else
SetPlayerHealth(playerid, 0); //Will set playerid 5's health to 0.
}