SA-MP Forums Archive
Pawno has stopped working.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pawno has stopped working.. (/showthread.php?tid=230133)



Pawno has stopped working.. - Snipa - 22.02.2011

Код:
if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128], buf[129];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{CCFFDD}You are registered", "{CCFFDD}Type your  password below", "{FF6347}Login", "{FF6347}Quit");
        WP_Hash(buf,sizeof(buf),(inputtext));
        new INI:Acc = INI_Open(file);
        INI_WriteString(Acc,"Password", buf);
        INI_WriteInt(Acc,"Regged",1);
        INI_WriteInt(Acc,"Level",0);
        INI_WriteInt(Acc,"Score",0);
        INI_WriteInt(Acc,"Cash",0);
        INI_Close(Acc);
        format(string,sizeof(string),"You have successfully registered with the password: %s", inputtext);
        SendClientMessage(playerid, limegreen, string);
        PInfo[playerid][Regged] = 1;
	}
	
	if(dialogid == 2)
	{
	    new name[MAX_PLAYER_NAME], file[256], string[128];
	    GetPlayerName(playerid,name,sizeof(name));
	    format(file,sizeof(file),SERVER_USER_FILE, name);
	    if(!response) return Kick(playerid);
	    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
	    new tmp;
	    tmp = INI_Int(file, "Password");
	    if(WP_Hash(inputtext) = !tmp) {
	        SendClientMessage(playerid,red,"ERROR: Wrong Password!");
	        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
		}
		else
		{
		    PInfo[playerid][Logged] = 1;
		    PInfo[playerid][Level] = INI_Int(file,"Level");
		    SetPlayerScore(playerid,PInfo[playerid][Score]);
		    GivePlayerMoney(playerid,PInfo[playerid][Cash]);
		    SendClientMessage(playerid,limegreen,"You have successfully logged in!");
	}
That is what I added last, and now pawno crashes whenever I try to compile? Help...


Re: Pawno has stopped working.. - Hashski - 22.02.2011

If you idented your code you'd know whats wrong.
Fixed, Anyways..
Код:
if (dialogid == 1)
{
	new name[MAX_PLAYER_NAME], file[256], string[128], buf[129];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), SERVER_USER_FILE, name);
	if(!response) return Kick(playerid);
	if (!strlen(inputtext)) return
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{CCFFDD}You are registered", "{CCFFDD}Type your       password below", "{FF6347}Login", "{FF6347}Quit");
	WP_Hash(buf,sizeof(buf),(inputtext));
 	new INI:Acc = INI_Open(file);
 	INI_WriteString(Acc,"Password", buf);
 	INI_WriteInt(Acc,"Regged",1);
 	INI_WriteInt(Acc,"Level",0);
 	INI_WriteInt(Acc,"Score",0);
        INI_WriteInt(Acc,"Cash",0);
 	INI_Close(Acc);
 	format(string,sizeof(string),"You have successfully registered with the password: %s", inputtext);
 	SendClientMessage(playerid, limegreen, string);
 	PInfo[playerid][Regged] = 1;
}
if(dialogid == 2)
{
	new name[MAX_PLAYER_NAME], file[256], string[128];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),SERVER_USER_FILE, name);
	if(!response) return Kick(playerid);
	if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
	new tmp;
	tmp = INI_Int(file, "Password");
	if(WP_Hash(inputtext) = !tmp) {
	SendClientMessage(playerid,red,"ERROR: Wrong Password!");
	ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
	}
	else
	{
 	    PInfo[playerid][Logged] = 1;
	    PInfo[playerid][Level] = INI_Int(file,"Level");
	    SetPlayerScore(playerid,PInfo[playerid][Score]);
	    GivePlayerMoney(playerid,PInfo[playerid][Cash]);
	    SendClientMessage(playerid,limegreen,"You have successfully logged in!");
	}
}



Re: Pawno has stopped working.. - Snipa - 23.02.2011

Quote:
Originally Posted by Hashski
Посмотреть сообщение
If you idented your code you'd know whats wrong.
Fixed, Anyways..
Код:
if (dialogid == 1)
{
	new name[MAX_PLAYER_NAME], file[256], string[128], buf[129];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), SERVER_USER_FILE, name);
	if(!response) return Kick(playerid);
	if (!strlen(inputtext)) return
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{CCFFDD}You are registered", "{CCFFDD}Type your       password below", "{FF6347}Login", "{FF6347}Quit");
	WP_Hash(buf,sizeof(buf),(inputtext));
 	new INI:Acc = INI_Open(file);
 	INI_WriteString(Acc,"Password", buf);
 	INI_WriteInt(Acc,"Regged",1);
 	INI_WriteInt(Acc,"Level",0);
 	INI_WriteInt(Acc,"Score",0);
        INI_WriteInt(Acc,"Cash",0);
 	INI_Close(Acc);
 	format(string,sizeof(string),"You have successfully registered with the password: %s", inputtext);
 	SendClientMessage(playerid, limegreen, string);
 	PInfo[playerid][Regged] = 1;
}
if(dialogid == 2)
{
	new name[MAX_PLAYER_NAME], file[256], string[128];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),SERVER_USER_FILE, name);
	if(!response) return Kick(playerid);
	if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
	new tmp;
	tmp = INI_Int(file, "Password");
	if(WP_Hash(inputtext) = !tmp) {
	SendClientMessage(playerid,red,"ERROR: Wrong Password!");
	ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
	}
	else
	{
 	    PInfo[playerid][Logged] = 1;
	    PInfo[playerid][Level] = INI_Int(file,"Level");
	    SetPlayerScore(playerid,PInfo[playerid][Score]);
	    GivePlayerMoney(playerid,PInfo[playerid][Cash]);
	    SendClientMessage(playerid,limegreen,"You have successfully logged in!");
	}
}
Blame the forums. I had everything indented.


