Helper System
#1

I'm currently working on a helper system for my server.

I want it to make it so, when a player asks a /n question, the question will get stored in their playerVariables.
After 30 seconds, the question will be sent to one helper only, so he will be the only one that can answer that question.

This is what I have so far..

Код:
CMD:n(playerid, params[])
{
	if(pInfo[playerid][HasQuestion] == 0)
	{
		if(pInfo[playerid][QuestionTime] == 0)
		{
			new admins, report[256], aName[MAX_PLAYER_NAME];				
			foreach(Player, i)
	     	{
				if(pInfo[i][pHelperLevel] >= 1)
				{
					admins++;
				}
			}
			if(admins == 0) return SendClientMessage(playerid, -1, "There are no helpers online.");
			if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/n(ewbie) [question]");
			GetPlayerName(playerid, aName, sizeof(aName));
			SendClientMessage(playerid, -1, "Your question has been sent to the helpers.");
			format(pInfo[playerid][Question], 256, "%s", report);
			pInfo[playerid][HasQuestion] = 1;
			pInfo[playerid][QuestionAccepted] = 0;
			pInfo[playerid][QuestionTime] = 1;
			SetTimerEx("SendToHelpers", 60000, 0, "d", playerid);
			SetTimerEx("QuestionMute", 60000, 0, "d", playerid);
		}
		else return SendClientMessage(playerid, -1, "You have to wait 60 seconds after your last question.");
	}
	else return SendClientMessage(playerid, -1, "You already have asked something, wait for your question to get answered.");
	return 1;
}
This is the part where I got stuck. I have no idea how I could send the message to only one helper.
Код:
public SendToHelpers(playerid)
{
	foreach(Player, i)
	{
		if(pInfo[i][pHelperLevel] > 0 && pInfo[i][pHelperDuty] == 1 && pInfo[i][hQuestion] == 0)
		{
			
		}
	}
	SendClientMessage(playerid, -1, "You can now use /report again.");
	return 1;
}
Reply
#2

Use break; inside foreach after sending the message that will prevent foreach to iterate further after the message has been sent.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)