04.03.2011, 08:31
SAVING'S
OK let's start by adding some variable's
So, let's do it
On the Top of the Script
pawn Код:
#include <a_samp> // This includes a_samp from pawno/include/
#include <Dini> // This include is use for saving data's
#include <Dutils> // This include is used for some important function
#include <Dudb> // This include is used for hashing password
Add this under that
Код:
#define savefolder "/save/%s.ini" // This defines the file name and folder
under the includes add this
Код:
#pragma unused ret_memcpy // This avoid the ret_memcpy warning
Under the #pragma add this
Код:
new Killz[MAX_PLAYERS]; // We have used this variable because to save the kills of the player new Deathz[MAX_PLAYERS]; // Same on here
Add this under OnPlayerConnect
pawn Код:
new pname[128]; // This get's the length of the player name
new file[128]; // This get's the lenght of the file
GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the lenght of the player name
format(file, sizeof(file), savefolder,pname); // This describe's where to save and how to save it
if(!dini_Exists(file)) { // If the file exist
dini_Create(file); // Create the file
dini_IntSet(file, "Score", 0); // Set's "Score"
dini_IntSet(file, "Money", 0); // Set's "Money"
dini_IntSet(file, "Kills", Killz[playerid]); // Set's "Kills"
dini_IntSet(file, "Deaths", Deathz[playerid]); // Set's "Deaths"
dini_IntSet(file, "Skin", 0); // Set's Skin
SetPlayerScore(playerid, dini_Int(file, "Score")); // This describes where to load the score
SetPlayerMoney(playerid, dini_Int(file, "Money")); // This describes where to load the money
SetPlayerSkin(playerid, dini_Int(file, "Skin")); // This describes where to load the skin
// and at last this set's the value which were on the file
}
else {
SetPlayerScore(playerid, dini_Int(file, "Score"));
SetPlayerMoney(playerid, dini_Int(file, "Money"));
SetPlayerSkin(playerid, dini_Int(file, "Skin"));
// the same thing
}
Under OnPlayerDisconnect add this
pawn Код:
new pname[128]; // The name length
new file[128]; // The file length
GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the name length
format(file, sizeof(file), savefolder,pname); // Formatting file
if(!dini_Exists(file)) { // If the file exist
}
else { // if not
dini_IntSet(file, "Score", GetPlayerScore(playerid)); // This Get the Score
dini_IntSet(file, "Money", GetPlayerMoney(playerid)); // This Get the cash
dini_IntSet(file, "Kills", Killz[playerid]); // This get the kills
dini_IntSet(file, "Deaths", Deathz[playerid]); // This get the Deaths
dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); // This get the skin
}
Under OnPlayerDeath add this
Код:
Killz[killerid] ++; // The killer value will be increased Deathz[playerid] ++; // The death value will be increased
-------------
Create a folder on your server scripfiles and rename it to save.
You will need Dini, Dutils and Dudb include.
-------------
Tired of learning and writing. Download this example script
HERE