Доступ к готовым решениям

Переход в группу "Пользователь"

300.00
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Мануал Мини игра - Прокачай меткость

#Rips

Эксперт
Пользователь
Регистрация
16 Дек 2015
Сообщения
1,737
Лучшие ответы
0
Репутация
499
Здравствуйте уважаемые пользователи портала.
Сегодня я бы хотел предоставить копию игры с проекта Monser Gang War.
[HR][/HR]

Что требуется для работы:
1. Командный процессор: DC_CMD / Pawn.CMD
2. Можете скачать данную систему с ЯндексДиска:

Недочеты:
1. Вывод список топ игроков игры
2. Сохранение очков игрока




1. Ко всем переменным:
PHP:
static

    Text:gBackGrounds[5],                    // Задний фон игры
    TimerPlayer[MAX_PLAYERS], 				 // Время на набратие очков
	ScorePlayer[MAX_PLAYERS],                // Количество очков у игрока
	MouseClickChit[MAX_PLAYERS],             // Нажал ли игрок на синий шар, или же нет
    TimerPlayerGame[MAX_PLAYERS char],       // Переменная на удаление таймера после выхода из игры
    CheckGamePlayer[MAX_PLAYERS char],       // Проверка на то, что игрок играет в нее или нет
    PlayerText:pInformation[MAX_PLAYERS][6]; // Информация о игроке

static const Float:random_coords_chit[19][2] = // Коориданы данного шарика/точки
{
	{179.5000, 44.2444},
	{520.0000, 67.2666},
	{48.0000, 207.2666},
	{414.0000, 321.7555},
	{84.5000, 339.8000},
	{285.0000, 171.7999},
	{259.5000, 263.2666},
	{434.5000, 139.4443},
	{335.5000, 46.1110},
	{554.5000, 184.2443},
	{598.5000, 423.7999},
	{304.0000, 410.7332},
	{160.0000, 146.2888},
	{448.5000, -2.4222},
	{42.5000, 427.5333},
	{20.5000, 89.0444},
	{482.0000, 271.3556},
	{392.0000, 227.1778},
	{175.5000, 235.8889}
};
2. В коллбэк OnPlayerConnect, OnPlayerDisconnect:
PHP:
 	KillTimer(TimerPlayerGame{playerid});
    MouseClickChit[playerid] = 0;
    ScorePlayer[playerid] = 0;
    TimerPlayer[playerid] = 0;
    CheckGamePlayer{playerid} = 0;
