#1

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

Your question is a bit confusing.

Are you saying that if you create a variable inside a stock function, will it be accessible outside the function?
or are you asking if a variable created inside a stock will work for only one playerid, such as playerid 0?
Reply
#3

Quote:
Originally Posted by Krx17
Посмотреть сообщение
Your question is a bit confusing.

Are you saying that if you create a variable inside a stock function, will it be accessible outside the function?
or are you asking if a variable created inside a stock will work for only one playerid, such as playerid 0?
Both I need to know!
Reply
#4

If you create a variable inside a stock function, it can only be used inside that function.

If you create a variable inside a stock function, you can use it for any playerid.

Example:
pawn Код:
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.
}
Hopefully that was what you were asking.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)