10.04.2017, 19:28
Hey guys, I just can't figure it out, what I'm trying to do is to combine 2 different strings into 1 to explain it a bit, I'm just learning a bit about sql, and database and so on so what I'm trying to save is the following, I'm using dialog where I insert a name, and I'm using another dialog where I insert lastname saving them to two different PVars.
However I want to combine those 2 (name and lastname) PVars into 1 and to save it as full name.
So what I tried to do is the following:
Dialog Response for inserting the name
Dialog Response for inserting the lastname
"Function" and few commented attempts what I tried to do to combine those two strings:
And how I tried to save:
Just can't figure it out how I can combine and save two strings into one so it will be saved as full name firstname_lastname. Thanks for answer in advance as this is eating my nerves
I know the code at the end went messy but I tried a lot of stuff to make it work, so I just posted the last attempt what I tried.
However I want to combine those 2 (name and lastname) PVars into 1 and to save it as full name.
So what I tried to do is the following:
Dialog Response for inserting the name
Код:
new charname[128]; format(charname,sizeof(charname),"%s",inputtext); SetPVarString(playerid,"CharName",charname);
Код:
new charlastname[128]; format(charlastname,sizeof(charlastname),"%s",inputtext); SetPVarString(playerid,"CharLastName",charlastname);
Код:
SetCharName(playerid) { new setname[128]; new fname[128]; new lname[128]; //format(setname,sizeof(setname),"%s_%s",CharData[playerid][CharName],CharData[playerid][CharLastName]); //format(setname,sizeof(setname),"%s_%s",GetPVarString(playerid, "CharName", setname, sizeof(setname)),GetPVarString(playerid, "CharLastName", setname, sizeof(setname))); //SetPlayerName(playerid,setname); format(setname,sizeof(setname),"%s_%s",GetPVarString(playerid, "CharName", fname, sizeof(fname)) ,GetPVarString(playerid, "CharLastName", lname, sizeof(lname))); SetPVarString(playerid, "PlayerName", setname); GetPVarString(playerid, "PlayerName", setname, sizeof(setname)); return 1; }
Код:
format(szQuery, sizeof(szQuery), "INSERT INTO `characters` (username, yearofbirth, monthofbirth, dayofbirth) VALUES ('%s', '%d', '%d','%d')", SetCharName(playerid) //code goes on...
I know the code at the end went messy but I tried a lot of stuff to make it work, so I just posted the last attempt what I tried.