// Скрипт сделал DuMBaSS

#include <a_samp>

new PlayerInJob[MAX_PLAYERS];
new Meshki[MAX_PLAYERS];
new Meshok[MAX_PLAYERS];
new gryz1;
new gryz2;
new gryz3;
new Oldskin2[MAX_PLAYERS];

#define COLOR_RED 0xAA3333AA
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_LIGHTBLUE 0x33CCFFAA

#pragma tabsize 0


// ОБРАТИТЕ ВНИМАНИЕ НА СТРОКУ 129

forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

public OnFilterScriptInit()
{
   CreateObject(2060,2172.89526367,-2256.86108398,12.46142387,0.00000000,0.00000000,44.00000000);
   CreateObject(2060,2172.89453125,-2256.86035156,12.46142387,0.00000000,0.00000000,43.99475098);
   CreateObject(2060,2172.42309570,-2256.42822266,12.46099281,0.00000000,0.00000000,47.25003052);
   CreateObject(2060,2173.31835938,-2257.36694336,12.46148300,0.00000000,0.00000000,43.75000000);
   CreateObject(2060,2172.75854492,-2256.49853516,12.77687645,0.00000000,0.00000000,315.24987793);
   CreateObject(2060,2172.41381836,-2256.85815430,12.77693558,0.00000000,0.00000000,316.25000000);
   CreateObject(2060,2173.61865234,-2257.31201172,12.77693558,0.00000000,0.00000000,136.00000000);
   CreateObject(2060,2173.29321289,-2257.70800781,12.77693558,0.00000000,0.00000000,134.00000000);
   CreateObject(2060,2173.73193359,-2257.77856445,12.46504116,0.00000000,0.00000000,42.00000000);
   CreateObject(2060,2172.61962891,-2256.63281250,13.09232903,0.00000000,0.00000000,0.00000000);
   CreateObject(2060,2229.29809570,-2286.05883789,13.53178787,0.00000000,0.00000000,226.00000000);
   CreateObject(2060,2229.61987305,-2286.45825195,13.53178787,0.00000000,0.00000000,45.00000000);
   CreateObject(2060,2230.00610352,-2286.81738281,13.53178787,0.00000000,0.00000000,44.00000000);
   CreateObject(2060,2230.39746094,-2287.23168945,13.53178787,0.00000000,0.00000000,44.00000000);
   CreateObject(2060,2229.35400391,-2286.54858398,13.80724049,0.00000000,0.00000000,134.00000000);
   CreateObject(2060,2230.20898438,-2286.95312500,13.82723999,0.00000000,0.00000000,102.00000000);
   gryz1 = CreatePickup(1239, 23, 2137.8227539063,-2282.4379882813,20.671875, -1);
   gryz2 = CreatePickup(1239, 23, 2127.6430664063,-2275.4113769531,20.671875, -1);
   gryz3 = CreatePickup(1239, 23, 2182.0974121094,-2252.8625488281,14.7734375, -1);
   Create3DTextLabel("[Раздевалка]\nВстань на иконку чтобы надеть рабочую одежду",0x0000FFAA,2137.8227539063,-2282.4379882813,20.671875,40.0,0, 1);
   Create3DTextLabel("[Касса]\nВстань на иконку чтобы получить зарплату",0x0000FFAA,2127.6430664063,-2275.4113769531,20.671875,40.0,0, 1);
   Create3DTextLabel("Помощь по работе",0x0000FFAA,2182.0974121094,-2252.8625488281,14.7734375,40.0,0, 1);

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
PlayerInJob[playerid] = 0;
	Meshok[playerid] = 0;
    Meshki[playerid] = 0;
    Oldskin2[playerid] = 0;
	return 1;
	}


public OnPlayerUpdate(playerid)
 {

   new animlib[32];
   new animname[32];

  if(Meshok[playerid] == 1){
 GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
 if(strcmp(animname, "IDLE_STANCE", true) != 0 && strcmp(animname, "RUN_CIVI", true) != 0 && strcmp(animname, "WALK_CIVI", true) != 0 && strcmp(animname, "crry_prtial", true) != 0 && strcmp(animname, "SPRINT_PANIC", true) != 0 && strcmp(animname, "RUN_PLAYER", true) != 0 && strcmp(animname, "WALK_PLAYER", true) != 0 && strcmp(animname, "SPRINT_CIVI", true) != 0){
 Meshok[playerid] = 0;
 SendClientMessage(playerid, COLOR_RED, "Вы уронили мешок!");
 if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
 ApplyAnimation(playerid,"PED","IDLE_tired",4.1,0,1,1,0,1);
 SetPlayerCheckpoint(playerid,2230.8132324219,-2285.7043457031,13.531787872314,2.0);
  }
 }
 return 1;
 }


