String not showing ingame but printing fine - Snow - 2021-04-18
So I am trying to show offline stats of a player and?I am fetching the results from the database to show in game but one of the columns do not show in there. But if i print the string, it shows the result there. Basically i fetch a few columns and format them into a string to show in a textdraw. As you can see here,?
It shows everything but not the Last Seen which is also fetched from database. On printing the string, this is the result:
Code: ~p~Username: ~w~localhost~n~~p~Score: ~w~10~n~~p~Kills:~w~ 0~n~~p~Deaths:~w~ 0~n~~p~Money:~w~ $50,000~n~~p~Last On:~w~ 04-05-2021
In the code above, you can clearly see its printing "Last Seen On:" thing but it wont show it in game. Here is the code:
Code: CMD:osts(playerid, params[])
{
? ? new query[128], string2[128], accountname[24], ohours, omins, oscore, obal, okills, odeaths, ologged[128];
? ? if(sscanf(params, "s[24]", accountname))
? ? ? ? return SendClientMessage(playerid, COLOR_RED, "USAGE: /osts [account name]");
? ? mysql_format(g_SQL, query, sizeof(query), "SELECT score,hours,minutes,money,kills,deaths, laston FROM `players` WHERE `username` = '%e'",accountname);
? ? new Cache:result;
? ? result = mysql_query(g_SQL, query, true);
? ? new rows = cache_num_rows();
? ? if(rows)
? ? {? ? ?
? ? ? ? new string[1024];
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][0]);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][1]);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][3]);
? ? ? ? for (new i = 0; i < rows; i )
? ? ? ? {
? ? ? ? ? ? cache_get_value_name(i, "laston", ologged);
? ? ? ? ? ? cache_get_value_name_int(i, "kills", okills);
? ? ? ? ? ? cache_get_value_name_int(i, "deaths", odeaths);
? ? ? ? ? ? cache_get_value_name_int(i, "score", oscore);
? ? ? ? ? ? cache_get_value_name_int(i, "hours", ohours);
? ? ? ? ? ? cache_get_value_name_int(i, "minutes", omins);
? ? ? ? ? ? cache_get_value_name_int(i, "money", obal);
? ? ? ? ? ?
? ? ? ? ? ? format(string, sizeof(string), "~p~Username: ~w~%s~n~~p~Score: ~w~%d~n~~p~Kills:~w~ %d~n~~p~Deaths:~w~ %d~n~~p~Money:~w~ %s~n~~p~Last On:~w~ %s", accountname,oscore,okills,odeaths,formatInt(obal), ologged);
? ? ? ? }
? ? ? ? PlayerTextDrawSetString(playerid, OStatsTD[playerid][2], string);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][2]);?
? ? ? ? SetTimerEx("tdhide", 10000, false, "i", playerid);?
? ? ? ?
? ? ? ? cache_delete(result);
? ? }
? ? else
? ? format(string2, sizeof(string2), "ERROR: %s isn't found in the database." ,accountname);
? ? SendClientMessage(playerid, COLOR_RED, string2);
? ? return 1;
}
Any idea what could be wrong here? Also, increasing the string size wouldn't help either.
RE: String not showing ingame but printing fine - Radical - 2021-04-19
I made some changes in your code. Try.
Code: CMD:osts(playerid, params[])
{
? ? new accountname[24];
? ? if(sscanf(params, "s[24]", accountname))
? ? ? ? return SendClientMessage(playerid, COLOR_RED, "USAGE: /osts [account name]");
? ? new string[256];
? ? mysql_format(g_SQL, string, 128, "SELECT score,hours,minutes,money,kills,deaths, laston FROM `players` WHERE `username` = '%e' LIMIT 1",accountname);
? ? new Cache: result = mysql_query(g_SQL, string, true);
? ? new rows = cache_num_rows();
? ? if(rows)
? ? {
? ? ? ? new ohours, omins, oscore, obal, okills, odeaths, ologged[11];
? ? ? ?
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][0]);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][1]);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][3]);
? ? ? ? cache_get_value_name_int(0, "score", oscore);
? ? ? ? cache_get_value_name_int(0, "hours", ohours);
? ? ? ? cache_get_value_name_int(0, "minutes", omins);
? ? ? ? cache_get_value_name_int(0, "money", obal);
? ? ? ? cache_get_value_name_int(0, "kills", okills);
? ? ? ? cache_get_value_name_int(0, "deaths", odeaths);
? ? ? ? cache_get_value_name(0, "laston", ologged);
? ? ? ?
? ? ? ? format(string, sizeof(string), "~p~Username: ~w~%s~n~~p~Score: ~w~%d~n~~p~Kills:~w~ %d~n~~p~Deaths:~w~ %d~n~~p~Money:~w~ %d~n~~p~Last On:~w~ %s", accountname,oscore,okills,odeaths,obal, ologged);
? ? ? ? PlayerTextDrawSetString(playerid, OStatsTD[playerid][2], string);
? ? ? ? PlayerTextDrawShow(playerid, OStatsTD[playerid][2]);
? ? ? ? SetTimerEx("tdhide", 10000, false, "i", playerid);
? ? ?
? ? ? ? cache_delete(result);
? ? } else format(string, 128, "ERROR: %s isn't found in the database." ,accountname),
? ? SendClientMessage(playerid, COLOR_RED, string);
? ? return 1;
}
RE: String not showing ingame but printing fine - Snow - 2021-04-21
Thanks man. That solved the problem.
|