SA-MP Forums Archive
[HELP]Stocks - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]Stocks (/showthread.php?tid=555000)



[HELP]Stocks - TheRaGeLord - 06.01.2015

I Need Help In Understanding Stocks, for eg, This one

pawn Код:
stock SendAdminMessage(col, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0)
            SendClientMessage(i, col, string);
    }

    return 1;
}



Re: [HELP]Stocks - RedFusion - 06.01.2015

Putting stock infront of your function name basically means that the compiler won't warn you if you haven't used the function anywhere.
Read more here: https://sampwiki.blast.hk/wiki/Stock_Functions

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
This is called a for loop. This loop in particular will go from 0 - 499. It stops before i reaches a value of 500, hence 499.

(MAX_PLAYERS is usually defined as 500)

Using this is the equivalent of putting 1000~ lines of code as such:
pawn Код:
if(PlayerInfo[0][pAdmin] > 0)
 SendClientMessage(0, col, string);

if(PlayerInfo[1][pAdmin] > 0)
 SendClientMessage(1, col, string);

if(PlayerInfo[2][pAdmin] > 0)
 SendClientMessage(2, col, string);
// and so on from 0 > 499
Read more about the for loop here: https://sampwiki.blast.hk/wiki/Keywords:Statements#for

pawn Код:
if(PlayerInfo[i][pAdmin] > 0)
This appears to check if the player's admin level is above 0; 1 and upwards. If it is, then it executes this line of code:

pawn Код:
SendClientMessage(i, col, string);
This is a function that sends the player a message.
Read more here: https://sampwiki.blast.hk/wiki/SendClientMessage


Re: [HELP]Stocks - TheRaGeLord - 06.01.2015

Thanks...


Re: [HELP]Stocks - RedFusion - 06.01.2015

To summarize it, it sends a message to all the online admins.
I hope this helped you.