PDA

View Full Version : Y ini string doesn't display in message box dialog


gumball3000
29/02/2016, 03:00 PM
I use y ini ta save a long string that contains the mdc data of every player. here is how it works:


#define PATH "/Users/%s.ini"



stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

function LoadUser_data(playerid,name[],value[])
{
INI_String("mdc",PlayerData[playerid][mcrimes], 1024);
return 1;
}



function InsertCrime(playerid, id, level, reason[])
{
if(PlayerData[id][WantedLevel] == 0) PlayerData[id][TrackLose] = 30;
new sini, string[256], longstring[1024];
sini = PlayerData[id][WantedLevel];
if(level + PlayerData[id][WantedLevel] > 6) PlayerData[id][WantedLevel] = 6;
else PlayerData[id][WantedLevel] = level + PlayerData[id][WantedLevel];
SetPlayerWantedLevel(id,PlayerData[id][WantedLevel]);
sini = PlayerData[id][WantedLevel]-sini;

format(string, sizeof(string), "You've commited a Crime (%s). W: +%d, Reporter: %s.", reason, sini, PlayerData[playerid][Name]);
SendClientMessage(id, COLOR_LIGHTRED, string);
format(string, sizeof(string), "Current Wanted Level: %d", PlayerData[id][WantedLevel]);
SendClientMessage(id, COLOR_YELLOW, string);

new date[50];
new y,m,d,h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(date,sizeof(date),"%02d.%02d.%d %02d:%02d:%02d",d,m,y,h,mi,s);


if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(id), "LoadUser_%s", .bExtra = true, .extra = id);
longstring = PlayerData[id][mcrimes];
format(longstring, sizeof(longstring), "%s\n%s: %s - %s", longstring, date, reason, PlayerData[playerid][Name]);
new INI:File = INI_Open(UserPath(id));
INI_SetTag(File,"data");
INI_WriteString(File,"mdc",longstring);
INI_Close(File);
}
else
{
format(longstring, sizeof(longstring), "%s\n%s: %s - %s", longstring, date, reason, PlayerData[playerid][Name]);
new INI:File = INI_Open(UserPath(id));
INI_SetTag(File,"data");
INI_WriteString(File,"mdc",longstring);
INI_Close(File);
}

PlayerData[id][MDC] += 1;
PlayerData[id][Crimes] += 1;


format(string, sizeof(string), "HQ: All Units APB: Reporter: %s, Crime: %s, W: +%d (%d), Suspect: %s (%d)", PlayerData[playerid][Name],reason,sini,PlayerData[id][WantedLevel],PlayerData[id][Name],id);
SendRadioMessage(1, 0x3350FFFF, string);

new str[128];
mysql_format(SQL, str,128,"UPDATE `users` SET `WantedLevel`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[id][WantedLevel],PlayerData[id][ID]);
mysql_tquery(SQL, str, "", "");
return 1;
}


One of my output ini files:


[data]
mdc =
29.02.2016 17:51:52: test7 - gumball3000
29.02.2016 17:51:51: test6 - gumball3000
29.02.2016 17:51:49: test5 - gumball3000
29.02.2016 17:51:47: test3 - gumball3000
29.02.2016 17:51:41: test 3 - gumball3000
29.02.2016 17:51:40: test 2 - gumball3000
29.02.2016 09:14:53: 1 - gumball3000
29.02.2016 09:14:52: 1 - gumball3000


And here is my actual problem:


YCMD:mdc(playerid, params[], help)
{
new id, string[128];
new faction = PlayerData[playerid][Member] + PlayerData[playerid][Leader];
if(faction != 1) return SendClientMessage(playerid, COLOR_WHITE, CopOnly);
if(sscanf(params, "u", id)) return SendUsage(playerid,"/mdc <Name/Playerid>");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Player not connected.");
new strings[1024];
INI_ParseFile(UserPath(id), "LoadUser_%s", .bExtra = true, .extra = id);
ShowPlayerDialog(playerid,DIALOG_UNUSED,DIALOG_STY LE_MSGBOX,"Mobile data computer",PlayerData[id][mcrimes],"Close","");
return 1;
}


When i do /mdc in game nothing shows up, an empty message with just the title appears, what am i doing wrong? Alternatively how could i display the data inside the ini file in the client's chatbox line by line?

gumball3000
29/02/2016, 04:58 PM
Anyone?