Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Filterscript made by Kwarde:
- * SA-MP Forums: forum.sa-mp.com/member.php?u=70717
- * E-Mail: kwarde@mail.com
- For information about this filterscript and its defines, check out the 'BugReport_README.txt' file!
- YOU MAY:
- - Use this script ;-)
- - Edit this script (but don't re-release it!)
- - Remove ingame credits (checkout USE_INGAME_ADVERTISE), but please keep the prints (so you see my name yay :3)
- - Put this into your gamemode
- - Remove this annoying text (the one from start 'till '#define FILTERSCRIPT')
- YOU MAY NOT:
- - Re-release this script
- - Re-release this script and claim it for your own (That is just very pathethic and dumb)
- - Claim the script for your own without re-releasing it
- - Kill other people or steal from other people (re-releasing / claiming as your own is stealing!)
- Enjoy the filterscript :)
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_RED 0xFF0000AA
- #define COLOR_GREEN 0x00FF00AA
- #define COLOR_LIGHTBLUE 0x00FFFFAA
- #define COLOR_GRAY 0xAFAFAFAA
- #define FS_VERS_MAJOR 0
- #define FS_VERS_MINOR 1
- #define FS_VERS_BUILD 28
- #define FS_VERS_TAG "RC" //A(lpha), B(eta), R(elease) C(andidate)
- #define BUG_REPORT_FILE "ServerBugReports.txt"
- #define USE_INGAME_ADVERTISE
- #define REPORT_INTERVAL 30 //Ammount in seconds before a player can report a bug again
- #define DIALOG_BREPORT 666
- #define DIALOG_BREPORT_CONFIRM 667
- #define CB:%0(%1) forward %0(%1); public %0(%1)
- #define ploop(%0) for (new %0 = 0; %0 < MAX_PLAYERS; %0++) if (IsPlayerConnected(%0) && !IsPlayerNPC(%0))
- new bool:pCanReport[MAX_PLAYERS] = true,
- pReportTimer[MAX_PLAYERS] = (-1);
- public OnFilterScriptInit()
- {
- print(" ");
- print(">> BugReport v"#FS_VERS_MAJOR"."#FS_VERS_MINOR"."#FS_VERS_BUILD"-"#FS_VERS_TAG" loaded <<");
- print(">> BugReport created by Kwarde (contact: kwarde@mail.com) <<");
- print(" ");
- return 1;
- }
- public OnFilterScriptExit()
- {
- ploop(i)
- {
- #if defined USE_INGAME_ADVERTISE
- DeletePVar(i, "BR_FirstSpawn");
- #endif
- DeletePVar(i, "BR_BugReport");
- if (pReportTimer[i] != -1) KillTimer(pReportTimer[i]); //Not sure if it's needed
- }
- print(">> Filterscript BugReport (made by Kwarde) unloaded <<");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- #if defined USE_INGAME_ADVERTISE
- new str[128];
- SetPVarInt(playerid, "BR_FirstSpawn", 0);
- format(str, 128, "This server is using {FFFFFF}BugReport v%d.%d.%d-%s", FS_VERS_MAJOR, FS_VERS_MINOR, FS_VERS_BUILD, FS_VERS_TAG);
- SendClientMessage(playerid, COLOR_GRAY, str);
- #endif
- return 0;
- }
- #if defined USE_INGAME_ADVERTISE
- public OnPlayerSpawn(playerid)
- {
- if (GetPVarInt(playerid, "BR_FirstSpawn") == 0)
- {
- SendClientMessage(playerid, COLOR_WHITE, "SERVER: We are using BugReport so that you can report bugs! ({FF0000}/reportbug{FFFFFF})");
- SendClientMessage(playerid, COLOR_WHITE, "SERVER: BugReport is created by Kwarde (for more info, contact {FFFF00}kwarde@mail.com{FFFFFF})");
- SetPVarInt(playerid, "BR_FirstSpawn", 1);
- }
- return 0;
- }
- #endif
- public OnPlayerDisconnect(playerid)
- {
- if (pReportTimer[playerid] != -1)
- {
- KillTimer(pReportTimer[playerid]);
- pReportTimer[playerid] = (-1);
- }
- pCanReport[playerid] = true;
- DeletePVar(playerid, "BR_BugReport");
- #if defined USE_INGAME_ADVERTISE
- DeletePVar(playerid, "BR_FirstSpawn");
- #endif
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch (dialogid)
- {
- case DIALOG_BREPORT:
- {
- if (!response)
- return SendClientMessage(playerid, COLOR_GRAY, "Bug report cancelled.");
- if (isnull(inputtext) || strlen(inputtext) < 10 || strlen(inputtext) > 100)
- {
- SendClientMessage(playerid, COLOR_RED, "[ERROR] {FFFFFF}You must fill in the report bug, with a length of 10 to 100 characters!");
- ShowDialog(playerid, DIALOG_BREPORT);
- return 1;
- }
- SetPVarString(playerid, "BR_BugReport", inputtext);
- ShowDialog(playerid, DIALOG_BREPORT_CONFIRM);
- return 1;
- }
- case DIALOG_BREPORT_CONFIRM:
- {
- if (!response)
- return ShowDialog(playerid, DIALOG_BREPORT);
- new str[128], pName[MAX_PLAYER_NAME], bug[100];
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- GetPVarString(playerid, "BR_BugReport", bug, 100);
- BugReport(playerid, bug);
- SendClientMessage(playerid, COLOR_GREEN, "Thank you very much! The bug has been reported!");
- format(str, 128, "[NOTICE] %s (ID: %d) reported a bug! Use /checkbugs to see the report! (You'll see the last 9 bug reports)", pName, playerid);
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (!IsPlayerConnected(i) || IsPlayerNPC(i) || !IsAdmin(i)) continue;
- SendClientMessage(i, COLOR_LIGHTBLUE, str);
- }
- DeletePVar(playerid, "BR_BugReport");
- pCanReport[playerid] = false;
- pReportTimer[playerid] = SetTimerEx("PReportOn", REPORT_INTERVAL * 1000, false, "i", playerid);
- return 1;
- }
- }
- return 0;
- }
- CB:PReportOn(playerid)
- {
- pReportTimer[playerid] = (-1);
- pCanReport[playerid] = true;
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "[NOTICE] {FFFFFF}You can use /reportbug again to report bugs!");
- return 1;
- }
- stock IsAdmin(playerid) //Check out 'IsAdmin_examples.pwn' so that this function makes more sense ;)
- {
- if (IsPlayerAdmin(playerid))
- return true;
- return false;
- }
- stock BugReport(playerid, bugTxt[])
- {
- new pName[MAX_PLAYER_NAME];
- new File:bugReportFile = fopen(BUG_REPORT_FILE, io_append);
- new writeStr[200];
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- format(writeStr, 200, "%s|%s\n", pName, bugTxt);
- fwrite(bugReportFile, writeStr);
- fclose(bugReportFile);
- return 1;
- }
- stock GetFileLines(file[])
- {
- if (!fexist(file)) return 0;
- new File:readFile = fopen(file, io_read);
- new readStr[200], lines = 1; //readStr[255] - I preferred 'readStr[1]', but it only seems to work if the length is as long as the line (I tested, and [1] didn't work on the next file content: "1\n2\n3\n4\n5"
- while (fread(readFile, readStr))
- lines++;
- fclose(readFile);
- return lines;
- }
- stock ShowDialog(playerid, dialogid)
- {
- switch (dialogid)
- {
- case DIALOG_BREPORT: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Bug report", "Please fill in the bug you've detected.\nIt's recommended that you report it as short as possible and also include information on how it happened.\nExample: \"The command /reportbug is nog working!\" or \"My vehicle doesn't spawn when I use /veh\"", "Report", "Cancel");
- case DIALOG_BREPORT_CONFIRM:
- {
- new str[210], bug[100];
- GetPVarString(playerid, "BR_BugReport", bug, 100);
- format(str, 210, "{FFFFFF}You are going to report the next bug:\n{FF0000}%s\n{FFFFFF}Are you sure you want to report that?", bug);
- ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Bug report: Confirm", str, "Yes", "No");
- }
- }
- return 1;
- }
- CMD:reportbug(playerid, params[])
- {
- if (pCanReport[playerid])
- ShowDialog(playerid, DIALOG_BREPORT);
- else
- {
- SendClientMessage(playerid, COLOR_RED, "[ERROR] {FFFFFF}You can't report a bug at the time (in order to prevent spamming).");
- SendClientMessage(playerid, COLOR_RED, "[ERROR] {FFFFFF}You'll receive a message when you can use this command again");
- return 1;
- }
- return 1;
- }
- CMD:checkbugs(playerid, params[])
- {
- if (!IsAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] {FFFFFF}This command is for admins only!");
- if (!fexist(BUG_REPORT_FILE)) return SendClientMessage(playerid, COLOR_GRAY, "[NOTICE] {FFFFFF}There are nog bugs reported");
- for (new i = 0; i < 10; i++) SendClientMessage(playerid, -1, " ");
- SendClientMessage(playerid, COLOR_WHITE, "|---------- {FFFF00}Bug reports {FFFFFF}----------|");
- new File:bugReportFile = fopen(BUG_REPORT_FILE, io_read);
- new readStr[200], str[128], curLine = 1;
- new totalLines = GetFileLines(BUG_REPORT_FILE);
- new start;
- if (totalLines <= 11) start = 1;
- else start = totalLines - 8;
- while (fread(bugReportFile, readStr))
- {
- curLine++;
- if (curLine < start) continue;
- new strName[MAX_PLAYER_NAME], strBug[100];
- sscanf(readStr, "p<|>s[24]s[100]", strName, strBug);
- format(str, 128, "%s: {AFAFAF}%s", strName, strBug);
- SendClientMessage(playerid, COLOR_WHITE, str);
- }
- fclose(bugReportFile);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement