how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
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
Re: how to make score, kills, deaths, skin saves -
jejemonerz123 - 04.03.2011
nice job. But one question. Why have you use Killz[MAX_PLAYERS] instead of Killz?
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
nice question. That is because to find the difference between killerid and playerid
AW: how to make score, kills, deaths, skin saves -
.LaaRs. - 04.03.2011
good work. Now it will be easy
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
thanks guys. I have did this tutorial in 10 mins
Re: how to make score, kills, deaths, skin saves -
BASITJALIL - 04.03.2011
Nice man
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
thanks!!
Re: how to make score, kills, deaths, skin saves -
Mean - 04.03.2011
Quote:
Originally Posted by jejemonerz123
nice job. But one question. Why have you use Killz[MAX_PLAYERS] instead of Killz?
|
Because Killz only will work for ID 0, and with MAX_PLAYERS will work for max 500 players, because the a_samp definition of MAX_PLAYERS is 500.
pawn Код:
#define MAX_PLAYERS (500)
So you are doing
So, size of 500, works for 500 players.
Nice tut, but I don't like Dini.
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
Quote:
Originally Posted by Mean
Because Killz only will work for ID 0, and with MAX_PLAYERS will work for max 500 players, because the a_samp definition of MAX_PLAYERS is 500.
pawn Код:
#define MAX_PLAYERS (500)
So you are doing
So, size of 500, works for 500 players.
Nice tut, but I don't like Dini.
|
me tooo. I like y_ini always. BTW I show it in DINI to make people understand
AW: how to make score, kills, deaths, skin saves -
[DR]Reaper[GEARS] - 04.03.2011
Verry nice !
Keep it up!
Re: AW: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 04.03.2011
Quote:
Originally Posted by [DR]Reaper[GEARS]
Verry nice !
Keep it up!
|
thanks mate!
Re: how to make score, kills, deaths, skin saves -
ilikenuts - 05.03.2011
G00D J0B
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 05.03.2011
thaNZ
Re: how to make score, kills, deaths, skin saves -
TheYoungCapone - 27.03.2011
Question how would I make a command where it shows players stats for exmaple /stats [id] displays there stats like Kils:0 Deaths:0 Money:0 Score:0 ect..
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 28.03.2011
you can make it easily with format function
Re: how to make score, kills, deaths, skin saves -
Ironboy - 28.03.2011
Nice it is very usefull!
Re: how to make score, kills, deaths, skin saves -
Medal Of Honor team - 29.03.2011
ya thanks
Re: how to make score, kills, deaths, skin saves -
[M.A]Angel[M.A] - 04.04.2011
I think
This FS is better so
Re: how to make score, kills, deaths, skin saves -
$$inSane - 03.05.2012
thnx for the tutorial
Re: how to make score, kills, deaths, skin saves -
JaKe Elite - 04.05.2012
Quote:
Originally Posted by $$inSane
thnx for the tutorial
|
I'm enough, every time i see you in old topics i'm very very enough.
You just making your post count grower, you didn't even test the tutorial.
Don't bother posting in old topics or don't post like
'Nice'
'Thanks it help me alot'
'Rep for you'
'Nice job'
i'm enough really enough!
By the way this is 1 year old topic and you bumping it gosh