[Player's Data] Password = ECC629F3F55BBC3AEE0E3DD15E8D25AB138F3DB6B636BC6266EE914F074666A42499CE75DADF28DAE64E897F4C1A3C9D1C4DEDBE43A5466A6F4328AEB2198EE2 Score = 1 Cash = 999999499 Admin = 6 VIP = 2 Kills = 0 Deaths = 14 Wanted Level = 0 Moneybags = 1 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Banned = 0 AFK = 0
[Player's Data] Password = ECC629F3F55BBC3AEE0E3DD15E8D25AB138F3DB6B636BC6266EE914F074666A42499CE75DADF28DAE64E897F4C1A3C9D1C4DEDBE43A5466A6F4328AEB2198EE2 Score = 1 Cash = 999999499 Admin = 6 VIP = 2 Kills = 0 Deaths = 14 Wanted Level = 0 Moneybags = 1 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Banned = 0 AFK = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 1 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 1 Total Bans = 1 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 1 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 3 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 1 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 1 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 1 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0 Wanted Level = 0 Reaction Tests = 0 Math Tests = 0 Total Warnings = 0 Total Kicks = 0 Total Bans = 0
|
Do not use special characters or spaces in tags. I would recommend sticking to the lowercase Latin alphabet only.
|
|
i didnt really get all u said but how would getting rid of the spaces in tags or special characters or lowercases solve the problem ? do they really affect the scripts generally ?
|
enum pInfo
{
pPass[129],
pScore,
pCash,
pAdmin,
AFKstatus,
pVIP,
pKills,
pDeaths,
pWantedLvl,
pMoneybag,
pReactionTest,
pMathTest,
pMuted,
pJailed,
pWarnings,
pKicks,
pBans,
pBanned
}
new PlayerInfo[MAX_PLAYERS][pInfo];
if(fexist(Path(playerid)))
{
new INI:File = INI_Open(Path(playerid));
INI_SetTag(File,"Player's Data");
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"AFK",PlayerInfo[playerid][AFKstatus]);
INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Wanted Level",GetPlayerWantedLevel(playerid));
INI_WriteInt(File,"Moneybags",PlayerInfo[playerid][pMoneybag]);
INI_WriteInt(File,"Reaction Tests",PlayerInfo[playerid][pReactionTest]);
INI_WriteInt(File,"Math Tests",PlayerInfo[playerid][pMathTest]);
INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
INI_WriteInt(File,"Total Warnings",PlayerInfo[playerid][pWarnings]);
INI_WriteInt(File,"Total Kicks",PlayerInfo[playerid][pKicks]);
INI_WriteInt(File,"Total Bans",PlayerInfo[playerid][pBans]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_Close(File);
}
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password",PlayerInfo[playerid][pPass],129);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("AFK",PlayerInfo[playerid][AFKstatus]);
INI_Int("VIP",PlayerInfo[playerid][pVIP]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Wanted Level",PlayerInfo[playerid][pWantedLvl]);
INI_Int("Moneybags",PlayerInfo[playerid][pMoneybag]);
INI_Int("Reaction Tests",PlayerInfo[playerid][pReactionTest]);
INI_Int("Math Tests",PlayerInfo[playerid][pMathTest]);
INI_Int("Muted",PlayerInfo[playerid][pMuted]);
INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
INI_Int("Total Warnings",PlayerInfo[playerid][pWarnings]);
INI_Int("Total Kicks",PlayerInfo[playerid][pKicks]);
INI_Int("Total Bans",PlayerInfo[playerid][pBans]);
INI_Int("Banned",PlayerInfo[playerid][pBanned]);
return 1;
}
if(dialogid == dregister)
{
if(!response) return 1;
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Enter your password below to create a new account.","Register","Quit");
return 1;
}
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:File = INI_Open(Path(playerid));
INI_SetTag(File,"Player's Data");
INI_WriteString(File,"Password",hashpass);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"AFK",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Wanted Level",0);
INI_WriteInt(File,"Moneybags",0);
INI_WriteInt(File,"Reaction Tests",0);
INI_WriteInt(File,"Math Tests",0);
INI_WriteInt(File,"Muted",0);
INI_WriteInt(File,"Jailed",0);
INI_WriteInt(File,"Total Warnings",0);
INI_WriteInt(File,"Total Kicks",0);
INI_WriteInt(File,"Total Bans",0);
INI_WriteInt(File,"Banned",0);
INI_Close(File);
SendClientMessage(playerid,COLOR_YELLOW,"INFO: You have been successfully registered.");
GivePlayerMoney(playerid,50000);
return 1;
}
}
if(dialogid == dlogin)
{
if(!response) return Kick(playerid);
if(response)
{
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(strcmp(hashpass, PlayerInfo[playerid][pPass], false))
{
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Invalid Password. \nWrite your password please.","Login","Quit");
}
else
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
SetPlayerWantedLevel(playerid,PlayerInfo[playerid][pWantedLvl]);
SetPVarInt(playerid,"VIP",PlayerInfo[playerid][pVIP]);
SetPVarInt(playerid,"Admin",PlayerInfo[playerid][pAdmin]);
if(PlayerInfo[playerid][pJailed]!=0)
{
}
SendClientMessage(playerid,COLOR_YELLOW,"INFO: You have successfully logged in.");
}
}
}
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),Userpath,name);
return str;
}
// [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
#include <YSI\y_ini>
// NATIVES:
// WHIRLPOOL:
native WP_Hash(buffer[], len, const str[]);
// UNDEFINES:
#undef isnull
// DEFINES:
// FUNCTIONS:
#define function%0(%1) forward%0(%1); public%0(%1)
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
// DIALOGS:
#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1
// DATABASE:
#define USER_TAG "player_data"
#define USER_PASSWORD "password"
#define USER_SCORE "score"
#define USER_CASH "cash"
#define USER_KILLS "kills"
#define USER_DEATHS "deaths"
#define USER_VIP_LEVEL "vip_level"
#define USER_ADMIN_LEVEL "admin_level"
// ARRAYS AND ENUMERATORS:
enum eUserInfo
{
user_password[129],
user_score,
user_cash,
user_kills,
user_deaths,
user_vip_level,
user_admin_level
}
new aUserInfo[MAX_PLAYERS][eUserInfo];
// VARIABLES:
// STATES:
new bool:sSignedIn[MAX_PLAYERS] = false;
// MAIN:
main()
{
print("Development Mode: ini_login_system.amx");
}
// CALLBACKS:
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUserData", .bExtra = true, .extra = playerid);
ShowLoginDialog(playerid, "");
}
else ShowRegisterDialog(playerid, "");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(IsPlayerSignedIn(playerid))
{
new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file, USER_TAG);
INI_WriteInt(file, USER_SCORE, GetPlayerScore(playerid));
INI_WriteInt(file, USER_CASH, GetPlayerMoney(playerid));
INI_WriteInt(file, USER_KILLS, aUserInfo[playerid][user_kills]);
INI_WriteInt(file, USER_DEATHS, aUserInfo[playerid][user_deaths]);
INI_WriteInt(file, USER_VIP_LEVEL, aUserInfo[playerid][user_vip_level]);
INI_WriteInt(file, USER_ADMIN_LEVEL, aUserInfo[playerid][user_admin_level]);
INI_Close(file);
}
ResetPlayerVariables(playerid);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return KickPlayer(playerid);
if(response)
{
if(isnull(inputtext)) return ShowRegisterDialog(playerid, "Enter a password.");
new hash[129];
WP_Hash(hash, sizeof(hash), inputtext);
new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file, USER_TAG);
INI_WriteString(file, USER_PASSWORD, hash);
INI_WriteInt(file, USER_SCORE, 0);
INI_WriteInt(file, USER_CASH, 0);
INI_WriteInt(file, USER_KILLS, 0);
INI_WriteInt(file, USER_DEATHS, 0);
INI_WriteInt(file, USER_VIP_LEVEL, 0);
INI_WriteInt(file, USER_ADMIN_LEVEL, 0);
INI_Close(file);
sSignedIn[playerid] = true;
return SendClientMessage(playerid, -1, "You have successfully registered an account.");
}
}
case DIALOG_LOGIN:
{
if(!response) return KickPlayer(playerid);
if(response)
{
if(isnull(inputtext)) return ShowLoginDialog(playerid, "Enter a password.");
new hash[129];
WP_Hash(hash, sizeof(hash), inputtext);
if(strcmp(aUserInfo[playerid][user_password], hash, false) == 0)
{
INI_ParseFile(UserPath(playerid), "LoadUserData", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, aUserInfo[playerid][user_score]);
GivePlayerMoney(playerid, aUserInfo[playerid][user_cash]);
sSignedIn[playerid] = true;
return SendClientMessage(playerid, -1, "You have successfully logged into your account.");
}
else return ShowLoginDialog(playerid, "Incorrect password.");
}
}
}
return 1;
}
// FUNCTIONS:
stock ResetPlayerVariables(playerid)
{
// ARRAYS AND ENUMERATORS:
aUserInfo[playerid][user_password] = EOS;
aUserInfo[playerid][user_score] = 0;
aUserInfo[playerid][user_cash] = 0;
aUserInfo[playerid][user_kills] = 0;
aUserInfo[playerid][user_deaths] = 0;
aUserInfo[playerid][user_vip_level] = 0;
aUserInfo[playerid][user_admin_level] = 0;
// PER-PLAYER VARIABLES:
// STATES:
sSignedIn[playerid] = false;
return 1;
}
function LoadUserData(playerid, name[], value[])
{
INI_String(USER_PASSWORD, aUserInfo[playerid][user_password], 129);
INI_Int(USER_SCORE, aUserInfo[playerid][user_score]);
INI_Int(USER_CASH, aUserInfo[playerid][user_cash]);
INI_Int(USER_KILLS, aUserInfo[playerid][user_kills]);
INI_Int(USER_DEATHS, aUserInfo[playerid][user_deaths]);
INI_Int(USER_VIP_LEVEL, aUserInfo[playerid][user_vip_level]);
INI_Int(USER_ADMIN_LEVEL, aUserInfo[playerid][user_admin_level]);
return 1;
}
stock ShowRegisterDialog(playerid, error[])
{
new string[256];
strcat(string, "Welcome. This account is not registered.\n");
strcat(string, "Enter a password below to register an account.");
if(!isnull(error)) format(string, sizeof(string), "%s\n\n{FF0000}%s", string, error);
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", string, "Register", "Quit");
}
stock ShowLoginDialog(playerid, error[])
{
new string[256];
strcat(string, "Welcome back. This account is already registered.\n");
strcat(string, "Insert your password to log into your account.");
if(!isnull(error)) format(string, sizeof(string), "%s\n\n{FF0000}%s", string, error);
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", string, "Login", "Quit");
}
stock KickPlayer(playerid) return SetTimerEx("KickPlayerEx", 100, false, "i", playerid);
function KickPlayerEx(playerid) return Kick(playerid);
stock UserPath(playerid)
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "/Users/%s.ini", name);
return string;
}
function bool:IsPlayerSignedIn(playerid) return sSignedIn[playerid];