23.05.2013, 10:59
I think you're over thinking it, the tutorial covers both less advanced and more advanced techniques;
In reality, the first few paragraphs is all you need to know to cover the basics and create what you want.
Specifically, that part.
So if you want to store a players' score, cash and if he has a drivers license. You'll want something like this:
Example usage would be as following:
In reality, the first few paragraphs is all you need to know to cover the basics and create what you want.
Quote:
Enumerators There is something about enums that many scripters aren't aware of. There are many of you using enums in your script for storing Player/Vehicle/House Data etc. (Especially user info) A typical (or very common) example: pawn Код:
|
So if you want to store a players' score, cash and if he has a drivers license. You'll want something like this:
pawn Код:
enum playerInfo
{
Money,
Score,
License
};
new pInfo[MAX_PLAYERS][playerInfo];
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SavePlayerStatsToDB(playerid); // Your function to save player stats, e.g. by MySQL or ini files, whatever you use.
pInfo[playerid][Score] = 0; // unset the vars.
pInfo[playerid][Money] = 0;
pInfo[playerid][License] = 0;
}
public OnPlayerConnect(playerid)
{
LoadPlayerStats(playerid);
}
LoadPlayerStats(playerid);
{
//Load stats
//Minor example:
//You have the variable value, which was previously retrieved using your manner of choice.
pInfo[playerid][License] = value;
}
SavePlayerStatsToDB(playerid)
{
//Save stats
}
hasLicense(playerid) // Ideally, you don't want to use a plain function, but much rather perform the if check every
// time you need it, this is merely an example.
{
if (pInfo[playerid][License])
{
return 1; // player has a license
}
return 0;
}