Set string to variable string - Whirlpool
#1

Hello.

Is there a way to set string variable to string from OnDialogResponse? i mean exactly something like that:

pawn Код:
new Variable[129], Variable2[129];

//dialog 1
Variable[129] = strlen(inputtext);

//dialog2
Variable2[129] = strlen(inputtext);

// Saving
("code", Variable)
("code2", Variable2)
Because i can't set variable [129] because max string for inputtext is 128. I using 129 because it's a Whirpool system by ******. I think there's no way to do that because i tried and tried with
pawn Код:
printf("%s | %s", Variable, Variable2);
and it nothing given me. So maybe someone other will have idea. Hm?
Reply
#2

Variable = inputtext[The Size Of Inpout Text]
Reply
#3

I don't know why you're trying to store the length of the inputtext in an array, if you want to store the contents of inputtext in the array, simply use strcat, for example:

pawn Код:
strcat(Variable, inputtext);
Reply
#4

Storing because i saving text into dialog2 not in dialog1 as you see. And inputtext is one no other.

I will try suggestions.

@Berlovan
Your suggestion won't work because i tried it before. It's just telling me:
Код:
error 033: array must be indexed (variable "MyVariable")
after i add [129] to MyVariable = inputtext[129]; i will get:
Код:
error 032: array index out of bounds (variable "MyVariable")
That mean variables [129] is too big for "MyVariable" after i change it to 128 it works.

I can only try your way @UP
Reply
#5

Okey so.. first dialog:

pawn Код:
strcat(OldPass, inputtext);
               
                WP_Hash(bufOldPass, sizeof(bufOldPass), OldPass); // Then it don't know what to hash after strcat.. am i good think?
Second dialog:
pawn Код:
strcat(NewPass, inputtext);
                   
                    WP_Hash(bufNewPass, sizeof(bufNewPass), NewPass);
                   
                    new INI:Account = INI_Open(PlayerFile(playerid));
                    INI_WriteString(Account,    "Old_Password",     OldPass);
                    INI_WriteString(Account,    "Password",         NewPass);
Like that?

P.S
I will check strcpy but reply first for this code.
Reply
#6

But..

pawn Код:
WP_Hash(bufOldPass, sizeof(bufOldPass), inputtext);
WP_Hash(bufNewPass, sizeof(bufNewPass), inputtext);
Will set the same value here:
pawn Код:
INI_WriteString(Account,    "Old_Password",     bufOldPass);
INI_WriteString(Account,    "Password",         bufNewPass);
Reply
#7

Nope. It works corectly i tested it with friend. And i can't use WP_Hash in good momments because:

pawn Код:
Check your PM box for code. I really won't show it to all people, and then reply here, please.
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
Only if you do them at the same time. Be careful however - if you are only using "bufOldPass" and "bufNewPass" and writing everything in the second call to the dialog callback you stand the risk of writing the wrong data if two people are using the command at the same time.
Wow, race conditions when SA-MP is not even multithreaded!
Reply
#9

Hm.. i tested it and all works okey. But by your way how it should be done to work corectly? only /changepass (old_pass) (new_pass) ?
Reply
#10

Maybe in this code not. But i wanted to make this (save old and new set to Password = as it is now) but i need to save old_password because saving is only in second dialog as you see.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)