public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == gryz1) {
    ShowPlayerDialog(playerid,102,DIALOG_STYLE_MSGBOX,"Раздевалка","Вы хотите переодеться чтобы начать работу?","да","нет");
	}

	if(pickupid == gryz2) {
    ShowPlayerDialog(playerid,103,DIALOG_STYLE_MSGBOX,"Касса","Вы хотите получить зарплату и закончить работу?","да","нет");
	}

	if(pickupid == gryz3) {
    ShowPlayerDialog(playerid,104,DIALOG_STYLE_MSGBOX,"Помощь","1. Чтобы начать работу зайдите в это здание и переоденьтесь в рабочую одежду\n2. На вашей карте появится чекпоинт, идите на него чтобы взять мешок\n3. Отнесите мешок на склад и идите за новым мешком\n4. Когда отнесете нужное вам количество мешков\nприходите в кассу за зарплатой, она находится рядом с раздевалкой","ОК","");
	}
	return 1;
  }

public OnPlayerEnterCheckpoint(playerid)
{
   new string[256];
   if(PlayerToPoint(2.0, playerid,2230.8132324219,-2285.7043457031,13.531787872314))
	  {
	  Meshok[playerid] = 1;
	  ApplyAnimation(playerid,"CARRY","crry_prtial",4.1,0,1,1,1,1);
	  SetPlayerAttachedObject(playerid, 2, 2060, 5, 0.01, 0.1, 0.2, 100, 10, 85);
    SetPlayerCheckpoint(playerid,2172.1313476563,-2255.2292480469,12.454199790955,2.0);
    }

    if(PlayerToPoint(2.0, playerid,2172.1313476563,-2255.2292480469,12.454199790955))
	  {
	  Meshok[playerid] = 0;
	  ApplyAnimation(playerid,"PED","IDLE_tired",4.1,0,1,1,0,1);
	  Meshki[playerid]++;
	  if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
	  format(string, sizeof(string), "Мешков перетащено {A52A2A}%d",Meshki[playerid]);
	  SendClientMessage(playerid, COLOR_SYSTEM, string);
    SetPlayerCheckpoint(playerid,2230.8132324219,-2285.7043457031,13.531787872314,2.0);
    }
    
	return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

       if(dialogid == 103) // касса
    {
    new string[128];
    if(response){
    if(!PlayerInJob[playerid]){
    SendClientMessage(playerid, COLOR_RED, "Вы не на работе");
    SendClientMessage(playerid, COLOR_RED, "Переоденьтесь в раздевалке чтобы начать работу");
	return 1;
	}
    PlayerInJob[playerid] = 0;
	SetPlayerSkin(playerid, Oldskin2[playerid]);
    DisablePlayerCheckpoint(playerid);
    GivePlayerMoney(playerid, Meshki[playerid]*50); // ВНИАНИЕ!!! ЗАМЕНИТЕ GivePlayerMoney НА ПЕРЕМЕННУЮ ВЫДАЧИ ДЕНЕГ ДЛЯ ВАШЕГО МОДА
    format(string, sizeof(string), "{FFFAFA}Вы получили {228B22}%d$ {FFFAFA}за {A52A2A}%d {FFFAFA}мешка(ов)",Meshki[playerid]*50,Meshki[playerid]);
    SendClientMessage(playerid, COLOR_SYSTEM, string);
    Meshki[playerid] = 0;
	}
	return 1;
  }

     if(dialogid == 102) //раздевалка
    {
    if(response){
    if(PlayerInJob[playerid]){
    SendClientMessage(playerid, COLOR_RED, "Вы уже на работе");
    SendClientMessage(playerid, COLOR_RED, "Если хотите закончить рабочий день, идите в кассу");
	return 1;
	}
    PlayerInJob[playerid] = 1;
	Oldskin2[playerid] = GetPlayerSkin(playerid);
	SetPlayerSkin(playerid, 16);
	SetPlayerCheckpoint(playerid,2230.8132324219,-2285.7043457031,13.531787872314,2.0);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, "На вашей карте отмечен чекпоинт");
	SendClientMessage(playerid, COLOR_LIGHTBLUE, "Идите к нему чтобы взять мешок");
	}
	return 1;
  }
	return 1;
}

																								                           // (c)DuMBaSS All rights reserved
