This variable dont work?
#1

Hello, why this dont work, it says "this player has not asked a question" even if he does?

Код:
	if(QuestionAsked[playerid] != true) return SendClientMessage(playerid, -1,""chat""COL_RED" This player has not asked a question!");
Reply
#2

Even if he does, does the system know that as long as you don't set QuestionAsked[playerid] to true? No.
Reply
#3

it is set to true here are the commands:

Код:
CMD:ask(playerid, params[])
{
   	new string[128], string2[256];
    if (sscanf(params, "s[256]", Question[playerid])) return SendClientMessage(playerid, -1,""chat" Usage: /ask [question]");
	if(QuestionAsked[playerid] == true) return SendClientMessage(playerid, -1,""chat""COL_RED" Wait for the response of your previous question!");
	SendClientMessage(playerid,-1,""chat""COL_RED" Your question has been successfully sent to admins!");
	format(string, sizeof(string),""chat" {FF0000}%s (%d) has asked a question, use /answer %d to answer it!", PlayerName(playerid),playerid,playerid);
	SendMessageToAllAdmins(string, -1);
	format(string2, sizeof(string2),""chat" {FF0000}Question: %s", Question[playerid]);
	SendMessageToAllAdmins(string2, -1);
	QuestionAsked[playerid] = true;
	return 1;
}

CMD:answer(playerid, params[])
{
	new targetid, string[256], string2[256];
	if (sscanf(params, "is[256]", targetid, string)) return SendClientMessage(playerid,-1,""chat" Usage: /answer [playerid] [answer]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1,""chat""COL_RED" Player is not connected/online.");
	if(QuestionAsked[playerid] != true) return SendClientMessage(playerid, -1,""chat""COL_RED" This player has not asked a question!");
	QuestionAsked[playerid] = false;
	SendClientMessage(playerid,-1,""chat""COL_RED" Your answer has been successfully sent!");
	format(string2, sizeof(string2),""chat""COL_RED" Answer: %s", string);
	SendClientMessage(targetid, -1, string2);
	SendClientMessage(targetid,-1,""chat""COL_RED" Your question got answered.");
	return 1;
}
Reply
#4

You need to check and set the variable for the targetid, not the playerid.

pawn Код:
if(QuestionAsked[targetid] != true) return SendClientMessage(playerid, -1,""chat""COL_RED" This player has not asked a question!");
QuestionAsked[targetid] = false;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)