Re: Pawno has stopped working.. - Hashski - 23.02.2011

Okay, but it works now?


Re: Pawno has stopped working.. - Snipa - 23.02.2011

No, still says it has stopped working.

When I take it out + compile, it works fine. So what's up with it?


Re: Pawno has stopped working.. - Serbish - 23.02.2011

Put both dialogs separated (once the first dialog only, after it the second dialog only) in the script to see which one of both crashes pawno.


Re: Pawno has stopped working.. - Snipa - 23.02.2011

Quote:
Originally Posted by Serbish
Посмотреть сообщение
Put both dialogs separated (once the first dialog only, after it the second dialog only) in the script to see which one of both crashes pawno.
Second dialog causes it to crash.


Re: Pawno has stopped working.. - Serbish - 23.02.2011

pawn Код:
if(dialogid == 1)
{
    new name[MAX_PLAYER_NAME], file[256], string[128], buf[129];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(!response) return Kick(playerid);
    if (!strlen(inputtext)) return
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{CCFFDD}You are registered", "{CCFFDD}Type your  password below", "{FF6347}Login", "{FF6347}Quit");
    WP_Hash(buf,sizeof(buf),(inputtext));
    new INI:Acc = INI_Open(file);
    INI_WriteString(Acc,"Password", buf);
    INI_WriteInt(Acc,"Regged",1);
    INI_WriteInt(Acc,"Level",0);
    INI_WriteInt(Acc,"Score",0);
    INI_WriteInt(Acc,"Cash",0);
    INI_Close(Acc);
    format(string,sizeof(string),"You have successfully registered with the password: %s", inputtext);
    SendClientMessage(playerid, limegreen, string);
    PInfo[playerid][Regged] = 1;
}
else if(dialogid == 2)
{
    new name[MAX_PLAYER_NAME], file[256], tmp[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(file,sizeof(file),SERVER_USER_FILE, name);
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
    tmp = INI_Int(file, "Password");
    if(WP_Hash(inputtext) != tmp)
    {
        SendClientMessage(playerid,red,"ERROR: Wrong Password!");
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
    }
    else
    {
        PInfo[playerid][Logged] = 1;
        PInfo[playerid][Level] = INI_Int(file,"Level");
        SetPlayerScore(playerid,PInfo[playerid][Score]);
        GivePlayerMoney(playerid,PInfo[playerid][Cash]);
        SendClientMessage(playerid,limegreen,"You have successfully logged in!");
    }
}
Well, I changed some stuff in the code.


Re: Pawno has stopped working.. - Snipa - 23.02.2011

Quote:
Originally Posted by Serbish
Посмотреть сообщение
pawn Код:
if(dialogid == 1)
{
    new name[MAX_PLAYER_NAME], file[256], string[128], buf[129];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(!response) return Kick(playerid);
    if (!strlen(inputtext)) return
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{CCFFDD}You are registered", "{CCFFDD}Type your  password below", "{FF6347}Login", "{FF6347}Quit");
    WP_Hash(buf,sizeof(buf),(inputtext));
    new INI:Acc = INI_Open(file);
    INI_WriteString(Acc,"Password", buf);
    INI_WriteInt(Acc,"Regged",1);
    INI_WriteInt(Acc,"Level",0);
    INI_WriteInt(Acc,"Score",0);
    INI_WriteInt(Acc,"Cash",0);
    INI_Close(Acc);
    format(string,sizeof(string),"You have successfully registered with the password: %s", inputtext);
    SendClientMessage(playerid, limegreen, string);
    PInfo[playerid][Regged] = 1;
}
else if(dialogid == 2)
{
    new name[MAX_PLAYER_NAME], file[256], tmp[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(file,sizeof(file),SERVER_USER_FILE, name);
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
    tmp = INI_Int(file, "Password");
    if(WP_Hash(inputtext) != tmp)
    {
        SendClientMessage(playerid,red,"ERROR: Wrong Password!");
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
    }
    else
    {
        PInfo[playerid][Logged] = 1;
        PInfo[playerid][Level] = INI_Int(file,"Level");
        SetPlayerScore(playerid,PInfo[playerid][Score]);
        GivePlayerMoney(playerid,PInfo[playerid][Cash]);
        SendClientMessage(playerid,limegreen,"You have successfully logged in!");
    }
}
Well, I changed some stuff in the code.
Doesn't help, still crashes.


Re: Pawno has stopped working.. - leong124 - 23.02.2011

You must use strcmp to compare strings...
Also you used WP_Hash wrongly...
pawn Код:
if(WP_Hash(inputtext) != tmp)//Wrong
pawn Код:
new buffer[129];
WP_Hash(buffer,sizeof(buffer),inputtext);
//.....
if(strcmp(buffer,tmp,false))//No need to be case insensitive because Whirlpool always outputs capital characters.This can make the check faster.
//...
Second,shouldn't the password be a string?
pawn Код:
new tmp;//:/
tmp = INI_Int(file, "Password");//Use the function to read string
Also, in the first post I found that you missed a closing brace.
pawn Код:
else if(dialogid == 2)//Using else if is faster,as it doesn't need to check the dialogid again when dialogid is 1.
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        new tmp;
        tmp = INI_Int(file, "Password");
        if(WP_Hash(inputtext) = !tmp) {
            SendClientMessage(playerid,red,"ERROR: Wrong Password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        }
        else
        {
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Level] = INI_Int(file,"Level");
            SetPlayerScore(playerid,PInfo[playerid][Score]);
            GivePlayerMoney(playerid,PInfo[playerid][Cash]);
            SendClientMessage(playerid,limegreen,"You have successfully logged in!");
        }//Here
    }