Paste: report system

Author: OmerT`
Mode: lua
Date: Sat, 12 Jun 2010 20:30:27
Plain Text |
	if(cmd[0].tolower() == "/admins")
	{
		sendPlayerMessage(playerid, COLOR_SEABLUE, "Connected admins:");
		foreach(i, var in pData)
		{
			if(var.Admin >= 1) sendPlayerMessage(playerid, COLOR_SEABLUE, nameX(i) + " - Admin level: " + var.Admin + "|" + //continued next line
				iif(var.Report != NO_REPORT, "Taking care of the report of: " + nameX(var.Report) + ".", "Currently not taking care of a report."));
		}
		sendPlayerMessage(playerid, COLOR_SEABLUE, "-------------------");
	}
	if(cmd[0].tolower() == "/report")
	{
		if(!(2 in cmd)) return sendPlayerMessage(playerid, COLOR_USAGE, "USAGE: /Report [ID/Name] [The admin ID (Found by /Admins), or the letter R (For a random admin)] [Reason].");
		if(!isNumeric(cmd[2]) && !cmd[2].tolower() == "r") return sendPlayerMessage(playerid, COLOR_USAGE, "The Admin's ID must be a number. For a list of admins, use: /Admins.");
		local adminID;
		if(isNumeric(cmd[2])) //Admin chosen by player
		{
			if(!isPlayerConnected(cmd[2].tointeger())) return sendPlayerMessage(playerid, COLOR_USAGE, "This ID is not connected. For a list of admins, use: /Admins.");
			if(getAdminLevel(cmd[2].tointeger()) == 0) return sendPlayerMessage(playerid, COLOR_USAGE, "This player is not an admin. For a list of admins, use: /Admins.");
			if(pVar[cmd[2].tointeger()].Report != NO_REPORT) return sendPlayerMessage(playerid, COLOR_USAGE, "This admin is already taking care of the report of " + nameX(pVar[cmd[2].tointeger()].Report) + ".");
			adminID = cmd[2].tointeger();
		}
		else //Random admin
		{
			local adminsArray = array(countConnectedPlayers(), -1);
			local adminsArrayIdx = 0;
			foreach(i, var in pData) if(var.Admin != 0 && pVar[i].Report != NO_REPORT) adminsArray[adminsArrayIdx++] = i;
			if(adminsArray[0] == -1) return sendPlayerMessage(playerid, COLOR_USAGE, "There are no connected admins or all the admins are busy taking care of other reports, try again later.");
			srand(getTimeStamp);
			adminID = adminsArray[Random(0, adminsArrayIdx)];
		}
		pVar[cmd[2].tointeger()].Report = playerid;
		sendPlayerMessage(playerid, COLOR_GRAY, "Your report has been sent successfully to the admin " + nameX(cmd[2].tointeger()) + " and it will be taken care of as soon as possible.");
		return sendPlayerMessage(cmd[2].tointeger(), COLOR_PINK, "*NEW REPORT* - Sent by: " + nameX(playerid) + " | " + "Reported player (ID/NAME): " + cmd[1] + " | " + "Reason: " + command.slice(cmd[0].len() + cmd[1].len() + cmd[2].len() + 3, command.len()) + " | When finished with the report do: /Donereport."); 
	}
	
	if(cmd[0].tolower() == "/donereport")
	{
		if(getAdminLevel(playerid) == 0) return adminOnlyCMD(playerid, 1);
		if(!(1 in cmd)) return sendPlayerMessage(playerid, COLOR_USAGE, "USAGE: /DoneReport [COMMENT].");
		if(pVar[playerid].Report == NO_REPORT) return sendPlayerMessage(playerid, COLOR_USAGE, "You are not taking care of any report right now.");
		sendPlayerMessage(playerid, COLOR_AA, "You have taken care of your report and the reporter has been informed.");
		sendPlayerMessage(pVar[playerid].Report, COLOR_DARKGREEN, "The admin " + nameX(playerid) + " has taken care of your report, with the comment: " + command.slice(cmd[0].len() + 1, command.len));
		return pVar[playerid].Report = NO_REPORT;
	}

New Annotation

Summary:
Author:
Mode:
Body: