Sql & PVars
#1

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
Код:
			new charname[128];
            format(charname,sizeof(charname),"%s",inputtext);
			SetPVarString(playerid,"CharName",charname);
Dialog Response for inserting the lastname
Код:
new charlastname[128];
			format(charlastname,sizeof(charlastname),"%s",inputtext);
			SetPVarString(playerid,"CharLastName",charlastname);
"Function" and few commented attempts what I tried to do to combine those two strings:

Код:
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;
}
And how I tried to save:

Код:
format(szQuery, sizeof(szQuery), "INSERT INTO `characters` (username, yearofbirth, monthofbirth, dayofbirth) VALUES ('%s', '%d', '%d','%d')", SetCharName(playerid) //code goes on...
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.
Reply


Messages In This Thread
Sql & PVars - by Lajko1 - 10.04.2017, 19:28
Re: Sql & PVars - by AndreiWow - 10.04.2017, 19:54
Re: Sql & PVars - by Lajko1 - 10.04.2017, 19:58
Re: Sql & PVars - by AndreiWow - 10.04.2017, 20:00
Re: Sql & PVars - by Lajko1 - 10.04.2017, 20:08
Re: Sql & PVars - by AndreiWow - 10.04.2017, 20:26
Re: Sql & PVars - by Lajko1 - 11.04.2017, 04:54

Forum Jump:


Users browsing this thread: 1 Guest(s)