Advertisement
frog163

Rubbish | Мусорки 1.2

Nov 21st, 2012
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Авторы: frog163 (код), Essle (идея, координаты)
  2. //ver1.2 (21/11/2012) - месяц до конца ;D
  3. #include <a_samp>
  4.  
  5. #define dial_rub            13548
  6. enum rub_inf{rub_eat, rub_id, rub_use, rub_item[5], rub_ticks, rub_spawn};
  7. new pi[MAX_PLAYERS][rub_inf];
  8.  
  9. new Float:coord_rubbish[60][3] = {
  10.     {706.44970, -1868.288, 5.40530},{433.47780, -1747.789, 9.20910},{1020.2922, -1370.158, 13.5557},{2482.2393, -1539.644, 24.0529},{665.22440, -623.3416, 16.3359},{668.25450, -623.4119, 16.3359},
  11.     {1368.2468, 483.17370, 20.0276},{831.17250, -754.8876, 85.3125},{2320.0833, 14.314600, 26.4766},{1919.8068, -2088.174, 13.5803},{1920.1069, -2123.145, 13.5849},{255.37350, -133.6588, 1.57810},
  12.     {259.68970, -133.8148, 1.57810},{1419.9714, -1355.812, 13.5636},{1439.9532, -1324.729, 13.5449},{1424.5007, -1320.657, 13.5547},{1424.5394, -1317.951, 13.5547},{1415.5901, -1300.219, 13.5450},
  13.     {1337.5129, -1816.416, 13.5469},{1337.0326, -1843.056, 13.5469},{1660.7600, -1001.314, 24.0460},{1666.8646, -998.6257, 24.0543},{1829.5341, -1084.263, 23.8814},{1829.5391, -1097.156, 23.8823},
  14.     {1829.5399, -1113.888, 23.8765},{1829.5847, -1143.721, 23.8809},{1829.5399, -1147.461, 23.8822},{1800.3743, -1147.267, 23.8410},{1786.1982, -1147.266, 23.8725},{1788.8701, -1112.512, 24.0859},
  15.     {1788.7521, -1115.898, 24.0859},{2247.2285, -1083.271, 41.6016},{1461.4281, -1488.460, 13.5469},{1633.1481, -991.2181, 24.0776},{1631.0746, -988.4139, 24.0757},{1538.1969, -1849.265, 13.5469},
  16.     {1516.7352, -1849.304, 13.5469},{1486.2128, -1847.384, 13.5469},{1468.7784, -1847.650, 13.5469},{1466.1975, -1847.893, 13.5469},{1420.4850, -1846.494, 13.5469},{1420.4072, -1844.248, 13.5469},
  17.     {1616.6780, -1201.350, 19.8059},{1660.5033, -1201.405, 19.7931},{1593.1951, -1201.409, 19.8159},{1521.2386, -1018.571, 23.9108},{1521.2343, -1014.755, 23.9755},{1425.6398, -1084.340, 17.5536},
  18.     {1425.6172, -1080.487, 17.5583},{1438.1196, -1094.793, 17.6086},{1435.4872, -1094.758, 17.5950},{1612.0013, -994.8882, 24.0781},{1384.5127, -1894.332, 13.4800},{1175.3978, -1878.592, 13.5733},
  19.     {1117.4015, -1876.006, 13.5469},{1102.1302, -1876.006, 13.5469},{1093.0156, -1876.780, 13.5469},{1093.0381, -1881.252, 13.5469},{657.83260, -649.0323, 16.3359},{1337.7872, -1773.970, 13.5469}
  20. };
  21. #define all_item 12
  22. new rub_str[all_item][2][32] = {
  23.     {"Огурец", "съел его"}, {"Тухлое мясо", "съел его"}, {"Молоко", "выпил его"}, {"Помидор", "съел его"}, {"Картошка", "съел ее"}, {"Сметана", "отлизал ее"}, {"Пирожоное", "съел его"},
  24.     {"Кусок хлеба", "съел его"}, {"Морковка", "съел ее"}, {"Тухлая рыба", "съел ее"}, {"Кефир", "выпил его"}, {"Салат", "съел его"}
  25. };
  26. public OnPlayerSpawn(playerid){
  27.     if(!pi[playerid][rub_spawn]){
  28.         ApplyAnimation(playerid,"FOOD","null",0.0,0,0,0,0,0);
  29.         ApplyAnimation(playerid,"BOMBER","null",0.0,0,0,0,0,0);
  30.         pi[playerid][rub_spawn] = true;
  31.     }
  32.     return true;
  33. }
  34. public OnPlayerConnect(playerid){
  35.     pi[playerid][rub_eat] = false;
  36.     pi[playerid][rub_use] = false;
  37.     pi[playerid][rub_spawn] = false;
  38.     return true;
  39. }
  40.  
  41. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
  42.     if(newkeys & KEY_WALK && !pi[playerid][rub_use] && pi[playerid][rub_id] > -1)
  43.         rubbish(playerid);
  44.     return true;
  45. }
  46.  
  47. public OnPlayerUpdate(playerid){
  48.     if(pi[playerid][rub_eat] < 1)pi[playerid][rub_eat] = 0;
  49.     else pi[playerid][rub_eat]--;
  50.     if(pi[playerid][rub_ticks] > GetTickCount())return true;
  51.     if(is_player_in_rubbish(playerid))
  52.         GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~PRESS ~y~~k~~SNEAK_ABOUT~", 1200, 3);
  53.     else pi[playerid][rub_use] = 0;
  54.     pi[playerid][rub_ticks]=((pi[playerid][rub_id]!=-1)?5000:250)+GetTickCount();
  55.     return true;
  56. }
  57.  
  58. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  59.     if(dialogid == dial_rub){
  60.         pi[playerid][rub_use] = false;
  61.         if(!response) return true;
  62.         if(listitem == 5)return rubbish(playerid);
  63.         new str[128];
  64.         ApplyAnimation(playerid, "FOOD", "EAT_Burger", 4.1, 0, 1, 1, 1, 1, 1);
  65.         format(str, sizeof str, "{d4d4d4}Ты достал из мусорки {9DDAF2}%s {d4d4d4}и %s.", rub_str[pi[playerid][rub_item][listitem]][0], rub_str[pi[playerid][rub_item][listitem]][1]);
  66.         SendClientMessage(playerid, -1, str);
  67.         if(pi[playerid][rub_eat] >= 1500+random(1000)){
  68.             pi[playerid][rub_eat] = 0;
  69.             SendClientMessage(playerid, -1, "{fddd00}Твой желудок не справился с таким количеством говна :(");
  70.             ApplyAnimation(playerid, "FOOD", "EAT_Vomit_P", 4.0, 0, 1, 1, 1, 1, 1);
  71.         }else{
  72.             new Float:health;
  73.             GetPlayerHealth(playerid, health);
  74.             health += random(10)+3;
  75.             SetPlayerHealth(playerid, health>100.0?100.0:health);
  76.             pi[playerid][rub_eat] += 1000;
  77.         }
  78.     }
  79.     return true;
  80. }
  81. forward rubbish(playerid);
  82. public rubbish(playerid){
  83.     switch(pi[playerid][rub_use]++){
  84.         case 0:{
  85.             turn_player_face_to_coord(playerid, coord_rubbish[pi[playerid][rub_id]][0], coord_rubbish[pi[playerid][rub_id]][1]);
  86.             ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.1, 1, 1, 1, 1, 5500, 1);
  87.             SetTimerEx("rubbish", 5000, false, "d", playerid);
  88.             SetPlayerChatBubble(playerid, "Роется в мусорке", 0x00FF00FF, 30.0, 5000);
  89.         }
  90.         case 1:show_rubdialog(playerid);
  91.     }
  92.     return true;
  93. }
  94. turn_player_face_to_coord(playerid, Float:x, Float:y){
  95.     new Float:pPos[3];
  96.     GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  97.     SetPlayerFacingAngle(playerid, 180.0-atan2(pPos[0] - x, pPos[1] - y));
  98.     return true;
  99. }  
  100. is_player_in_rubbish(playerid){
  101.     for(new f = sizeof coord_rubbish -1; f != -1; --f)
  102.         if(IsPlayerInRangeOfPoint(playerid, 1.0, coord_rubbish[f][0], coord_rubbish[f][1], coord_rubbish[f][2])){
  103.             pi[playerid][rub_id] = f;
  104.             return true;
  105.         }
  106.     pi[playerid][rub_id] = -1;
  107.     return false;
  108. }
  109. show_rubdialog(playerid){
  110.     new str[256];
  111.     for(new f, rub_rand; f<5; ++f){
  112.         rub_rand = random(all_item);
  113.         format(str, sizeof str, "%s{00d400}[%d] {868686}%s\n", str, f+1, rub_str[rub_rand][0]);
  114.         pi[playerid][rub_item][f] = rub_rand;
  115.     }
  116.     strcat(str, "{d46500}[6] {868686}Искать еще..");
  117.     ShowPlayerDialog(playerid, dial_rub, DIALOG_STYLE_LIST, "{d46500}Мусорка", str, "Выбрать", "Отмена");
  118.     return true;
  119. }
Advertisement
RAW Paste Data Copied
Advertisement