SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 10/02/2011, 08:45 PM   #1
Anteino
Big Clucker
 
Join Date: Dec 2010
Posts: 138
Reputation: 2
Default Stock

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?
Anteino is offline  
Old 10/02/2011, 08:48 PM   #2
Krx17
Huge Clucker
 
Krx17's Avatar
 
Join Date: Jul 2010
Posts: 423
Reputation: 22
Default Re: Stock

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?
Krx17 is offline  
Old 10/02/2011, 09:09 PM   #3
Anteino
Big Clucker
 
Join Date: Dec 2010
Posts: 138
Reputation: 2
Default Re: Stock

Quote:
Originally Posted by Krx17 View Post
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!
Anteino is offline  
Old 10/02/2011, 09:12 PM   #4
Krx17
Huge Clucker
 
Krx17's Avatar
 
Join Date: Jul 2010
Posts: 423
Reputation: 22
Default Re: Stock

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 Code:
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.
Krx17 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stock GaGlets(R) Help Archive 4 11/12/2010 02:55 PM
ban stock help The_Gangstas Help Archive 0 04/12/2010 11:28 PM
Help with stock.. The_Moddler Help Archive 0 17/10/2010 02:53 PM
I need this stock Takumi.WS Help Archive 17 21/09/2009 01:02 AM


All times are GMT. The time now is 10:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.