Untitled

 avatar
user_0390871
plain_text
a year ago
4.1 kB
1
Indexable
Never
#include <a_samp>

stock question_Dialog(playerid, dialogid, response, const inputtext[])
{
    if(dialogid == DIALOG_QUESTION)
    {
    	if(response)
    	{

			if (isnull(inputtext))
			{
				SendClientMessageEx(playerid, COLOR_GREY, "Ban da huy bo tao cau do.");
				return 1;
			}
			format(CauDo, sizeof(CauDo), inputtext);
			ShowPlayerDialog(playerid, DIALOG_QUESTIONS, DIALOG_STYLE_INPUT, "Tao cau do", "Nhap vao dap an", "Dong y", "Huy bo");
		}
    }

    if(dialogid == DIALOG_QUESTIONS)
    {
    	if(response)
    	{
    	    if (isnull(inputtext))
    	    {
    	        SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Ban da huy bo tao cau do.");
    	        format(CauDo, sizeof(CauDo), "None");
    	        return 1;
    		}
    		new str[128];
    		format(DapAn, sizeof(DapAn), inputtext);
    		TonTaiCauDo = 1;
    		NguoiTaoCauDo = playerid;
    		format(str, sizeof(str), "{C0CEFF}** CAU DO **: {FFFF00}%s", CauDo);
    		SendClientMessageToAllEx(COLOR_YELLOW, str);
    		SendClientMessageToAllEx(COLOR_YELLOW, "{C0CEFF}** CAU DO **: {FFFF00}Su dung /traloicaudo [noi dung] de tra loi.");
    	}
    	else
    	{
    		format(CauDo, sizeof(CauDo), "None");
    		SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Ban da huy bo tao cau do.");
    	}
    }
    return 1;
}

CMD:traloicaudo(playerid, params[])
{
	new CauTraLoi[32];
	new string[128];
	if (TonTaiCauDo == 1)
	{
		if (NguoiTaoCauDo == playerid)
			return SendClientMessageEx(playerid, COLOR_GREY, "Ban khong the tra loi cau do cua ban than.");

		if (sscanf(params, "s[32]", CauTraLoi))
			return SendClientMessageEx(playerid, COLOR_GREY, "Su dung: /traloicaudo [noi dung]");

		if (!strcmp(CauTraLoi, DapAn, true))
		{
			format(string, sizeof(string), "{C0CEFF}** CAU DO **: {FFFF00}Dap an la '%s'", DapAn);
			SendClientMessageToAllEx(COLOR_YELLOW, string);
			new rand = random(3);
			switch (rand)
			{
				case 0:
				{
					format(string, sizeof(string), "{C0CEFF}** CAU DO **: {FFFF00}%s da tra loi dung va nhan duoc phan thuong 100,000 SAD.", GetPlayerNameEx(playerid));
					SendClientMessageToAllEx(COLOR_YELLOW, string);
					GivePlayerCash(playerid, 100000);
				}
				case 1:
				{
					format(string, sizeof(string), "{C0CEFF}** CAU DO **: {FFFF00}%s da tra loi dung va nhan duoc phan thuong 10,000 vat lieu.", GetPlayerNameEx(playerid));
					SendClientMessageToAllEx(COLOR_YELLOW, string);
					PlayerInfo[playerid][pMats] += 10000;
				}
				case 2:
				{
					format(string, sizeof(string), "{C0CEFF}** CAU DO **: {FFFF00}%s da tra loi dung va nhan duoc phan thuong 1,000 Credits.", GetPlayerNameEx(playerid));
					SendClientMessageToAllEx(COLOR_YELLOW, string);
					PlayerInfo[playerid][pCredits] += 1000;
				}
			}
			TonTaiCauDo = 0;
			NguoiTaoCauDo = INVALID_PLAYER_ID;
			format(CauDo, sizeof(CauDo), "None");
			format(DapAn, sizeof(DapAn), "None");
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_GRAD2, "Ban da tra loi sai.");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GREY, "Chua co cau do nao duoc tao.");
	return 1;
}

CMD:taocaudo(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 99999)
	{
 		if(TonTaiCauDo != 0)
			SendClientMessageEx(playerid, COLOR_GREY, "Da co cau do. /xoacaudo de dat cau do moi.");
		else
			ShowPlayerDialog(playerid, DIALOG_QUESTION, DIALOG_STYLE_INPUT, "Tao cau do", "Nhap vao cau hoi:", "Tiep tuc", "Huy bo");
	}
	else 
		SendClientMessageEx(playerid, COLOR_GREY, "Ban khong the su dung lenh nay.");
	return 1;
}

CMD:xoacaudo(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 99999)
	{
		if(TonTaiCauDo == 1)
		{
	 		TonTaiCauDo = 0;
	 		NguoiTaoCauDo = INVALID_PLAYER_ID;
			format(CauDo, sizeof(CauDo), "None");
			format(DapAn, sizeof(DapAn), "None");
			SendClientMessageEx(playerid, COLOR_YELLOW, "Da xoa cau do.");
		}
		else return SendClientMessageEx(playerid, COLOR_GREY, "Chua co cau do nao duoc tao.");
	}
	else return SendClientMessageEx(playerid, COLOR_GREY, "Ban khong the su dung lenh nay.");
	return 1;
}