#include <a_samp>
#include <dutils>
#include <Dini>
enum pInfo {
AdminLevel,
level,
cash,
pw,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid) {
new name[MAX_PLAYER_NAME], file[128]; // the name and the file
GetPlayerName(playerid, name, MAX_PLAYER_NAME); // getting client's name
format(file, sizeof(file), ".../Users/%s.ini", name); // the location of the file
if(!fexist(file)) { // if the file does not exists
SendClientMessage(playerid, COLOR_YELLOW, "You are not registered, please register");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please Register", "Enter Your Password Below", "Register", "Cancel"); // this is the dialog type
}
else {
new str[128]; // if the player IS registered
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "Welcome Back ~r~%s. Enjoy!", name);
SendClientMessage(playerid, COLOR_YELLOW, str);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
return 1;
}
playerid The ID of the player to show the dialog to. dialogid An ID to assign this dialog to, so responses can be processed. Max dialogid is 32767. Using negative values will close any open dialog. style The style of the dialog. caption[] The title at the top of the dialog. The length of the caption can not exceed more than 64 characters before it starts to cut off. info[] The text to display in the dialog. Use \n to start a new line and \t to tabulate. button1[] The text on the left button. button2[] The text on the right button. Leave it blank to hide it.
public OnPlayerDisconnect(playerid, reason)
{
new file[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(dini_Exists(file)) {
dini_IntSet(file, "pw", PlayerInfo[playerid][pw]);
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
dini_IntSet(file, "level", PlayerInfo[playerid][level]);
}
return 1;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(dialogid == 1) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
dini_Create(file);
dini_IntSet(file, "pw", num_hash(inputtext));
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
dini_IntSet(file, "level", PlayerInfo[playerid][level]);
format(str, sizeof(str), "You are registered as ~r~%s. Your password is ~r~%s. /changepass to change it", name, inputtext);
SendClientMessage(playerid, COLOR_SYSTEM, str);
PlayerInfo[playerid][level] = dini_Int(file, "level");
PlayerInfo[playerid][cash] = dini_Int(file, "cash");
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
}
}
else {
Kick(playerid);
}
}
if(dialogid == 2) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), ".../Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
if(num_hash(inputtext) != dini_Int(file, "pw")) {
if(dialogid == 2) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), ".../Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
if(num_hash(inputtext) != dini_Int(file, "pw")) {
SendClientMessage(playerid, COLOR_SYSTEM, "Wrong Password");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
else {
SendClientMessage(playerid, COLOR_SYSTEM, "Succesfuly logged in");
PlayerInfo[playerid][level] = dini_Int(file, "level");
PlayerInfo[playerid][cash] = dini_Int(file, "cash");
GivePlayerMoney(playerid, dini_Int(file, "cash"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
}
}
}
else {
Kick(playerid);
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "Welcome to UK-DM");
SendClientMessage(playerid, COLOR_BRIGHTRED, "Hope you enjoy!");
SendClientMessage(playerid, COLOR_BRIGHTRED, "Type /commands for a list of commands");
new name[MAX_PLAYER_NAME], file[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(!fexist(file)) {
SendClientMessage(playerid, COLOR_YELLOW, "You are not registered, please register");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please Register", "Enter Your Password Below", "Register", "Cancel");
}
else {
new str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "Welcome Back ~r~%s. Enjoy!", name);
SendClientMessage(playerid, COLOR_YELLOW, str);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(dini_Exists(file)) {
dini_IntSet(file, "pw", PlayerInfo[playerid][pw]);
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
dini_IntSet(file, "level", PlayerInfo[playerid][level]);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), ".../Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
dini_Create(file);
dini_IntSet(file, "pw", num_hash(inputtext));
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
dini_IntSet(file, "level", PlayerInfo[playerid][level]);
format(str, sizeof(str), "You are registered as ~r~%s. Your password is ~r~%s. /changepass to change it", name, inputtext);
SendClientMessage(playerid, COLOR_SYSTEM, str);
PlayerInfo[playerid][level] = dini_Int(file, "level");
PlayerInfo[playerid][cash] = dini_Int(file, "cash");
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
}
}
else {
Kick(playerid);
}
}
if(dialogid == 2) {
new file[128], name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), ".../Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
if(num_hash(inputtext) != dini_Int(file, "pw")) {
SendClientMessage(playerid, COLOR_SYSTEM, "Wrong Password");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
else {
SendClientMessage(playerid, COLOR_SYSTEM, "Succesfuly logged in");
PlayerInfo[playerid][level] = dini_Int(file, "level");
PlayerInfo[playerid][cash] = dini_Int(file, "cash");
GivePlayerMoney(playerid, dini_Int(file, "cash"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
}
}
}
else {
Kick(playerid);
}
}
return 1;
}
#pragma unused ret_memcpy
When i hit register the server crashes. |
.../Users/%s.ini
../Users/%s.ini
First, you must have the folder Users.
Then, it's a mistake pawn Код:
pawn Код:
|
Users/%s.ini
Where do I create folder "Users"? I tried registering but no couldn't find a Users folder or a file with my name on it. |
You forgot to add this pawn Code:
|
Where do I create folder "Users"? I tried registering but no couldn't find a Users folder or a file with my name on it.
|
Inside the scriptfile folder you create the folder called ''Users'' |
Doesnt matter it works like this too
Code:
Users/%s.ini |
Where do I create folder "Users"? I tried registering but no couldn't find a Users folder or a file with my name on it.
|
undefined symbol "AdminLevel" |
Very nice but when I hit "Compile" It shows me some errors , which actually are the same but on diferent places so here is the error
P.S. I am using SAM[P]CE does it matter ? |
C:\Users\abc123\Desktop\samp\gamemodes\loginreigster.pwn(103) : error 028: invalid subscript (not an array or too many subscripts): "pInfo" C:\Users\abc123\Desktop\samp\gamemodes\loginreigster.pwn(103) : warning 215: expression has no effect C:\Users\abc123\Desktop\samp\gamemodes\loginreigster.pwn(103) : error 001: expected token: ";", but found "]" C:\Users\abc123\Desktop\samp\gamemodes\loginreigster.pwn(103) : error 029: invalid expression, assumed zero C:\Users\abc123\Desktop\samp\gamemodes\loginreigster.pwn(103) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.
dini_IntSet(file, "pw", pInfo[playerid][pw]); //error line