16.11.2013, 02:22
Hi-
I'm making a bug system, and the way to see an active bug is by a dialog. However, I can't figure out how to make it add a new line to the list dialog for each bug report that's added.
It's under /bugs that I can't figure it out.
Each time I try it in game, it just keeps one line even if there's no active bugs.
Such as, "(Bug: ) Date:00/00/0|Sender: | "
I'm making a bug system, and the way to see an active bug is by a dialog. However, I can't figure out how to make it add a new line to the list dialog for each bug report that's added.
Код:
#define DIALOG_BUGS 3354 enum BugInfo { bugID, bSender[MAX_PLAYER_NAME], bText[128], bMonth, bDay, bYear, bHour, bMinute } new BugReport[MAX_BREPORTS][BugInfo]; stock LoadBug() { if(!fexist("bug.cfg")) fcreate("bug.cfg"); new binfo[6][32]; new string[256]; new File:file = fopen("bug.cfg", io_read); if(file) { new bug = 0; while(bug < MAX_BREPORTS) { fread(file, string); split(string, binfo, '|'); format(BugReport[bug][bSender], 32, "%s", binfo[1]); format(BugReport[bug][bText], 128, "%s", binfo[2]); BugReport[bug][bMonth] = strval(binfo[3]); BugReport[bug][bDay] = strval(binfo[4]); BugReport[bug][bYear] = strval(binfo[5]); BugReport[bug][bHour] = strval(binfo[6]); BugReport[bug][bMinute] = strval(binfo[7]); bug++; } } print("Bugs rehashed."); return 1; } stock SaveBugs() { if(!fexist("bug.cfg")) fcreate("bug.cfg"); new bug = 0, File:file; new string[256]; while(bug < MAX_BREPORTS) { format(string, sizeof(string), "%s|%s|%d|%d|%d|%d|%d|\r\n", BugReport[bug][bSender], BugReport[bug][bText], BugReport[bug][bMonth], BugReport[bug][bDay], BugReport[bug][bYear], BugReport[bug][bHour], BugReport[bug][bMinute]); if(bug == 1) { file = fopen("bug.cfg", io_write); } else { file = fopen("bug.cfg", io_append); } fwrite(file, string); fclose(file); bug++; } print("Bug system saved."); } CMD:sendbug(playerid, params[]) { new string[128]; new hour, minute; new Month, Day, Year; getdate(Year, Month, Day); gettime(hour, minute, _); if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!PlayerInfo[playerid][pAdmin] && PlayerInfo[playerid][pTester]) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(isnull(params)) return SCM(playerid, GREY, "Usage: /sendbug [bug text]"); for(new bug=0; bug<MAX_BREPORTS; bug++) { if(!BugReport[bug][bText][0]) { format(BugReport[bug][bSender], 32, RPN(playerid)); format(BugReport[bug][bText], 128, params); BugReport[bug][bMonth] = Month; BugReport[bug][bDay] = Day; BugReport[bug][bYear] = Year; BugReport[bug][bHour] = hour; BugReport[bug][bMinute] = minute; format(string,sizeof(string),"[New Bug Report:%d] Sender: %s, Bug: %s (Use /bugs)", bug, RPN(playerid), params); SendATMessage(ADMIN, string); Log("logs/bugs.log", string); bug = MAX_BREPORTS; } } return 1; } CMD:bugs(playerid, params[]) { new bug2[128], bug1[32]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!PlayerInfo[playerid][pAdmin] || PlayerInfo[playerid][pTester]) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); for(new f=0; f<MAX_BREPORTS; f++) { format(bug1,sizeof(bug1), "Active Bug Reports:"); format(bug2, sizeof(bug2), "{FF0000}(Bug %d){FFFFFF} Date:%02d/%02d/%d |Sender: %s| %s\r\n", f, BugReport[f][bMonth], BugReport[f][bDay], BugReport[f][bYear], BugReport[f][bSender], BugReport[f][bText]); ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_LIST, bug1, bug2, "Select", "Quit"); } return 1; } CMD:clearbug(playerid, params[]) { new id, string[128]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!PlayerInfo[playerid][pAdmin] && PlayerInfo[playerid][pTester]) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /clearbug [bugid]"); if(!BugReport[id][bText][0]) return SendClientMessage(playerid, ADMIN, "There's no active report on that ID."); format(string, sizeof(string), "[Bug Saver] %s cleared %s's bug report [Bug %d]", RPN(playerid), BugReport[id][bSender], id); SendATMessage(ADMIN, string); Log("logs/bugs.log", string); format(BugReport[id][bSender], 32, ""); format(BugReport[id][bText], 128, ""); BugReport[id][bMonth] = 0; BugReport[id][bDay] = 0; BugReport[id][bYear] = 0; BugReport[id][bHour] = 0; BugReport[id][bMinute] = 0; return 1; }
Each time I try it in game, it just keeps one line even if there's no active bugs.
Such as, "(Bug: ) Date:00/00/0|Sender: | "