Password system bug
#1

Код:
	new password[128], sex[6], varsta;
	switch(dialogid)
	{
	    case dialog_register:
	    {
	        if(!response) Kick(playerid);
	        else
	            SendClientMessage(playerid, 0xFFFFFF, "Mai intai sa verificam parola"),
				format(password, sizeof(password), "%s", inputtext),
				ShowPlayerDialog(playerid, dialog_register_check, DIALOG_STYLE_PASSWORD, "REGISTER", "Acum, pentru a verifica ca tii minte parola scri-o mai jos", "Gata", "RESCRIE");
	    }
	    case dialog_register_check:
	    {
	        if(!response) ShowPlayerDialog(playerid, dialog_register, DIALOG_STYLE_PASSWORD, "Register", "Scrie parola pe care o vrei:", "Gata", "Kick");
	        else
	            if(strcmp(password, inputtext))
					SendClientMessage(playerid, 0xFFFFFF, "Felicitari, acum ai parola setata"),
					ShowPlayerDialog(playerid, dialog_sex, DIALOG_STYLE_MSGBOX, "REGISTER", "Ce sex esti?", "Baiat", "Fata");
				else
                    ShowPlayerDialog(playerid, dialog_register, DIALOG_STYLE_PASSWORD, "Register", "Scrie parola pe care o vrei:", "Gata", "Kick");
	    }
So i did like that, but when I enter in game, and try my luck, the verify pass part dont work, so I think I did something wrong...
Reply
#2

check strcmp at line
PHP код:
if(strcmp(passwordinputtext)) 
https://sampwiki.blast.hk/wiki/Strcmp

see example and return value

PHP код:
// Check if the strings are the same
if(!strcmp(string1string2)) 
Reply
#3

Now, it works, but at verify it's working with any password... but I want to check if the password is the same.

Quote:

format(password, sizeof(password), "%s", inputtext),

Here, I a have a better option?


Код:
	    case dialog_varsta:
	    {
			if(!response) Kick(playerid);
			else
			{
			    varsta = strval(inputtext);
			    if(varsta > 6)
			    {
			    	SendClientMessage(playerid, 0xFFFFFF, "Multi inainte! Bine ai venit!");
			    	dini_Create(path(playerid));
			    	dini_Set(path(playerid), "pass", password);
			    	dini_Set(path(playerid), "sex", sex);
			    	dini_IntSet(path(playerid), "varsta", varsta);
			    	dini_IntSet(path(playerid), "cash", 1000);
			    	dini_IntSet(path(playerid), "banca", 1000);
			    	dini_IntSet(path(playerid), "admin", 0);
			    }
			    else
			    {
			        SendClientMessage(playerid, 0xFFFFFF, "... HAI SA FIM SERIOSI!");
			        Kick(playerid);
			    }
			}
}
and it's not write anything at sex and pass... why?
Reply
#4

Quote:
Originally Posted by POL_george
Посмотреть сообщение
Now, it works, but at verify it's working with any password... but I want to check if the password is the same.

Here, I a have a better option?
cause new password[128] is not a global var

so when callback ondialogrespon again it's not you format

https://sampwiki.blast.hk/wiki/Scripting_Basics
https://sampwiki.blast.hk/wiki/Scripting_Basics#global
Reply
#5

Код:
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(248 -- 249) : error 001: expected token: "]", but found "-identifier-"
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(249) : warning 217: loose indentation
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(249) : warning 215: expression has no effect
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(249) : error 001: expected token: ";", but found "]"
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(249) : error 029: invalid expression, assumed zero
C:\Users\bpocn\Desktop\sa\server\gamemodes\Gm2.pwn(249) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
where I defined my passwordthis is at the beggining of the script)
Код:
new pPass[MAX_PLAYERS][128];
249:
Код:
format(pPass[playerid], sizeof(pPass[playerid]), "%s", inputtext),
248
Код:
SendClientMessage(playerid, 0xFFFFFF, "Mai intai sa verificam parola"),
Reply
#6

you cant use
Quote:

sizeof(pPass[playerid])

try
Quote:

format(pPass[playerid], 128, "%s", inputtext),

Reply
#7

ok, thanks that worked
Reply
#8

Just an advice: use strcat instead of format (e.g strcat(pPass[playerid], inputtext)).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)