SA-MP Forums Archive
Read full name in DJSon. - 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: Read full name in DJSon. (/showthread.php?tid=589538)



Read full name in DJSon. - Zevcore - 20.09.2015

Good morning, hello, I took a selection of first and last name when registering and write to a file in DJSon.
Now I did read in OnPlayerConnect.

pawn Код:
new string[128], imie[500], nazwisko[500];
imie = dj(PlayerPath(playerid), "Dane/Imię");
nazwisko = dj(PlayerPath(playerid), "Dane/Nazwisko");
format the

pawn Код:
format(string,sizeof(string), "%s_%s", imie, nazwisko);
and I set the player a nickname

pawn Код:
SetPlayerName(playerid, string);
but it gets nickname "_" instead of "Name_Surname"


Re: Read full name in DJSon. - BroZeus - 20.09.2015

You mean "Name_" or "_Surname" ?
And try printing their values after they are being loaded like this :
PHP код:
printf"Imie: %s Nazwisko: %s"imienazwisko); 
And see what it prints


Re: Read full name in DJSon. - Zevcore - 20.09.2015

Print:
Код:
Imie: Nazwisko:
but it is in file
Код:
{
  "Dane":{
    "Haslo":"poop",
    "Imię":"Peter",
    "Nazwisko":"Smith"
  }
}
Hasło - Password
Imię - Name
Nazwisko - Surname

It must look like this:
"Name_Surname"


Re: Read full name in DJSon. - BroZeus - 20.09.2015

Try this :
PHP код:
new string[128], imie[23], nazwisko[23];//no need to make them 500 way to big
strcat(imiedj(PlayerPath(playerid), "Dane/Imię"));
strcat(nazwiskodj(PlayerPath(playerid), "Dane/Nazwisko")); 
if this doesn't work then try this and tell what happens :
PHP код:
new string[128], imie[23], nazwisko[23];//no need to make them 500 way to big
format(imiesizeof(imie), "%s",  dj(PlayerPath(playerid), "Dane/Imię"));
format(nazwiskosizeof(nazwisko), "%s",  dj(PlayerPath(playerid), "Dane/Nazwisko")); 



Re: Read full name in DJSon. - Zevcore - 20.09.2015

Nothing, nick look "_" ._.


Re: Read full name in DJSon. - Zevcore - 21.09.2015

@ref

On PL Forum said : this lane is bad
Код:
format(string,sizeof(string), "%s_%s", imie, nazwisko);
but i don't know why


Re: Read full name in DJSon. - Zevcore - 22.09.2015

@ref


Re: Read full name in DJSon. - BroZeus - 22.09.2015

Well if you tried printing after loading then it means that there is problem in loading not in format, check the PlayerPath function to see whether it returns correct path or not.