PDA

View Full Version : Password system bug


POL_george
27/11/2016, 09:29 AM
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...

Alvitr
27/11/2016, 09:36 AM
check strcmp at line
if(strcmp(password, inputtext))
https://wiki.sa-mp.com/wiki/Strcmp

see example and return value

// Check if the strings are the same
if(!strcmp(string1, string2))

POL_george
27/11/2016, 09:43 AM
Now, it works, but at verify it's working with any password... but I want to check if the password is the same.

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?

Alvitr
27/11/2016, 09:45 AM
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://wiki.sa-mp.com/wiki/Scripting_Basics
https://wiki.sa-mp.com/wiki/Scripting_Basics#global

POL_george
27/11/2016, 09:57 AM
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 (c) 1997-2006, ITB CompuPhase


4 Errors.

where I defined my password:(this 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"),

Alvitr
27/11/2016, 10:01 AM
you cant use sizeof(pPass[playerid])

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

POL_george
27/11/2016, 10:08 AM
ok, thanks that worked

GoldenLion
27/11/2016, 11:23 AM
Just an advice: use strcat instead of format (e.g strcat(pPass[playerid], inputtext)).