[Qestions]
#1

Hello i Want Know How To use it And its what its doing please example and + rep
new Hitman[MAX_PLAYERS];
new anythingshere[MAX_PLAYERS];
Reply
#2

That's a global variable. According to Wikipedia,
Quote:
Originally Posted by wikipedia
In computer programming, a global variable is a variable with global scope, meaning that it is visible (hence accessible) throughout the program, unless shadowed. The set of all global variables is known as the global environment or global state.
A variable is something holding data.

The [new] is a keyword telling the compiler that the code following it is a definition. The "MAX_PLAYERS" tells the compiler how many cells the variable should be made of. By default it would be
new anythingshere[500];

You can then use it like so:
pawn Код:
new g_IsAdmin[MAX_PLAYERS];

CMD:makeadmin(playerid, params[])
{
     g_IsAdmin[playerid] = 1;
     return 1;
}
By default, g_IsAdmin would be "0".
Reply
#3

What you are doing is creating a new array. MAX_PLAYERS is a standard defined value of 500. To change this you can put this on top of your script:

Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 50 // For example, change 50 to what you want.
The number in between the brackets -> [] determines the size of the array when it is being created.
So now it would say Hitman[500], which means you have 500 "slots" available to save information. MAX_PLAYERS is used because you want to save a value for each player.

After an array is made you can read/write it by putting a index between the brackets.

So if you want to get the value of the 3rd spot in the array, you would use Hitman[2] (since arrays start at 0).

You could use this as the following (example):

Код:
new IsLoggedIn[MAX_PLAYERS];

if (IsLoggedIn[playerid] == 0)
{
 // Player is not logged in
}
else if (IsLoggedIn[playerid] == 1)
{
  // Player is logged in
}
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays for more information
Reply
#4

ok Thanks Guys +Rep
Now i Will Goto Trying Make Hitman
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)