24.06.2011, 11:55
Код:
if(dialogid == 1) { new name[MAX_PLAYER_NAME], file[256], string[128]; 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, "Register", "Welcome, your not registered, please fill in a password", "Register", "Leave"); if(!fexist(file)) dini_Create(file); dini_IntSet(file, "Password", udb_hash(inputtext)); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0); dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0); dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0); dini_IntSet(file, "Gender",PlayerInfo[playerid][pGender] = 0); dini_IntSet(file, "Age", PlayerInfo[playerid][pAge] = 0); SpawnPlayer(playerid); SetCameraBehindPlayer(playerid); format(String, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", Name, inputtext); SendClientMessage(playerid, COLOR_GREEN, String); gPlayerLogged[playerid] = 1; ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "_", "Welcome to Infinity Roleplay.\nBefore you can play and have fun with our players,\nwe have to ask you a few questions.", "Continue",""); } if (dialogid == 2) { new name[MAX_PLAYER_NAME], file[256], string[128]; 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, "Login", "You're already registered, please login.", "Login", "Leave"); new tmp; tmp = dini_Int(file, "Password"); if(udb_hash(inputtext) != tmp) { SendClientMessage(playerid, COLOR_RED, "Wrong password"); ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave"); } else { gPlayerLogged[playerid] = 1; PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel"); PlayerInfo[playerid][pScore] = dini_Int(file, "Score"); PlayerInfo[playerid][pCash] = dini_Int(file, "Money"); PlayerInfo[playerid][pGender] = dini_Int(file, "Gender"); PlayerInfo[playerid][pAge] = dini_Int(file, "Age"); Save[playerid] = SetTimerEx("SaveStats",1000,true,"i",playerid); SendClientMessage(playerid,COLOR_GREEN, "Successfully logged in!"); SpawnPlayer(playerid); SetCameraBehindPlayer(playerid); } }
pawn Код:
#define SERVER_USER_FILE "myserver/%s.ini"
OnPlayerDisconect
Код:
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][pAdminLevel]); dini_IntSet(file, "Gender", PlayerInfo[playerid][pGender]); dini_IntSet(file, "Age", PlayerInfo[playerid][pAge]); } gPlayerLogged[playerid] = 0;