3. Создаем stock StartGameMonser, HideGameMonser, Convert:
PHP:
stock HideGameMonser(playerid)
{
    for(new i; i < 6; i++) PlayerTextDrawHide(playerid, pInformation[playerid][i]); // Скрываем информацию игры
	for(new i; i != sizeof(gBackGrounds); i++) TextDrawHideForPlayer(playerid, gBackGrounds[i]); // Скрываем задний фон
	TextDrawDestroy(gBackGrounds[3]); // Удаляем синей шарик
	CancelSelectTextDraw(playerid); // Убираем курсор
	KillTimer(TimerPlayerGame{playerid}); // Удаляем таймер
	CheckGamePlayer{playerid} = 0; // Обнуление переменной
    TimerPlayer[playerid] = 0;
    MouseClickChit[playerid] = 0;
    ScorePlayer[playerid] = 0;
	return 1;
}
stock StartGameMonser(playerid)
{
	// Задний фон
    gBackGrounds[0] = TextDrawCreate(-3.5000, -1.1778, "LD_SPAC:white"); // пусто
	TextDrawTextSize(gBackGrounds[0], 651.0000, 468.0000);
	TextDrawAlignment(gBackGrounds[0], 1);
	TextDrawColor(gBackGrounds[0], 606348543);
	TextDrawBackgroundColor(gBackGrounds[0], 255);
	TextDrawFont(gBackGrounds[0], 4);
	TextDrawSetProportional(gBackGrounds[0], 0);
	TextDrawSetShadow(gBackGrounds[0], 0);

	gBackGrounds[1] = TextDrawCreate(495.5000, 293.7555, "LD_SPAC:white"); // пусто
	TextDrawTextSize(gBackGrounds[1], 146.0000, 44.0000);
	TextDrawAlignment(gBackGrounds[1], 1);
	TextDrawColor(gBackGrounds[1], 303174399);
	TextDrawBackgroundColor(gBackGrounds[1], 255);
	TextDrawFont(gBackGrounds[1], 4);
	TextDrawSetProportional(gBackGrounds[1], 0);
	TextDrawSetShadow(gBackGrounds[1], 0);

	gBackGrounds[2] = TextDrawCreate(495.5000, 339.8000, "LD_SPAC:white"); // пусто
	TextDrawTextSize(gBackGrounds[2], 146.0000, 33.0000);
	TextDrawAlignment(gBackGrounds[2], 1);
	TextDrawColor(gBackGrounds[2], 303174399);
	TextDrawBackgroundColor(gBackGrounds[2], 255);
	TextDrawFont(gBackGrounds[2], 4);
	TextDrawSetProportional(gBackGrounds[2], 0);
	TextDrawSetShadow(gBackGrounds[2], 0);
	
	// Синий шарик
	new rand = random(18);

	gBackGrounds[3] = TextDrawCreate(random_coords_chit[rand][0], random_coords_chit[rand][1], "LD_BEAT:chit"); // Шарик
	TextDrawTextSize(gBackGrounds[3], 15.0000, 19.0000);
	TextDrawAlignment(gBackGrounds[3], 1);
	TextDrawColor(gBackGrounds[3], 65535);
	TextDrawBackgroundColor(gBackGrounds[3], 255);
	TextDrawFont(gBackGrounds[3], 4);
	TextDrawSetProportional(gBackGrounds[3], 0);
	TextDrawSetShadow(gBackGrounds[3], 0);
	TextDrawSetSelectable(gBackGrounds[3], true);
	
	// Информация
	
	pInformation[playerid][0] = CreatePlayerTextDraw(playerid, 573.5000, 296.4000, "GAME_TIME_-_0:00"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][0], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][0], 2);
	PlayerTextDrawColor(playerid, pInformation[playerid][0], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][0], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][0], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][0], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][0], 0);

	pInformation[playerid][1] = CreatePlayerTextDraw(playerid, 500.0000, 305.7221, "SCORE_-_0~n~BEST_GAME:_0"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][1], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][1], 1);
	PlayerTextDrawColor(playerid, pInformation[playerid][1], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][1], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][1], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][1], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][1], 0);

	pInformation[playerid][2] = CreatePlayerTextDraw(playerid, 569.5000, 325.4888, "BEST_PLAYER_AND_SCORE"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][2], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][2], 2);
	PlayerTextDrawColor(playerid, pInformation[playerid][2], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][2], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][2], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][2], 0);

	pInformation[playerid][3] = CreatePlayerTextDraw(playerid, 498.5000, 343.6777, "1. NONE"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][3], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][3], 1);
	PlayerTextDrawColor(playerid, pInformation[playerid][3], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][3], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][3], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][3], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][3], 0);

	pInformation[playerid][4] = CreatePlayerTextDraw(playerid, 498.5000, 351.6782, "2. NONE"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][4], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][4], 1);
	PlayerTextDrawColor(playerid, pInformation[playerid][4], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][4], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][4], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][4], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][4], 0);

	pInformation[playerid][5] = CreatePlayerTextDraw(playerid, 498.5000, 359.7787, "3. NONE"); // пусто
	PlayerTextDrawLetterSize(playerid, pInformation[playerid][5], 0.2250, 0.9466);
	PlayerTextDrawAlignment(playerid, pInformation[playerid][5], 1);
	PlayerTextDrawColor(playerid, pInformation[playerid][5], -1);
	PlayerTextDrawBackgroundColor(playerid, pInformation[playerid][5], 255);
	PlayerTextDrawFont(playerid, pInformation[playerid][5], 2);
	PlayerTextDrawSetProportional(playerid, pInformation[playerid][5], 1);
	PlayerTextDrawSetShadow(playerid, pInformation[playerid][5], 0);
	
	for(new i; i != sizeof(gBackGrounds); i++) TextDrawShowForPlayer(playerid, gBackGrounds[i]); // Показываем задний фон и синий шарик
	for(new i; i < 6; i++) PlayerTextDrawShow(playerid, pInformation[playerid][i]); // Показываем информацию игры
	
	TimerPlayer[playerid] = 180;
	CheckGamePlayer{playerid} = 1; // Приравниваем к перменной
	SelectTextDraw(playerid, 0xFF9900FF);
	new string[16];
	format(string, sizeof(string), "GAME TIME: %s", Convert(TimerPlayer[playerid]));
	PlayerTextDrawSetString(playerid, pInformation[playerid][0], string);
	TimerPlayerGame{playerid} = SetTimerEx("@__StartGameMonserTimer", 1400, true, "d", playerid);
	
	return 1;
}

