04.07.2012, 08:02
(
Последний раз редактировалось Kindred; 04.07.2012 в 08:51.
)
Okay guys, I am having a problem.
I am trying to make a system in which you can have a username, and create several characters within them (5).
Now, the problem is, it won't save. I mean, when it goes back to the dialog to show what characters are there, they saved them there correctly, yet, they will not save into the database.
This is the line of code that saves the new character you register.
Also, if you can try to make it look nicer, because the way it looks now doesn't look very efficient, it would be appreciated.
Thanks in advance,
- Kindred.
PS: I am a newbie at MySQL, haven't used it in a few months and only started it a few months ago.
PS2: How can I see how much of a query size I need. I am new to this and would really like to know this before using useless memory.
I am trying to make a system in which you can have a username, and create several characters within them (5).
Now, the problem is, it won't save. I mean, when it goes back to the dialog to show what characters are there, they saved them there correctly, yet, they will not save into the database.
This is the line of code that saves the new character you register.
pawn Код:
stock RegisterCharacter(playerid, charactername[24])
{
new query[200];
if(!strcmp(CharacterInfo[playerid][0], "None", false)) CharacterInfo[playerid][0] = charactername;
else if(!strcmp(CharacterInfo[playerid][1], "None", false)) CharacterInfo[playerid][1] = charactername;
else if(!strcmp(CharacterInfo[playerid][2], "None", false)) CharacterInfo[playerid][2] = charactername;
else if(!strcmp(CharacterInfo[playerid][3], "None", false)) CharacterInfo[playerid][3] = charactername;
else if(!strcmp(CharacterInfo[playerid][4], "None", false)) CharacterInfo[playerid][4] = charactername;
format(query, sizeof(query), "INSERT INTO playerdata(name, Username, Cash, PlayHours) VALUES('%s', '%s', 0, 0)", charactername, pInfo[playerid][Username]);
mysql_query(query);
SavePlayerCharacters(playerid);
ShowDialog(playerid, 3);
return 1;
}
//SavePlayerCharacters stock
stock SavePlayerCharacters(playerid)
{
if(Logged[playerid] == 1)
{
new query[200];
format(query, sizeof(query), "UPDATE Accounts SET Character1=%s, Character2=%s, Character3=%s, Character4=%s, Character5=%s, Adminlevel=%i WHERE Username='%s'", \
CharacterInfo[playerid][0], CharacterInfo[playerid][1], CharacterInfo[playerid][2], CharacterInfo[playerid][3], CharacterInfo[playerid][4], pInfo[playerid][Username]);
mysql_query(query);
}
return 1;
}
Thanks in advance,
- Kindred.
PS: I am a newbie at MySQL, haven't used it in a few months and only started it a few months ago.
PS2: How can I see how much of a query size I need. I am new to this and would really like to know this before using useless memory.