19.05.2016, 18:33
Why i Can't saw my Nickname in Users File ? i already Make a Users Folder in scriptfiles but dosn't work Why? Show this
Are u saw ? i put it I'll show u the onplayerconnect and many Saw
Tell me What HAppend
i didn't got any Error / Warring but when i go my Server and Register And When i Relog i need Register Again Why !! Why ? i want Login When Register! That Happend! And i didn't saw my Username in File " USERS "
PHP код:
#define PATH "/Users/%s.ini"
#define UserPath "Users/%s.ini"
PHP код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME], file[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "scriptfiles/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 {FF0000}%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), "scriptfiles/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;
}
PHP код:
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), "scriptfiles/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 {FF0000}%s. Your password is {00FF00}%s.", name, inputtext);
SendClientMessage(playerid, COLOR_YELLOW, 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), "scriptfiles/Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
if(num_hash(inputtext) != dini_Int(file, "pw")) {
SendClientMessage(playerid, COLOR_BLUE, "Wrong Password");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
else {
SendClientMessage(playerid, COLOR_GREEN, "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;
}