dcmd_register(playerid, params[]) { new file[256], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); format(file, sizeof(file), "%s.ini", pName); if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/register [Password]"); if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are already registered!"); dini_Create(file); dini_IntSet(file, "HashPW", udb_hash(params)); dini_IntSet(file, "Admin", 0); dini_IntSet(file, "Score", GetPlayerScore(playerid)); dini_IntSet(file, "Money", GetPlayerMoney(playerid)); new string[128]; format(string, sizeof(string), "You succesfully registered the nickname %s", pName); SendClientMessage(playerid, COLOR_YELLOW, string); IsPlayerLoggedIn[playerid] = 1; SendClientMessage(playerid, COLOR_YELLOW, "You have been automatically Logged in!"); return true; }
dcmd_login(playerid, params[]) { new file[256]; new string[128], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); format(file, sizeof(string), "%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(IsPlayerLoggedIn[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, sizeof(string), "You specified the wrong Password for %s!", pName); SendClientMessage(playerid, COLOR_RED, string); } else { IsPlayerLoggedIn[playerid] = 1; IsPlayerAdminX[playerid] = dini_Int(file, "Admin"); GivePlayerMoney(playerid,dini_Int(file, "Money")-GetPlayerMoney(playerid)); SetPlayerScore(playerid,dini_Int(file, "Score")-GetPlayerScore(playerid)); SendClientMessage(playerid, COLOR_GREEN, "You have succesfully Logged in!"); printf("%s (%i) Logged in.", pName, playerid); } return true; }
public OnPlayerDisconnect(playerid, reason) { new pName[MAX_PLAYER_NAME], string[128], file[256]; format(file, sizeof(file), "%s.ini", pName); if (IsPlayerLoggedIn[playerid]) { dini_IntSet(file, "Score", GetPlayerScore(playerid)); dini_IntSet(file, "Money", GetPlayerMoney(playerid)); } GetPlayerName(playerid, pName, sizeof(pName)); switch(reason) { case 0: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Lost Connection)", pName); case 1: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Leaving)", pName); case 2: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Kicked/Banned)", pName); } SendClientMessageToAll(COLOR_RED, string); printf(string); return true; }
Originally Posted by Mikkel
What do you mean 'Encode'?.
|
Originally Posted by DracoBlue
First let's track down the issue.
Do you get any of the messages you made when doing /register? Are there any *.ini-files in your scriptfiles folder? - Draco |
Originally Posted by Pandabeer1337
i know the problem, you used a variable (pName[MAX_PLAYERS]
![]() ![]() |
Originally Posted by Mikkel
when you log off it doesnt save anything, and when you try to connect to the server, it says you are already logged in, it's quite a fatal error due to the fact i forced every client to log off at OnPlayerDisconnect, even tho i did that, it still says it's already logged in.
|
public OnPlayerDisconnect(playerid, reason)
{
........
if (IsPlayerLoggedIn[playerid])
{
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
}
IsPlayerLoggedIn[playerid]=0; // IsPlayerLoggedIn[playerid]=false ?!
}