SA-MP Forums Archive
Registration/login bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Registration/login bug (/showthread.php?tid=582814)



Registration/login bug - Deny1 - 23.07.2015

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"reg",""COL_WHITE"bad pass.\n"COL_WHITE"type pass to reg.","reg","exit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Age",0);
INI_WriteInt(File,"Sex",2);
INI_WriteInt(File,"Skin",0);
INI_WriteInt(File,"Location",0);
INI_Close(File);

ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT,"Age?","\nType age using numbers.","ok","");
}
}
case DIALOG_AGE:
{
if(!response) return Kick(playerid);
if(response)
{
new age, message[64];

age = strval(inputtext);
if(age < 13 || age > 70)
{
ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT,"Age?","Type age using numbers.","Ok","");
SendClientMessage(playerid, 0x33CCFFAA, "at least 13 years!");
}
else
{
PlayerInfo[playerid][pAge] = age;
SendClientMessage(playerid, 0x33CCFFAA, message);
ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST,"male or female","male\nfemale","Ok","");
}
}
}
case DIALOG_SEX:
{
if(response)
{
if(listitem == 0)
{
PlayerInfo[playerid][pSex] = 0;
PlayerInfo[playerid][pSkin] = 20;
printf("Skin has been set to 20");
ShowPlayerDialog(playerid, DIALOG_LOCATION, DIALOG_STYLE_LIST,"spawn","LS ","OK","");
}
if(listitem == 1)
{
PlayerInfo[playerid][pSex] = 1;
PlayerInfo[playerid][pSkin] = 12;
printf("Skin has been set to 12");
ShowPlayerDialog(playerid, DIALOG_LOCATION, DIALOG_STYLE_LIST,"SPAWN","LOS SANTOS","OK","");
}
}
}
case DIALOG_LOCATION:
{
if(!response) return Kick(playerid);
if(response)
{
new message[64];
if(listitem == 0)
{
PlayerInfo[playerid][pLocation] = 0;
format(message, sizeof(message), "MSG");
SendClientMessage(playerid, 0xFFFFFFFF, message);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1713.6101,-1912.2190,13.5669,85.9081, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
if(listitem == 1)
{
PlayerInfo[playerid][pLocation] = 1;
format(message, sizeof(message), "MSG");
SendClientMessage(playerid, 0xFFFFFFFF, message);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
if(listitem == 2)
{
PlayerInfo[playerid][pLocation] = 2;
format(message, sizeof(message), "MSG");
SendClientMessage(playerid, 0xFFFFFFFF, message);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
Kick(playerid);
}
return 1;
}
}
}
return 1;
}
this is my reg log system i made some change couse every time i'm in game i can regist.
so i add something on register text draw to stop that..and i add that but now every time i click on regist. and i go relog my account was deleted....

if(clickedid == reglog7)
{
if(fexist(UserPath(playerid))) return ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_MSGBOX, "error", "you are alredy regisred!", "ok", ""); // i put this
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"REG!","\nWLC TO OUR SERVER\n{FFFFFF}enjoy\n{FFFFFF}Forum {FFFFFF}www.comingsoon.com\nEnjoy!","Reg","exit");
TextDrawHideForPlayer(playerid, reglog0);
TextDrawHideForPlayer(playerid, reglog1);
TextDrawHideForPlayer(playerid, reglog2);
TextDrawHideForPlayer(playerid, reglog3);
TextDrawHideForPlayer(playerid, reglog4);
TextDrawHideForPlayer(playerid, reglog5);
TextDrawHideForPlayer(playerid, reglog6);
TextDrawHideForPlayer(playerid, reglog7);
}


Re: Registration/login bug - Deny1 - 23.07.2015

?? can somebody help me


Re: Registration/login bug - xVIP3Rx - 23.07.2015

Does it say you're already registered ?

also try to check for an invalid address or so by adding this
pawn Код:
// Check the file opened correctly
if (myFile != INI_NO_FILE)



Re: Registration/login bug - Deny1 - 23.07.2015

What do you mean with if (myFile != INI_NO_FILE) ? look when i click on td to register then showe me dialog you are alredy reged. but when i go relog my account was deleted i use this under that text draw
Quote:

if(fexist(UserPath(playerid))) return ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_MSGBOX, "error", "you are alredy regisred!", "ok", "");




Re: Registration/login bug - xVIP3Rx - 23.07.2015

Okay, when you logout or register does the file show up in the "UserPath" you defined ?, meaning somewhere in your script-files ?


Re: Registration/login bug - Deny1 - 23.07.2015

yes it shows but now when i click on reg and if exist account and i go exit everything is set to 0


Re: Registration/login bug - Deny1 - 23.07.2015

i have defined path


Re: Registration/login bug - Deny1 - 23.07.2015

Код:
[data]
Location = 0
Skin = 20
Sex = 0
Age = 18
Admin = 0
Cash = 0
Password = 19726487
like this


Re: Registration/login bug - xVIP3Rx - 23.07.2015

Show me your onplayerconnect and disconnect, and onplayerrequestclass too if you have anything under it.


Re: Registration/login bug - Deny1 - 23.07.2015

Under onplayerdisconnect
Код:
 new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Location", PlayerInfo[playerid][pLocation]);
    INI_Close(File);
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Sex", PlayerInfo[playerid][pSex]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Int("Skin", PlayerInfo[playerid][pSkin]);
    INI_Int("Location", PlayerInfo[playerid][pLocation]);
    return 1;
}