Make cash load and save? +REP
#1

Hello guys, I done this before, but I simply forgot it.

Here's my enum:

Код HTML:
enum PlayerInfo
{
   Logged,
   miniadmin,
   Level,
   Duty,
   pGD,
   pTS,
   pVip,
   pCop,
   pAmmo,
   pGuns,
   Banned,
}
And here's my login and register:

Код HTML:
CMD:login(playerid,params[])
{
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_RED,"†. You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to login
    new password[23],password2[23];//Creating a variable to store the password, and another one to store the password from the user's file.
    if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,COLOR_RED,"†. USAGE: /login [password]");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
    new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
    format(file,sizeof file,"Admin/%s.ini",PlayerName);
    if(!fexist(file)) return SendClientMessage(playerid,COLOR_RED,"†. Please use /register");//Checking if the player is not registered, again....
    INI_Open(file);//Opening the file with SII include
    INI_ReadString(password2,"Password");
    if(strcmp(password,password2) != 0) return SendClientMessage(playerid,COLOR_RED,"†. Wrong password!"),INI_Close();//Checking if he inputted the correct password, if not, retrieve him a message and closing the file;
    PInfo[playerid][Level] = INI_ReadInt("Level");
	PInfo[playerid][pVip] = INI_ReadInt("pVip");
	PInfo[playerid][pGD] = INI_ReadInt("pGD");
	PInfo[playerid][pTS] = INI_ReadInt("pTS");//Setting the admin level variable, to the one thats in his file.
    INI_Close();//"Closing the file", that means that we're not using it anymore :P
    SendClientMessage(playerid,COLOR_GREEN,"†. You've been succesfully logged in, enjoy the server homie. †");
    PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
    return 1;
}

CMD:register(playerid,params[])
{
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_RED,"†. You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to re-register
    new password[23];//Creating a variable to store the password
    if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,COLOR_RED,"†. USAGE: /register [password]");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
    new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
    format(file,sizeof file,"Admin/%s.ini",PlayerName);
    if(fexist(file)) return SendClientMessage(playerid,COLOR_RED,"†. Somehow you're already registered!");//Checking if the player is already registered, again....
    INI_Open(file);//Opening the file with SII include (with this function, if the file is not created, it will automatically create the file.)
    INI_WriteString("Password",password);//Writing in the file the password the player has inputted.
    INI_WriteInt("Level",PInfo[playerid][Level]);
	INI_WriteInt("pGD",PInfo[playerid][pGD]);
	INI_WriteInt("pTS",PInfo[playerid][pTS]);
	INI_WriteInt("pVip",PInfo[playerid][pVip]);//Writing in the file, the variable of the admin level.
    INI_Save();//After we write something to the file, we already have to use this to save the information in the player's file.
    INI_Close();//"Closing the file", that means that we're not using it anymore :P
    SendClientMessage(playerid,COLOR_GREEN,"†. You have successfully registered, enjoy the server homie †.");
    PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
    return 1;
}
Reply
#2

pawn Код:
enum PlayerInfo
{
   Logged,
   miniadmin,
   Level,
   Duty,
   Cash,
   pGD,
   pTS,
   pVip,
   pCop,
   pAmmo,
   pGuns,
   Banned,
}
pawn Код:
CMD:login(playerid, params[])
{
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_RED,"†. You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to login
    new password[23],password2[23];//Creating a variable to store the password, and another one to store the password from the user's file.
    if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,COLOR_RED,"†. USAGE: /login [password]");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
    new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
    format(file,sizeof file,"Admin/%s.ini",PlayerName);
    if(!fexist(file)) return SendClientMessage(playerid,COLOR_RED,"†. Please use /register");//Checking if the player is not registered, again....
    INI_Open(file);//Opening the file with SII include
    INI_ReadString(password2,"Password");
    if(strcmp(password,password2) != 0) return SendClientMessage(playerid,COLOR_RED,"†. Wrong password!"),INI_Close();//Checking if he inputted the correct password, if not, retrieve him a message and closing the file;
    PInfo[playerid][Level] = INI_ReadInt("Level");
    PInfo[playerid][Cash] = INI_ReadInt("Cash");
    PInfo[playerid][pVip] = INI_ReadInt("pVip");
    PInfo[playerid][pGD] = INI_ReadInt("pGD");
    PInfo[playerid][pTS] = INI_ReadInt("pTS");//Setting the admin level variable, to the one thats in his file.
    INI_Close();//"Closing the file", that means that we're not using it anymore :P
    SendClientMessage(playerid,COLOR_GREEN,"†. You've been succesfully logged in, enjoy the server homie. †");
    PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
    return 1;
}

CMD:register(playerid, params[])
{
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_RED,"†. You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to re-register
    new password[23];//Creating a variable to store the password
    if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,COLOR_RED,"†. USAGE: /register [password]");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
    new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
    format(file,sizeof file,"Admin/%s.ini",PlayerName);
    if(fexist(file)) return SendClientMessage(playerid,COLOR_RED,"†. Somehow you're already registered!");//Checking if the player is already registered, again....
    INI_Open(file);//Opening the file with SII include (with this function, if the file is not created, it will automatically create the file.)
    INI_WriteString("Password",password);//Writing in the file the password the player has inputted.
    INI_WriteInt("Level",PInfo[playerid][Level]);
    INI_WriteInt("Cash",PInfo[playerid][Cash]);
    INI_WriteInt("pGD",PInfo[playerid][pGD]);
    INI_WriteInt("pTS",PInfo[playerid][pTS]);
    INI_WriteInt("pVip",PInfo[playerid][pVip]);//Writing in the file, the variable of the admin level.
    INI_Save();//After we write something to the file, we already have to use this to save the information in the player's file.
    INI_Close();//"Closing the file", that means that we're not using it anymore :P
    SendClientMessage(playerid,COLOR_GREEN,"†. You have successfully registered, enjoy the server homie †.");
    PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
    return 1;
}
Reply
#3

Doesnt work...
Reply
#4

What 'doesn't work' exactly? It doesn't get saved? File doesn't load it properly?
Reply
#5

Yes lol, it doesnt save it.
Reply
#6

Someone?
Reply
#7

Seriously, someone cmon please.
Reply
#8

This may sound stupid, but have you made the folder /Admin in your scriptfiles?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)