[Tutorial] Save data without registration
#1

SAVE DATA WITHOUT REGISTRATION
In this simple tutorial will teach you how to save some data to re-enter to continue taking the same, but without requiring a log (either by command or dialogues) is very useful to make some filterscript or similar, will used where you are more comfortable, they can also be used in GameMode. All you need will include "dini" which can be found on the forum.

STEP 1: We should include, forgive the repetition, the include, so that its functions can be used in the GameMode / filterscripts. For that one used the following where are the other # includes.
pawn Код:
#include <Dini>
STEP 2: First of all we must make a "new" to find out the name of the player. To do this will the following below the # includes <>
pawn Код:
new jugadornombre[30];
STEP 3: Now we go to OnPlayerConnect, everything happens there when the player connects. We will: Find the name of the player, check if file exists if not create it there, if the data. For that, we will:
pawn Код:
GetPlayerName(playerid,jugadornombre,30); // Gets the name.
if(!dini_Exists(jugadornombre)) // Check if there.
dini_Create(jugadornombre); // Believe it.
else if(dini_Exists(jugadornombre)) // If not, get the data.
{
   SetPlayerScore(playerid, dini_Int(jugadornombre,"Score"));// Create the file variable.
}
STEP 4: In this way we save the data file created player to connect. As follows. Then, use the following code
pawn Код:
GetPlayerName(playerid,jugadornombre,30); // Gets the name.
dini_IntSet(jugadornombre,"Score", GetPlayerScore(playerid)); // Save the data in the file.

STEP 5: Here comes the end, load the data file to the player. For this use the following code in OnPlayerSpawn:
pawn Код:
SetPlayerScore(playerid, dini_Int(jugadornombre,"Score")); //Load the data to the player.

Credits: Me.
To: PawnoScripting.
Note: I used ****** translator, since it is not English.
Note2: If you notice any errors, please let me know that for sure was confused, as I did here in the forum.
Note3: nombrejugador = Player Name.
Reply
#2

Nice tutorial!
Reply
#3

Great tutorial.
Reply
#4

This is nice, but you would have to make a variable for EVERY PLAYER, what if you had a server that hit the max?
Reply
#5

this isn't very good because any random guy can go in my account and do wierd shits that's why we use registrations with passwords so nobody can go in our accounts
but the tutorial itself, it's pretty decent
Reply
#6

This will help me use Dini thanks man.
Reply
#7

what is new jugadornombre[30];
Reply
#8

Quote:
Originally Posted by admantis
Посмотреть сообщение
this isn't very good because any random guy can go in my account and do wierd shits that's why we use registrations with passwords so nobody can go in our accounts
but the tutorial itself, it's pretty decent
Actually, if you already have a login system (and player can't spawn) this will work perfectly.
Quote:
Originally Posted by xFirex
Посмотреть сообщение
what is new jugadornombre[30];
It means player name in Spanish.


Nice one [J]ulian, but...
pawn Код:
dini_Create(jugadornombre); // Believe it.
Believe it?

PD: such an old topic, just noticed about...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)