24.04.2013, 10:26
Hello, everyone. Well I'm in the process of scripting a character system and it's pretty much done now which I am amazed to have gotten this far without a single error, right up until I look at my characters through the in game dialog...
I currently have two characters in the database named Test_Char1 & Test_Char2.
Now I was hoping to display a list dialogue that displays these two characters and the player can choose between which one they wants to play as. Problem is, it only shows Test_Char1 in the list dialogue and Test_Char2 is no where to be found on the dialog.
When the dialog appears I have this code to send a query to the pCharacters table where I store all of the characters.
What I have under public FindCharacters
I've tried loops, i've tried not using loops... I just can't seem to get it right! Since placing the loop in the public sub it's began looping the character five times on the dialog so it appears as
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Any ideas people? Cheers
~Liam
I currently have two characters in the database named Test_Char1 & Test_Char2.
Now I was hoping to display a list dialogue that displays these two characters and the player can choose between which one they wants to play as. Problem is, it only shows Test_Char1 in the list dialogue and Test_Char2 is no where to be found on the dialog.
When the dialog appears I have this code to send a query to the pCharacters table where I store all of the characters.
pawn Код:
else if(dialogid == DIALOG_UCP)
{
if(listitem == 0)
{
//Displaying the players character menu
new query[128];
format(query, sizeof(query), "SELECT * FROM `pCharacters` WHERE cOwnerID='%d'", PlayerInfo[playerid][uniqID]);
mysql_function_query(dbHandle, query, true, "FindCharacters", "i", playerid);
}
pawn Код:
forward FindCharacters(playerid);
public FindCharacters(playerid)
{
new rows,
fields,
temp[100],
charname[32],
charlist[200],
previousid[100];
cache_get_data(rows, fields);
if(rows)
{
cache_get_row(0, 1, temp);
if(PlayerInfo[playerid][uniqID] == strval(temp))
{
for(new i = 0; i < 5; i++)
{
cache_get_row(0, 2, charname);
cache_get_row(0, 0, previousid);
format(charlist, sizeof(charlist), "%s%s (CID: %d)\n", charlist, charname, strval(previousid));
}
}
ShowPlayerDialog(playerid, DIALOG_MYCHARACTERS, DIALOG_STYLE_LIST, "{FF0000}My Characters", charlist, "Play", "UCP");
}
else
{
format(charlist, sizeof(charlist), "{FFFFFF}No Available Characters!");
ShowPlayerDialog(playerid, DIALOG_NOCHARACTERS, DIALOG_STYLE_MSGBOX, "{FFFFFF}You don't own any characters!", charlist, "Back", "");
}
return 1;
}
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Test_Char1 (CID: %d)
Any ideas people? Cheers
~Liam