Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. #define MAX_MOBILE (50)
  2. enum MobileStationEx
  3. {
  4. aID,
  5. Float:aX,
  6. Float:aY,
  7. Float:aZ,
  8. aRadius,
  9. };
  10. new MobileInfo[MAX_MOBILE][MobileStationEx], TOTALSTATION;
  11. new SignalStation[MAX_PLAYERS];
  12.  
  13. mysql_tquery(dbHandle, "SELECT * FROM "T_MOBILE"", "@LoadMobileStation", "");
  14.  
  15. @LoadMobileStation();
  16. @LoadMobileStation()
  17. {
  18. new time = GetTickCount();
  19.  
  20. #if MYSQL_R41_2 == true
  21.  
  22. new rows;
  23. cache_get_row_count(rows);
  24. if(rows)
  25. {
  26. for(new idx = 1; idx <= rows; idx++)
  27. {
  28. cache_get_value_index_int(idx-1, 0, MobileInfo[idx][aID]); // ID
  29. cache_get_value_index_float(idx-1, 1, MobileInfo[idx][aX]); // aX
  30. cache_get_value_index_float(idx-1, 2, MobileInfo[idx][aY]); // aY
  31. cache_get_value_index_float(idx-1, 3, MobileInfo[idx][aZ]); // aZ
  32. cache_get_value_index_float(idx-1, 4, MobileInfo[idx][aRadius]); // aRadius
  33.  
  34. TOTALSTATION++;
  35. MobileStation[idx] = CreateObject(3763, MobileInfo[idx][aX], MobileInfo[idx][aY], MobileInfo[idx][aZ], 0.0,0.0,0.0);
  36. }
  37. }
  38.  
  39. #else
  40.  
  41. new rows, fields;
  42. cache_get_data(rows, fields);
  43. if(rows)
  44. {
  45. for(new idx = 1; idx <= rows; idx++)
  46. {
  47. MobileInfo[idx][aID] = cache_get_row_int(idx-1, 0, dbHandle); // ID
  48. MobileInfo[idx][aX] = cache_get_row_float(idx-1, 1, dbHandle); // aX
  49. MobileInfo[idx][aY] = cache_get_row_float(idx-1, 2, dbHandle); // aY
  50. MobileInfo[idx][aZ] = cache_get_row_float(idx-1, 3, dbHandle); // aZ
  51. TOTALSTATION++;
  52. MobileStation[idx] = CreateObject(3763, MobileInfo[idx][aX], MobileInfo[idx][aY], MobileInfo[idx][aZ], 0.0,0.0,0.0);
  53. }
  54. }
  55.  
  56. #endif
  57.  
  58. printf("[Çàãðóæåíî ñòàíöèé]: <%i>. Ïîòðà÷åíî: <%i ms>.", TOTALSTATION, GetTickCount() - time);
  59. return 1;
  60. }
  61.  
  62. stock GetPlayerClosestMobileStation(playerid)
  63. {
  64. new id=-1, Float:dist=0.0, Float:mindist=9999.0;
  65. for(new i=0; i<MAX_MOBILE; i++)
  66. {
  67. if(MobileInfo[i][aID])
  68. {
  69. dist=GetPlayerDistanceFromPoint(playerid,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]);
  70. if(dist < MobileInfo[i][aRadius])
  71. {
  72. if(dist < mindist)
  73. {
  74. mindist=dist;
  75. id=i;
  76. }
  77. }
  78. }
  79. }
  80. return id;
  81. }
  82. stock SignalSetString(playerid)
  83. {
  84. new str[255];
  85. switch(SignalStation[playerid])
  86. {
  87. case -1:
  88. str = "~g~Phone Signal: ~y~!~b~offline";
  89. case 0:
  90. str = "~g~Phone Signal: ~y~!~b~lost";
  91. case 1:
  92. str = "~g~Phone Signal: ~y~!~b~-";
  93. case 2:
  94. str = "~g~Phone Signal: ~y~!~b~--";
  95. case 3:
  96. str = "~g~Phone Signal: ~y~!~b~---";
  97. case 4:
  98. str = "~g~Phone Signal: ~y~!~b~----";
  99. case 5:
  100. str = "~g~Phone Signal: ~y~!~b~-----";
  101. }
  102. return str;
  103. }
  104. stock GetSignal(playerid)
  105. {
  106. new i=GetPlayerClosestMobileStation(playerid);
  107. if(i!=-1)
  108. {
  109. if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*1,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
  110. return 5;
  111. else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*2,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
  112. return 4;
  113. else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*3,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
  114. return 3;
  115. else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*4,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
  116. return 2;
  117. else
  118. return 1;
  119. }
  120. else
  121. return 0;
  122. }
  123.  
  124. Обновление в 1 секунду таймер
  125. if(GetPlayerInterior(i)==0)
  126. Signal[i]=GetSignal(i);
  127. new sdstring[128];
  128. format(sdstring,128,"%s",SignalSetString(i));
  129. TextDrawSetString(mobile_text_TD[i],sdstring);
  130.  
  131. проверки
  132. else if(!Signal[plidx]) return SendClientMessage(playerid,COLOR_WHITE,"[Îøèáêà] Ó àáîíåíòà âðåìåííî íåò çîíû");
  133. else if(!Signal[playerid]) return SendClientMessage(playerid,COLOR_WHITE,"[Îøèáêà] Ó àáîíåíòà âðåìåííî íåò çîíû");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement