21.02.2012, 16:49
I have made register system but with hopeless it doesn't loads the player's PW and stats even if he was admin
see here is the code ::
// OnPlayerConnect...
If you know the problem please tell me!!
see here is the code ::
// OnPlayerConnect...
Код:
new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if (!dini_Exists(file)) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Earth RolePlay", "ServerName:: Earth-RolePlay\tIP::~~~~~\nIt seems like you are not registered, type your password to continue.", "Register", "Cancel"); } if(fexist(file)) { ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Earth RolePlay", "ServerName:: Earth-RolePlay\tIP::~~~~~\nYou are registered thanks for joining us , type your password to continue.", "Login", "Cancel"); } return 1; }
Код:
public OnPlayerDisconnect(playerid, reason) { new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(gPlayerLogged[playerid] == 1) { dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]); dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]); dini_IntSet(file,"Color",GetPlayerColor(playerid)); dini_IntSet(file,"Job",PlayerInfo[playerid][pJob]); dini_IntSet(file,"Vw",GetPlayerVirtualWorld(playerid)); dini_IntSet(file,"Int",GetPlayerInterior(playerid)); dini_IntSet(file,"Warns",PlayerInfo[playerid][pWarns]); dini_IntSet(file,"Fleader",PlayerInfo[playerid][pFleader]); dini_IntSet(file,"Fmember",PlayerInfo[playerid][pFmember]); dini_IntSet(file,"Bank",PlayerInfo[playerid][pBank]); dini_IntSet(file,"Prods",PlayerInfo[playerid][pProds]); dini_IntSet(file,"Skin",GetPlayerSkin(playerid)); dini_IntSet(file,"RepairOffer",PlayerInfo[playerid][pRepairOffer]); dini_IntSet(file,"Credit",PlayerInfo[playerid][pCredit]); } gPlayerLogged[playerid] = 0; return 1; }
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if (dialogid == 1) { new name[MAX_PLAYER_NAME], file[256], string[131]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Earth RolePlay", "ServerName:: Earth-RolePlay\tIP::~~~~~\nIt seems like you are not registered, type your password to continue.", "Register", "Cancel"); dini_Create(file); dini_IntSet(file, "Password", udb_hash(inputtext)); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0); dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500); dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0); dini_IntSet(file, "Job",PlayerInfo[playerid][pJob] = 0); dini_IntSet(file, "Color",PlayerInfo[playerid][pColor] = 0); dini_IntSet(file, "Vw",PlayerInfo[playerid][pVw] = 0); dini_IntSet(file, "Int",PlayerInfo[playerid][pInt] = 0); dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 0); dini_IntSet(file, "Fleader",PlayerInfo[playerid][pFleader] = 0); dini_IntSet(file, "Fmember",PlayerInfo[playerid][pFmember] = 0); dini_IntSet(file, "Bank",PlayerInfo[playerid][pBank] = 0); dini_IntSet(file, "Prods",PlayerInfo[playerid][pProds] = 0); dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0); dini_IntSet(file, "RepairOffer",PlayerInfo[playerid][pRepairOffer] = 0); dini_IntSet(file, "Credit",PlayerInfo[playerid][pCredit] = 0); format(string, 131, "You succesfully registered the name %s with password %s, you have been auto logged in.", name, inputtext); SendClientMessage(playerid, COLOR_WHITE, string); gPlayerLogged[playerid] = 1; } if (dialogid == 3) { new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Earth RolePlay", "ServerName:: Earth-RolePlay\tIP::~~~~~\nIt seems like you are not registered, type your password to continue.", "Register", "Cancel"); new tmp; tmp = dini_Int(file, "Password"); if(udb_hash(inputtext) != tmp) { SendClientMessage(playerid, COLOR_RED, "Wrong Password, try again."); ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Earth RolePlay", "ServerName:: Earth-RolePlay\tIP::~~~~~\nType in your password correctly to continue.", "Login", "Cancel"); } else { gPlayerLogged[playerid] = 1; PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel"); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid)); SendClientMessage(playerid,COLOR_RED, "Successfully logged in!"); } } return 1; }