18.02.2015, 23:08
Hello
I am working on a character selection screen using clickable textdraws and I bumped into a problem which I am not able to fix.
I have a table called: users which holds the basic information of a player (database ID, name, password,...).
I have a second table called: characters which holds the information of each character that the player has (Owner ID(refers to the database ID of the player), name, skin....).
Problem: The field that holds the character's name is not being stored correctly. The name loads perfectly but the variable that stores the name remains empty (due to this, data cannot be saved in the database after registering).
Code regarding the loading of the characters:
Character Info (enum):
The problem here is that Character[playerid][characterid][Name] returns an empty string when called. How can I fix this?
Thank you in advance.
EDIT:
Name is defined as a VARCHAR in my table (NOT NULL).
I am working on a character selection screen using clickable textdraws and I bumped into a problem which I am not able to fix.
I have a table called: users which holds the basic information of a player (database ID, name, password,...).
I have a second table called: characters which holds the information of each character that the player has (Owner ID(refers to the database ID of the player), name, skin....).
Problem: The field that holds the character's name is not being stored correctly. The name loads perfectly but the variable that stores the name remains empty (due to this, data cannot be saved in the database after registering).
Code regarding the loading of the characters:
Character Info (enum):
pawn Код:
enum Character_Info
{
ID,
cID,
Exists,
Name[MAX_PLAYER_NAME],
Gender,
Level,
Money,
Skin,
Float:LastPos[4],
LastInterior,
LastVirtualW,
}
new Character[MAX_PLAYERS][MAX_CHARACTERS][Character_Info];
pawn Код:
forward SQL_Character_Load(playerid);
public SQL_Character_Load(playerid)
{
new
rows,
fields;
cache_get_data(rows, fields, mysql);
for(new i = 0; i < rows; i++) if(i < MAX_CHARACTERS)
{
Character[playerid][i][Exists] = true;
Character[playerid][i][cID] = cache_get_field_content_int(i, "cID");
Character[playerid][i][ID] = cache_get_field_content_int(i, "ID");
cache_get_field_content(i, "Name", Character[playerid][i][Name], 24);
Character[playerid][i][Level] = cache_get_field_content_int(i, "Level");
Character[playerid][i][Money] = cache_get_field_content_int(i, "Money");
Character[playerid][i][Skin] = cache_get_field_content_int(i, "Skin");
Character[playerid][i][LastPos][0] = cache_get_field_content_float(i, "LastX");
Character[playerid][i][LastPos][1] = cache_get_field_content_float(i, "LastY");
Character[playerid][i][LastPos][2] = cache_get_field_content_float(i, "LastZ");
Character[playerid][i][LastPos][3] = cache_get_field_content_float(i, "LastA");
Character[playerid][i][LastInterior] = cache_get_field_content_int(i, "LastInterior");
Character[playerid][i][LastVirtualW] = cache_get_field_content_int(i, "LastVirtualW");
}
/*player spawns after this*/
return true;
}
Thank you in advance.
EDIT:
Name is defined as a VARCHAR in my table (NOT NULL).