debug cmd -
StR_MaRy - 18.10.2016
hey guys i did a debug to a command and had some error's where is returning but how can i fix it ?
Код HTML:
CMD:friends(playerid, params[])
{
new result2[500];
print("DEBUG first: Command /friends used");
printf("DEBUG first: MySQL returned %s", result2);
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login pin.");
if(IsPlayerConnected(playerid))
{
print("DEBUG after connect: Command /friends used");
printf("DEBUG after connect: MySQL returned %s", result2);
new online[1000],offline[1000],query[300],result[30],name[30],idd,mid=1,aim2[2000];
format(query, sizeof(query), "SELECT * FROM `friends` WHERE `PlayerID` = '%d' AND `Status`='1'",PlayerInfo[playerid][pSQLID]);
new Cache: membresult = mysql_query(handle,query);
for(new i, j = cache_get_row_count (); i != j; ++i)
{
idd = cache_get_field_content_int(i, "FriendID");
cache_get_field_content(i, "FriendName", result); format(name, 30, result);
Selected1[playerid][mid] = idd;
format(online, sizeof(online), "%s{228404}[online]{FFFFFF} %s\n",online,name);
mid++;
print("DEBUG status 1: Command /friends used");
printf("DEBUG status 1: MySQL returned %s", result2);
}
cache_delete(membresult);
format(query, sizeof(query), "SELECT * FROM `friends` WHERE `PlayerID` = '%d' AND `Status`='0'",PlayerInfo[playerid][pSQLID]);
new Cache: membresult1 = mysql_query(handle,query);
for(new i, j = cache_get_row_count (); i != j; ++i)
{
idd = cache_get_field_content_int(i, "FriendID");
cache_get_field_content(i, "FriendName", result); format(name, 30, result);
Selected1[playerid][mid] = idd;
format(offline, sizeof(offline), "%s{BB172D}[offline]{FFFFFF} %s\n",offline,name);
mid++;
print("DEBUG status 0: Command /friends used");
printf("DEBUG status 0: MySQL returned %s", result2);
}
cache_delete(membresult1);
format(aim2,sizeof(aim2),"{F89B0E}[+] Add Friend\n%s%s",online, offline);
ShowPlayerDialog(playerid, DIALOG_FRIENDS, DIALOG_STYLE_LIST, "Friends", aim2, "Select", "Exit");
print("DEBUG sfarsit: Command /friends used");
printf("DEBUG sfarsit: MySQL returned %s", result2);
}
return 1;
}
Код HTML:
[17:06:36] DEBUG first: Command /friends used
[17:06:36] DEBUG first: MySQL returned
[17:06:36] DEBUG after connect: Command /friends used
[17:06:36] DEBUG after connect: MySQL returned
Re: debug cmd -
StR_MaRy - 18.10.2016
bump solved , string to big
Re: debug cmd -
Konstantinos - 18.10.2016
I don't understand what is the problem but your debugging fails because you never assign any text to "result2" so it is always empty.
As for the 2 queries and non-threaded queries, I'd do this with a completely different way:
PHP код:
CMD:friends(playerid, params[])
{
if (!gLogged[playerid]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login pin.");
new query[90];
format(query, sizeof(query), "SELECT FriendName,Status FROM friends WHERE PlayerID=%d ORDER BY Status,FriendID", PlayerInfo[playerid][pSQLID]);
mysql_tquery(handle, query, "OnPlayerFriendsList", "i", playerid);
return 1;
}
forward OnPlayerFriendsList(playerid);
public OnPlayerFriendsList(playerid)
{
new dialog_info[500] = "{F89B0E}[+] Add Friend\n", friend_name[MAX_PLAYER_NAME];
for (new i, j = cache_get_row_count(handle); i != j; i++)
{
cache_get_row(i, 0, friend_name, handle);
format(dialog_info, sizeof dialog_info, "%s%s{FFFFFF} %s\n", dialog_info, cache_get_row_int(i, 1, handle) ? ("{228404}[online]") : ("{BB172D}[offline]"), friend_name);
}
ShowPlayerDialog(playerid, DIALOG_FRIENDS, DIALOG_STYLE_LIST, "Friends", dialog_info, "Select", "Exit");
return 1;
}
// OnDialogResponse -> dialogid == DIALOG_FRIENDS && response
if (!listitem)
{
// add friend
}
else
{
new friend_name[MAX_PLAYER_NAME];
sscanf(inputtext, "'] 's[24]", friend_name);
// do stuff but you will use "FriendName" in the WHERE clause.
}
I also notice that you save the FriendID so you can use it later on but extracting the name for a single query is fine. Since I wrote it and you said you solved it, I'll post it anyway.