
#include <a_samp>
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA

new Menu:VMenu;
new Menu:Menu1;
new Menu:Menu2;
new Menu:Menu3;

public OnFilterScriptInit()
{
	print("\n----------------------------------");
	print("         Magazin by eXtreme");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	VMenu = CreateMenu("Vehicle Magazine", 2, 150.0, 250.0, 150.0, 150.0);
	Menu1 = CreateMenu("Vehicle Magazine", 2, 150.0, 250.0, 150.0, 150.0);
	Menu2 = CreateMenu("Vehicle Magazine", 2, 150.0, 250.0, 150.0, 150.0);
	Menu3 = CreateMenu("Vehicle Magazine", 2, 150.0, 250.0, 150.0, 150.0);
    SetMenuColumnHeader(VMenu, 0, "TYPE VEHICLE");
    SetMenuColumnHeader(VMenu, 1, " ");
    AddMenuItem(VMenu, 0, "Sports");
    AddMenuItem(VMenu, 1, " ");
    AddMenuItem(VMenu, 0, "Bike");
    AddMenuItem(VMenu, 1, " ");
    AddMenuItem(VMenu, 0, "STreet-Race");
    AddMenuItem(VMenu, 1, " ");
    SetMenuColumnHeader(Menu1, 0, "NAME");
    SetMenuColumnHeader(Menu1, 1, "MONEY");
    AddMenuItem(Menu1, 0, "Turismo");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, "Infernus");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, "Bullet");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, "Comet");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, "Buffalo");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, "Banshee");
    AddMenuItem(Menu1, 1, "1000$");
    AddMenuItem(Menu1, 0, " ");
    AddMenuItem(Menu1, 1, "~y~BACK");
    SetMenuColumnHeader(Menu2, 0, "NAME");
    SetMenuColumnHeader(Menu2, 1, "MONEY");
    AddMenuItem(Menu2, 0, "BF400");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, "FCR900");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, "NRG500");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, "PCJ600");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, "Sanchez");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, "Freeway");
    AddMenuItem(Menu2, 1, "1000$");
    AddMenuItem(Menu2, 0, " ");
    AddMenuItem(Menu2, 1, "~y~BACK");
    SetMenuColumnHeader(Menu3, 0, "NAME");
    SetMenuColumnHeader(Menu3, 1, "MONEY");
    AddMenuItem(Menu3, 0, "Phoenix");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, "FCR900");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, "NRG500");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, "PCJ600");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, "Sanchez");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, "Freeway");
    AddMenuItem(Menu3, 1, "1000$");
    AddMenuItem(Menu3, 0, " ");
    AddMenuItem(Menu3, 1, "~y~BACK");
}
public OnGameModeExit()
{
	return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/carbuy",cmdtext,true,10)) {
    if(IsValidMenu(VMenu)) ShowMenuForPlayer(VMenu, playerid);
    TogglePlayerControllable(playerid, 0);
    return 1;
}
	return 0;
}
public OnPlayerSelectedMenuRow(playerid,row) {
    new Menu:Current = GetPlayerMenu(playerid);
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    if(Current == VMenu) {
        switch(row) {
            case 0: ShowMenuForPlayer(Menu1, playerid);
            case 1: ShowMenuForPlayer(Menu2, playerid);
            case 2: ShowMenuForPlayer(Menu3, playerid);
        }
    }

    if(Current == Menu1) {
    switch(row) {
    case 0: CreateV(playerid,451, 1000);
    case 1: CreateV(playerid,411, 1000);
    case 2: CreateV(playerid,541, 1000);
    case 3: CreateV(playerid,480, 1000);
    case 4: CreateV(playerid,402, 1000);
    case 5: CreateV(playerid,429, 1000);
    case 6: ShowMenuForPlayer(VMenu, playerid);
        }
	}
    if(Current == Menu2) {
    switch(row) {
    case 0: CreateV(playerid,581,1000);
    case 1: CreateV(playerid,521,1000);
    case 2: CreateV(playerid,522,1000);
    case 3: CreateV(playerid,461,1000);
    case 4: CreateV(playerid,468,1000);
    case 5: CreateV(playerid,463,1000);
    case 6: ShowMenuForPlayer(VMenu, playerid);
	   }
	}
    if(Current == Menu3) {
    switch(row) {
    case 0: CreateV(playerid,603,1000);
    case 1: CreateV(playerid,521,1000);
    case 2: CreateV(playerid,522,1000);
    case 3: CreateV(playerid,461,1000);
    case 4: CreateV(playerid,468,1000);
    case 5: CreateV(playerid,463,1000);
    case 6: ShowMenuForPlayer(VMenu, playerid);
	   }
	}
    return 1;
 }

stock CreateV(playerid,vehicletype,money) {
new Float:x, Float:y, Float:z, Float:a;
new string[256];
if (GetPlayerMoney(playerid) > 999) {
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
CreateVehicle(vehicletype, x + 3.0, y + 3.0, z-2, a + 90.0, -1, -1, 5000);
GivePlayerMoney(playerid, -money);
TogglePlayerControllable(playerid, 1);
format(string, sizeof(string), " С вас $%d $", money);
SendClientMessage(playerid, COLOR_GREEN, string);
}else{
    SendClientMessage(playerid, COLOR_RED, "* У тебя не достаточно денег!");
    TogglePlayerControllable(playerid, 1);
	}
}
public OnPlayerExitedMenu(playerid) {
TogglePlayerControllable(playerid, 1);
return 1;
}
