24.04.2011, 09:41
This is my code for saving some things and logging in/registering. When I login, i read from the file, and the SKIN applies, BUT it does NOT save to that file... What am I doing wrong
Код:
dcmd_login(playerid, params[]) { new file[256]; new string[256], pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(string), "\\Users\\%s.ini", pname); if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /login [password]"); if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered!"); //if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already logged in!"); new tmp[256]; tmp = dini_Get(file, "hashPW"); if(udb_hash(params) != strval(tmp)) { format(string, 256, "You specified the wrong password for %s!", pname); SendClientMessage(playerid, COLOR_RED, string); } else { logged[playerid] = 1; SetPlayerSkin(playerid, dini_Int(file, "skin")-SetPlayerSkin(playerid)); SetPlayerSkin(playerid, dini_Int(file, "score")-SetPlayerSkin(playerid)); TogglePlayerControllable(playerid,1); GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid)); SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!"); printf("%s (%i) logged in with password %s", pname, playerid, params); } return 1; } /* Ok, this script, like in the /register command, creates the "file" variable to store the file path, a "string" for the messages, and "pname" to store the player's name. Then some basic if() statements to check if the player is registered, logged in or there are no params. Then it creates a variable "tmp" to store the hashed version of the password. Then it hashes the player's inputted password and checks if the two passwords match, if they do, logs the player in, sets the "level" variable to the level, their score to the score and their money to the money in the player's stats file! */ public OnPlayerDisconnect(playerid, reason) { new file[256]; new string[256], pname[MAX_PLAYER_NAME]; dini_IntSet(file, "skin", GetPlayerSkin(playerid)); dini_IntSet(file, "score", GetPlayerSkin(playerid)); dini_IntSet(file, "money", GetPlayerMoney(playerid)); KillTimer( PlayerInfo[playerid][SpawnTimer] ); logged[playerid] = 0; return 1; }