PDA

View Full Version : After making a register system ...


MusicBeast
12/10/2011, 12:05 PM
Hello,

I have created a Register system. It works fine! But I want to start using it for examlpe, using AdminLevel or pScore and make them save. But I mainly need to know how to work with them,

This is what I have

enum pInfo
{
pKills,
pDeaths,
pMoney,
pAdmin,
pScore
}

How can I use pKills, pDeaths, pMoney, pAdmin and pScore and make them save? Like

if PlayerInfo[playerid][pKills]; I think it's similar to that. Could you tell me? Thank you.

trapped1
12/10/2011, 12:08 PM
use y_ini.. a lot of tutorials

http://forum.sa-mp.com/showthread.php?t=175565
http://forum.sa-mp.com/showthread.php?t=270229

look and maybe you will get it how to make it :)

MusicBeast
12/10/2011, 12:15 PM
Thank you, but are these scripts or w/e ini files help you saving stuff or making a register system, I've done this:

enum pInfo
{
pKills,
pDeaths,
pMoney,
pAdmin,
pScore
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerDisconnect(playerid, reason)
{
new file[64]; // We declare the size of the file
GetPlayerName(playerid,file,sizeof(file)); // We get the file name
format(file,sizeof(file),DOF2_File(file));// We get the user path from DOF2_File (folder Users)
DOF2_SetInt(file, "Murders",PlayerInfo[playerid][pKills]); // We set/update the players settings.
DOF2_SetInt(file, "Death Times",PlayerInfo[playerid][pDeaths]);
DOF2_SetInt(file, "Money",PlayerInfo[playerid][pMoney]);
DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin]);
DOF2_SetInt(file, "Score",PlayerInfo[playerid][pScore]);
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid) // We switch our dialog id's
{
case DIALOG_REGISTER: // If the dialog_register shows up ( id 1111)
{
if(!response) Kick(playerid); // If he click on Quit, he will get kicked
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","{FEABF1}You're a new player, type your password below to register.","Register","Escape");
// If he doesn't type anything, the dialog will show again.
if(response) // If he click on Register
{
new file[64]; // We declare the size of the file
GetPlayerName(playerid,file,sizeof(file)); // We get the file name
format(file,sizeof(file),DOF2_File(file)); // We get the path name from DOF2_File, that means from Users folder.
DOF2_CreateFile(file, inputtext); // Creates the file and the password.
DOF2_SetInt(file, "Kills", 0); // When the player register his kills will be set to 0, you can change
DOF2_SetInt(file, "Deaths", 0); // His deaths will be set to 0, you can change
DOF2_SetInt(file, "Money", 1000); // His money will be set to 1000, you can change
DOF2_SetInt(file, "AdminLevel", 0); // His Admin Level will be set to 0, you can change
DOF2_SetInt(file, "Score", 1); // Score will be set to 1.
DOF2_SaveFile(); // Saves the file.
SetSpawnInfo(playerid, 0, 0, 1965.7406, 1623.2534, 12.8618, 90, 0, 0, 0, 0, 0, 0); // We set the spawn LV
SpawnPlayer(playerid); // After registering, the player will spawn.
}
}
case DIALOG_LOGIN: // If dialog_login (id 2222) shows up
{
if(!response) Kick(playerid); // If he click on Quit, he will get kicked.
if(response) // If he click on Log-in
{
new file[64]; // We declare the size of the file
GetPlayerName(playerid,file,sizeof(file)); // We get the file name
format(file,sizeof(file),DOF2_File(file)); // We get the user path from DOF2_File ( folder Users )
if(DOF2_FileExists(file)) // If he is registered
{
if(DOF2_CheckLogin(file,inputtext)) // We check if the password match
{
PlayerInfo[playerid][pKills] = DOF2_GetInt(file,"Kills"); // We load our settings
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(file,"Deaths");
PlayerInfo[playerid][pMoney] = DOF2_GetInt(file,"Money");
PlayerInfo[playerid][pAdmin] = DOF2_GetInt(file,"AdminLevel");
PlayerInfo[playerid][pScore] = DOF2_GetInt(file,"Score");
SetSpawnInfo(playerid, 0, 0, 1965.7406, 1623.2534, 12.8618, 90, 0, 0, 0, 0, 0, 0); // We set the spawn LV
SpawnPlayer(playerid); // The player spawns after log-in
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]); // We give the player his money
return 1;
}
else // If the password don't match, they will get an error
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Wrong Password!","{F81414}You have typed a wrong password\n{FFFFFF}Type your password here to log-in!","Log-in","Quit");
return 1;
}
}
}
}
}
return 1;
}

How can I exactly use y_ini to save these and define them etc?

How can I make like /setadmin PLAYERID LEVEL for my system?

Jafet_Macario
12/10/2011, 12:17 PM
Follow this tut: http://forum.sa-mp.com/showthread.php?t=273088

MusicBeast
12/10/2011, 12:22 PM
@ Jafter_Macario, But I must make a new Register system if I want to follow the tutorial, right?

Dredd
12/10/2011, 08:38 PM
@ Jafter_Macario, But I must make a new Register system if I want to follow the tutorial, right?
I see he won't anwer xD
I will tell you.
Indead you must make a new register system.

MusicBeast
13/10/2011, 09:28 AM
Thank you, I've made one :) I used ******'s one. But I still don't know how to make it for example:

/makeadmin etc I mean using for example pAdmin in the command etc lol.