Enums are just a collection of several variables.
These variables can be anything: integers, floating point numbers and strings/arrays.
pawn Код:
enum PlayerInfo
{
Money,
Float:x, Float:y, Float:z,
PlayerName[24]
}
new PlayerData[MAX_PLAYERS][PlayerInfo];
In this example, you create an enum that has 6 "fields" (or variables) inside it: 1 integer (Money), 3 floating point variables (x, y, z) and a string (PlayerName).
This enum holds all the data for only one player, so you need several copies of that enum to hold all data for ALL players at once.
Then you create an array to hold all this data for every player.
Since MAX_PLAYERS is by default set to 500, you now have 500 copies of that enum inside that array, one for every player.
But this code won't do much right now, let's use it:
pawn Код:
PlayerData[5][Money] = GetPlayerMoney(5);
GetPlayerPos(5, PlayerData[5][x], PlayerData[5][y], PlayerData[5][z]);
GetPlayerName(5, PlayerData[5][PlayerName], 24);
On the first line, you get the amount of money of the player with ID 5.
That value is returned by GetPlayerMoney and is stored in the Money variable of the enum for player 5.
Then the current position of the player gets stored in the x, y and z variables of the enum for player 5.
Finally the name is stored in the PlayerName variable of the enum of player 5.
You can use those variables too for checking data with if-statements and other things (while, for, ...):
pawn Код:
if (PlayerData[5][Money] > 100000)
SendClientMessage(5, 0xFFFFFFFF, "You're rich");
This would send "You're rich" to the player with ID 5 when his money is more than 100.000.
Or to inform all players if they're rich:
pawn Код:
for (new playerid; playerid < MAX_PLAYERS; playerid++)
{
if (PlayerData[playerid][Money] > 100000)
SendClientMessage(playerid, 0xFFFFFFFF, "You're rich");
}