Convert(number)
{
	new hours = 0, mins = 0, secs = 0, string[100];
	hours = floatround(number / 3600);
	mins = floatround((number / 60) - (hours * 60));
	secs = floatround(number - ((hours * 3600) + (mins * 60)));
	if(hours > 0) { format(string, 100, "%i:%02dm:%02ds", hours, mins, secs); }
	else { format(string, 100, "%i:%02d", mins, secs); }
	return string;
}
4. В коллбэк OnPlayerClickPlayerTextDraw:
PHP:
if(_:clickedid == INVALID_TEXT_DRAW && 1 == CheckGamePlayer{playerid}) return SelectTextDraw(playerid, 0xFF9900FF);
	
	if(clickedid == gBackGrounds[3])
	{
	    if(MouseClickChit[playerid] == 1)
	    {
		    TextDrawHideForPlayer(playerid, gBackGrounds[3]);
            MouseClickChit[playerid] = 1;
			new rand = random(18);
		    gBackGrounds[3] = TextDrawCreate(random_coords_chit[rand][0], random_coords_chit[rand][1], "LD_BEAT:chit"); // Шарик
			TextDrawTextSize(gBackGrounds[3], 15.0000, 19.0000);
			TextDrawAlignment(gBackGrounds[3], 1);
			TextDrawColor(gBackGrounds[3], 65535);
			TextDrawBackgroundColor(gBackGrounds[3], 255);
			TextDrawFont(gBackGrounds[3], 4);
			TextDrawSetProportional(gBackGrounds[3], 0);
			TextDrawSetShadow(gBackGrounds[3], 0);
			TextDrawSetSelectable(gBackGrounds[3], true);

		    TextDrawShowForPlayer(playerid, gBackGrounds[3]);
		    ScorePlayer[playerid] -= 150;

		    static const form_one[] = "SCORE_-_%i~n~BEST_GAME:_0";
			new string[sizeof(form_one)+(-2+22)];
			format(string, sizeof(string), form_one, ScorePlayer[playerid]);
			PlayerTextDrawSetString(playerid, pInformation[playerid][1], string);
		}
		else
		{
  			TextDrawHideForPlayer(playerid, gBackGrounds[3]);
            MouseClickChit[playerid] = 0;
			new rand = random(18);
		    gBackGrounds[3] = TextDrawCreate(random_coords_chit[rand][0], random_coords_chit[rand][1], "LD_BEAT:chit"); // Шарик
			TextDrawTextSize(gBackGrounds[3], 15.0000, 19.0000);
			TextDrawAlignment(gBackGrounds[3], 1);
			TextDrawColor(gBackGrounds[3], 65535);
			TextDrawBackgroundColor(gBackGrounds[3], 255);
			TextDrawFont(gBackGrounds[3], 4);
			TextDrawSetProportional(gBackGrounds[3], 0);
			TextDrawSetShadow(gBackGrounds[3], 0);
			TextDrawSetSelectable(gBackGrounds[3], true);

		    TextDrawShowForPlayer(playerid, gBackGrounds[3]);
		    ScorePlayer[playerid] += 300;

		    static const form_one[] = "SCORE_-_%i~n~BEST_GAME:_0";
			new string[sizeof(form_one)+(-2+22)];
			format(string, sizeof(string), form_one, ScorePlayer[playerid]);
			PlayerTextDrawSetString(playerid, pInformation[playerid][1], string);
		}
	}
