[Tutorial] how to make score, kills, deaths, skin saves
#1

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
You can find these includes in the description.

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
OK now the variable's. Learn this carefully okay.

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
Now the main part

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
    }
Ok now

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
    }
It's not yet finished. We still have to define the Killz and Deathz.

Under OnPlayerDeath add this

Код:
Killz[killerid] ++; // The killer value will be increased
Deathz[playerid] ++; // The death value will be increased
Descriptions:
-------------

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
Reply


Messages In This Thread
how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 08:31
Re: how to make score, kills, deaths, skin saves - by jejemonerz123 - 04.03.2011, 08:34
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 08:35
AW: how to make score, kills, deaths, skin saves - by .LaaRs. - 04.03.2011, 08:36
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 08:38
Re: how to make score, kills, deaths, skin saves - by BASITJALIL - 04.03.2011, 08:54
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 09:10
Re: how to make score, kills, deaths, skin saves - by Mean - 04.03.2011, 09:13
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 09:18
AW: how to make score, kills, deaths, skin saves - by [DR]Reaper[GEARS] - 04.03.2011, 11:42
Re: AW: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 04.03.2011, 13:19
Re: how to make score, kills, deaths, skin saves - by ilikenuts - 05.03.2011, 08:49
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 05.03.2011, 09:49
Re: how to make score, kills, deaths, skin saves - by TheYoungCapone - 27.03.2011, 19:50
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 28.03.2011, 08:07
Re: how to make score, kills, deaths, skin saves - by Ironboy - 28.03.2011, 19:13
Re: how to make score, kills, deaths, skin saves - by Medal Of Honor team - 29.03.2011, 15:51
Re: how to make score, kills, deaths, skin saves - by [M.A]Angel[M.A] - 04.04.2011, 13:03
Re: how to make score, kills, deaths, skin saves - by $$inSane - 03.05.2012, 13:06
Re: how to make score, kills, deaths, skin saves - by JaKe Elite - 04.05.2012, 02:35
Re: how to make score, kills, deaths, skin saves - by mickos - 07.05.2012, 13:47
Respuesta: how to make score, kills, deaths, skin saves - by [DOG]irinel1996 - 07.05.2012, 14:21
Re: how to make score, kills, deaths, skin saves - by x4hi - 23.08.2014, 14:54
Re: how to make score, kills, deaths, skin saves - by PMH - 26.08.2014, 14:48
Re: how to make score, kills, deaths, skin saves - by HumbleGuy - 25.07.2016, 01:29
Re: how to make score, kills, deaths, skin saves - by Luis- - 25.07.2016, 01:36

Forum Jump:


Users browsing this thread: 1 Guest(s)