[SOLVED]User's Data Problem -
Armageddonz - 07.06.2015
I have a problem with user's database..when i try to open user's data in scriptfiles\Users it just empty in there...but after register..the system save my password and i can login ... i use this
https://sampforum.blast.hk/showthread.php?tid=352703 and
https://sampforum.blast.hk/showthread.php?tid=273088 tutorial but either of them have the same problem..
actually when i compile the code..i get this warning
Код:
C:\Users\Armageddon\Desktop\Samp Server\gamemodes\Gamemode.pwn(118) : warning 217: loose indentation
C:\Users\Armageddon\Desktop\Samp Server\gamemodes\Gamemode.pwn(122) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Warnings.
here's my whole code :
http://pastebin.com/6uXZmPr5
i hope u can help me
Re: User's Data Problem -
Yashas - 07.06.2015
You get this warning "warning 217: loose indentation" if you do not indent your code properly
This will give that warning
Код:
if(a)
{
for(new i;i <10;i++)
{
}
}
but this won't
Код:
if(a)
{
for(new i;i <10;i++)
{
}
}
This
Код:
if(!strlen(inputtext))
can be replaced with
Код:
if (inputtext[0] == 0 || (inputtext[0] == 1 && inputtext[1] == 0))
Try updating YSI.I can't find anything wrong in your register code.
Код:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Password",hashpass);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Vip",0);
INI_Close(File);
Re: User's Data Problem -
Armageddonz - 07.06.2015
thank you very much Yashas..I really appreciate it
Re: User's Data Problem -
Armageddonz - 07.06.2015
But can you fix the warning(already stated below)..i try to fix the warning with your guide but it still persist..
line 118
line 122
whole code
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(inputtext[0] == 0 || (inputtext[0] == 1 && inputtext[1] == 0)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Password",hashpass);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Vip",0);
INI_Close(File);
new string[256], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format( string, sizeof(string), "Welcome To {CCFF33}Cyber {66CCFF}Malaysian {FFCC99}Army, {FF6600}%s{FFFFFF}", pname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, PlayerInfo[playerid][pPass], false))
{
new string[256], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
format( string, sizeof(string), "Welcome Back, {FF6600}%s{FFFFFF}", pname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
SendClientMessageToAll( -1, szStr);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
Re: User's Data Problem -
Armageddonz - 07.06.2015
ok solved
Re: User's Data Problem -
Yashas - 07.06.2015
Код:
#define CLIENT_MESSAGE_MAX_LENGTH 144 //144 is the maximum length of a client message
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(inputtext[0] == 0 || (inputtext[0] == 1 && inputtext[1] == 0)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.nType your password below to register a new account.","Register","Quit");
new string[CLIENT_MESSAGE_MAX_LENGTH];
WP_Hash(string,sizeof(string),inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Password",string);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Vip",0);
INI_Close(File);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format( string, sizeof(string), "Welcome To{CCFF33} Cyber{66CCFF} Malaysian{FFCC99} Army, {FF6600}%s", pname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new string[CLIENT_MESSAGE_MAX_LENGTH];
WP_Hash(string,sizeof(string),inputtext);
if(!strcmp(string, PlayerInfo[playerid][pPass], false))
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
format( string, sizeof(string), "Welcome Back, {FF6600}%s",pname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
SendClientMessageToAll( -1, szStr); //What is szStr?
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.nType your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}