Untested as balls but here, i had some free time:
pawn Код:
new bool:HasReported[MAX_PLAYERS];
new ReportExpireTimer[MAX_PLAYERS];
forward ExpireReport(playerid);
stock ABroadCast(Color, BroadCastString[])
{
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, Color, BroadCastString);
}
}
return 1;
}
public OnGameModeInit()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
HasReported[i] = false;
ReportExpireTimer[i] = -1;
}
}
public OnGameModeExit()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
KillTimer(ReportExpireTimer[i])
}
}
public OnPlayerConnect(playerid)
{
HasReported[playerid] = false;
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
dcmd(answer, 6, cmdtext);
dcmd(help, 4, cmdtext);
return 0;
}
public ExpireReport(playerid)
{
if(HasReported[playerid])
{
HasReported[playerid] = false;
SendClientMessage(playerid, 0xFFFFFFFF, "Your HelpRequest has expired.");
KillTimer(ReportExpireTimer[playerid]);
ReportExpireTimer[playerid] = -1;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1001)
{
if(response)
{
if(strlen(inputtext) >= 3 && strlen(inputtext) <= 128)
{
HasReported[playerid] = true;
ABroadCast(0xFFFF00FF, inputtext);
ReportExpireTimer[playerid] = SetTimerEx("ExpireReport", 60000, false, "i", playerid); //Expires in 60k milliseconds (1 minute)
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - Invalid Length (3-128)");
}
}
}
return 1;
}
dcmd_help(playerid)
{
if(!HasReported[playerid])
{
ShowPlayerDialog(playerid, 1001, DIALOG_STYLE_INPUT, "Help {FFFFFF}Request", "Please enter a HelpRequest message.\nEnsure it is no shorter than 3 and no longer than 128 characters", "OK", "Cancel");
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - You still have a pending HelpRequest");
}
return 1;
}
dcmd_answer(playerid, params[])
{
new ReturnString[128];
new AdminName[MAX_PLAYER_NAME];
new TargetID;
if(IsPlayerAdmin(playerid))
{
GetPlayerName(playerid, AdminName, sizeof(AdminName));
if(sscanf(params, "us[128]", TargetID, ReturnString) == 0)
{
if(IsPlayerConnected(TargetID)
{
if(HasReported[TargetID])
{
if(strlen(ReturnString) >= 3 && strlen(ReturnString) <= 128)
{
new FormatString[256];
format(FormatString, sizeof(FormatString), "Answer From %s: %s", AdminName, ReturnString);
SendClientMessage(TargetID, 0xFFFF00FF, FormatString);
HasReported[TargetID] = false;
KillTimer(ReportExpireTimer[TargetID]);
ReportExpireTimer[TargetID] = -1;
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - Invalid Length (3-128).");
}
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - That player has not submitted a HelpRequest");
}
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - Specified player is not connected.");
}
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /answer [PlayerID/PartOfName] [Answer String]");
}
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Error - Not Authorized");
}
return 1;
}