5. Ко всем коллбэкам:
PHP:
@__StartGameMonserTimer(playerid);
@__StartGameMonserTimer(playerid)
{
	if( --TimerPlayer[playerid] != 0)
	{
		new string[16];
		format(string, sizeof(string), "GAME TIME: %s", Convert(TimerPlayer[playerid]));
		PlayerTextDrawSetString(playerid, pInformation[playerid][0], string);
	}
	else return HideGameMonser(playerid);

	if(MouseClickChit[playerid] == 0)
	{
	    TextDrawHideForPlayer(playerid, gBackGrounds[3]);
		new rand = random(18);
	    gBackGrounds[3] = TextDrawCreate(random_coords_chit[rand][0], random_coords_chit[rand][1], "LD_BEAT:chit"); // Шарик
		TextDrawTextSize(gBackGrounds[3], 15.0000, 19.0000);
		TextDrawAlignment(gBackGrounds[3], 1);
		TextDrawColor(gBackGrounds[3], 65535);
		TextDrawBackgroundColor(gBackGrounds[3], 255);
		TextDrawFont(gBackGrounds[3], 4);
		TextDrawSetProportional(gBackGrounds[3], 0);
		TextDrawSetShadow(gBackGrounds[3], 0);
		TextDrawSetSelectable(gBackGrounds[3], true);
	    TextDrawShowForPlayer(playerid, gBackGrounds[3]);

		static const form_one[] = "SCORE_-_%i~n~BEST_GAME:_0";
		new string[sizeof(form_one)+(-2+22)];
		format(string, sizeof(string), form_one, ScorePlayer[playerid]);
		PlayerTextDrawSetString(playerid, pInformation[playerid][1], string);
		
		MouseClickChit[playerid] = 0;
		if(ScorePlayer[playerid] - 1 >= 0) ScorePlayer[playerid] -= 150;

	}
	else
	{
	    TextDrawHideForPlayer(playerid, gBackGrounds[3]);
		new rand = random(18);
	    gBackGrounds[3] = TextDrawCreate(random_coords_chit[rand][0], random_coords_chit[rand][1], "LD_BEAT:chit"); // Шарик
		TextDrawTextSize(gBackGrounds[3], 15.0000, 19.0000);
		TextDrawAlignment(gBackGrounds[3], 1);
		TextDrawColor(gBackGrounds[3], 65535);
		TextDrawBackgroundColor(gBackGrounds[3], 255);
		TextDrawFont(gBackGrounds[3], 4);
		TextDrawSetProportional(gBackGrounds[3], 0);
		TextDrawSetShadow(gBackGrounds[3], 0);
		TextDrawSetSelectable(gBackGrounds[3], true);
	    TextDrawShowForPlayer(playerid, gBackGrounds[3]);
	    
	    MouseClickChit[playerid] = 1;
	    ScorePlayer[playerid] += 300;

	    static const form_one[] = "SCORE_-_%i~n~BEST_GAME:_0";
		new string[sizeof(form_one)+(-2+22)];
		format(string, sizeof(string), form_one, ScorePlayer[playerid]);
		PlayerTextDrawSetString(playerid, pInformation[playerid][1], string);

	}
	return 1;
}
6. Ко всем командам:
PHP:
CMD:game(playerid)
{
	if(1 == CheckGamePlayer{playerid}) return HideGameMonser(playerid);
	ShowPlayerDialog(playerid, 4000, DIALOG_STYLE_MSGBOX, "{FF9900}Информация", "\
		{FFFFFF}Смысл игры заключается в том, чтобы как можно больше раз попасть\n\
		курсором мыши по синему кругу, который появляется в рандомном\n\
		месте на экране. За каждое попадение присваивается 300 очков, за\n\
		каждый промах отнимается 150.\n\n\
		{FF9900}Для комфортной игры рекомендуем:\n\
		\n\t{FF9900}-{FFFFFF} Отключить чат (клавиша F7)\
		\n\t{FF9900}-{FFFFFF} Отключить килл-чат (клавиша F9)\
		\n\t{FF9900}-{FFFFFF} Включить звук в настройках игры\
		\n\t{FF9900}-{FFFFFF} Оптимальное разрешение экрана для игры не ниже 1024x768x32", "Играть", "Отмена");
	return 1;
}
7. В коллбэк OnDialogResponse:
PHP:
case 4000:
	    {
	        if(!response) return 1;
	        StartGameMonser(playerid);
		}
 
Последнее редактирование:
Сверху Снизу