1
0

fcrp.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. #include <a_samp>
  2. stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  3. {
  4. if(IsPlayerConnected(playerid))
  5. {
  6. new Float:posx, Float:posy, Float:posz;
  7. new Float:oldposx, Float:oldposy, Float:oldposz;
  8. new Float:tempposx, Float:tempposy, Float:tempposz;
  9. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  10. for(new i = 0; i < MAX_PLAYERS; i++)
  11. {
  12. if(IsPlayerConnected(i))
  13. {
  14. GetPlayerPos(i, posx, posy, posz);
  15. tempposx = (oldposx -posx);
  16. tempposy = (oldposy -posy);
  17. tempposz = (oldposz -posz);
  18. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  19. {
  20. SendClientMessage(i, col1, string);
  21. }
  22. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  23. {
  24. SendClientMessage(i, col2, string);
  25. }
  26. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  27. {
  28. SendClientMessage(i, col3, string);
  29. }
  30. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  31. {
  32. SendClientMessage(i, col4, string);
  33. }
  34. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  35. {
  36. SendClientMessage(i, col5, string);
  37. }
  38. }
  39. else
  40. {
  41. SendClientMessage(i, col1, string);
  42. }
  43. }
  44. }
  45. return 1;
  46. }
  47. stock GetPlayerNameEx(playerid)
  48. {
  49. new string[24];
  50. GetPlayerName(playerid,string,24);
  51. new str[24];
  52. strmid(str,string,0,strlen(string),24);
  53. for(new i = 0; i < MAX_PLAYER_NAME; i++)
  54. {
  55. if (str[i] == '_') str[i] = ' ';
  56. }
  57. return str;
  58. }
  59. stock SendName(playerid)
  60. {
  61. new
  62. pos = 0,
  63. name[MAX_PLAYER_NAME];
  64. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  65. pos = strfind(name, "_", false);
  66. name[pos] = ' ';
  67. if( GetPVarInt(playerid, "IsMasked") == 1 )
  68. {
  69. format(name, MAX_PLAYER_NAME, "[MaskID %d]", GetPVarInt(playerid, "MaskID"));
  70. }
  71. return name;
  72. }
  73. stock SendAdminMessage(color, string[])
  74. {
  75. for(new i = 0; i < MAX_PLAYERS; i++)
  76. {
  77. if(GetPVarInt(i, "AdminLevel") > 0)
  78. {
  79. SendClientMessage(i, color, string);
  80. }
  81. }
  82. return 1;
  83. }
  84. /*----------------------------------------------------------------------------*-
  85. Function:
  86. sscanf
  87. Params:
  88. string[] - String to extract parameters from.
  89. format[] - Parameter types to get.
  90. {Float,_}:... - Data return variables.
  91. Return:
  92. 0 - Successful, not 0 - fail.
  93. Notes:
  94. A fail is either insufficient variables to store the data or insufficient
  95. data for the format string - excess data is disgarded.
  96. A string in the middle of the input data is extracted as a single word, a
  97. string at the end of the data collects all remaining text.
  98. The format codes are:
  99. c - A character.
  100. d, i - An integer.
  101. h, x - A hex number (e.g. a colour).
  102. f - A float.
  103. s - A string.
  104. z - An optional string.
  105. pX - An additional delimiter where X is another character.
  106. '' - Encloses a litteral string to locate.
  107. u - User, takes a name, part of a name or an id and returns the id if they're connected.
  108. Now has IsNumeric integrated into the code.
  109. Added additional delimiters in the form of all whitespace and an
  110. optioanlly specified one in the format string.
  111. -*----------------------------------------------------------------------------*/
  112. stock sscanf(string[], format[], {Float,_}:...)
  113. {
  114. #if defined isnull
  115. if (isnull(string))
  116. #else
  117. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  118. #endif
  119. {
  120. return format[0];
  121. }
  122. #pragma tabsize 4
  123. new
  124. formatPos = 0,
  125. stringPos = 0,
  126. paramPos = 2,
  127. paramCount = numargs(),
  128. delim = ' ';
  129. while (string[stringPos] && string[stringPos] <= ' ')
  130. {
  131. stringPos++;
  132. }
  133. while (paramPos < paramCount && string[stringPos])
  134. {
  135. switch (format[formatPos++])
  136. {
  137. case '\0':
  138. {
  139. return 0;
  140. }
  141. case 'i', 'd':
  142. {
  143. new
  144. neg = 1,
  145. num = 0,
  146. ch = string[stringPos];
  147. if (ch == '-')
  148. {
  149. neg = -1;
  150. ch = string[++stringPos];
  151. }
  152. do
  153. {
  154. stringPos++;
  155. if ('0' <= ch <= '9')
  156. {
  157. num = (num * 10) + (ch - '0');
  158. }
  159. else
  160. {
  161. return -1;
  162. }
  163. }
  164. while ((ch = string[stringPos]) > ' ' && ch != delim);
  165. setarg(paramPos, 0, num * neg);
  166. }
  167. case 'h', 'x':
  168. {
  169. new
  170. num = 0,
  171. ch = string[stringPos];
  172. do
  173. {
  174. stringPos++;
  175. switch (ch)
  176. {
  177. case 'x', 'X':
  178. {
  179. num = 0;
  180. continue;
  181. }
  182. case '0' .. '9':
  183. {
  184. num = (num << 4) | (ch - '0');
  185. }
  186. case 'a' .. 'f':
  187. {
  188. num = (num << 4) | (ch - ('a' - 10));
  189. }
  190. case 'A' .. 'F':
  191. {
  192. num = (num << 4) | (ch - ('A' - 10));
  193. }
  194. default:
  195. {
  196. return -1;
  197. }
  198. }
  199. }
  200. while ((ch = string[stringPos]) > ' ' && ch != delim);
  201. setarg(paramPos, 0, num);
  202. }
  203. case 'c':
  204. {
  205. setarg(paramPos, 0, string[stringPos++]);
  206. }
  207. case 'f':
  208. {
  209. new changestr[16], changepos = 0, strpos = stringPos;
  210. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  211. {
  212. changestr[changepos++] = string[strpos++];
  213. }
  214. changestr[changepos] = '\0';
  215. setarg(paramPos,0,_:floatstr(changestr));
  216. }
  217. case 'p':
  218. {
  219. delim = format[formatPos++];
  220. continue;
  221. }
  222. case '\'':
  223. {
  224. new
  225. end = formatPos - 1,
  226. ch;
  227. while ((ch = format[++end]) && ch != '\'') {}
  228. if (!ch)
  229. {
  230. return -1;
  231. }
  232. format[end] = '\0';
  233. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  234. {
  235. if (format[end + 1])
  236. {
  237. return -1;
  238. }
  239. return 0;
  240. }
  241. format[end] = '\'';
  242. stringPos = ch + (end - formatPos);
  243. formatPos = end + 1;
  244. }
  245. case 'u':
  246. {
  247. new
  248. end = stringPos - 1,
  249. id = 0,
  250. bool:num = true,
  251. ch;
  252. while ((ch = string[++end]) && ch != delim)
  253. {
  254. if (num)
  255. {
  256. if ('0' <= ch <= '9')
  257. {
  258. id = (id * 10) + (ch - '0');
  259. }
  260. else
  261. {
  262. num = false;
  263. }
  264. }
  265. }
  266. if (num && IsPlayerConnected(id))
  267. {
  268. setarg(paramPos, 0, id);
  269. }
  270. else
  271. {
  272. #if !defined foreach
  273. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  274. #define __SSCANF_FOREACH__
  275. #endif
  276. string[end] = '\0';
  277. num = false;
  278. new
  279. name[MAX_PLAYER_NAME];
  280. id = end - stringPos;
  281. foreach (Player, playerid)
  282. {
  283. GetPlayerName(playerid, name, sizeof (name));
  284. if (!strcmp(name, string[stringPos], true, id))
  285. {
  286. setarg(paramPos, 0, playerid);
  287. num = true;
  288. break;
  289. }
  290. }
  291. if (!num)
  292. {
  293. setarg(paramPos, 0, INVALID_PLAYER_ID);
  294. }
  295. string[end] = ch;
  296. #if defined __SSCANF_FOREACH__
  297. #undef foreach
  298. #undef __SSCANF_FOREACH__
  299. #endif
  300. }
  301. stringPos = end;
  302. }
  303. case 's', 'z':
  304. {
  305. new
  306. i = 0,
  307. ch;
  308. if (format[formatPos])
  309. {
  310. while ((ch = string[stringPos++]) && ch != delim)
  311. {
  312. setarg(paramPos, i++, ch);
  313. }
  314. if (!i)
  315. {
  316. return -1;
  317. }
  318. }
  319. else
  320. {
  321. while ((ch = string[stringPos++]))
  322. {
  323. setarg(paramPos, i++, ch);
  324. }
  325. }
  326. stringPos--;
  327. setarg(paramPos, i, '\0');
  328. }
  329. default:
  330. {
  331. continue;
  332. }
  333. }
  334. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  335. {
  336. stringPos++;
  337. }
  338. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  339. {
  340. stringPos++;
  341. }
  342. paramPos++;
  343. }
  344. do
  345. {
  346. if ((delim = format[formatPos++]) > ' ')
  347. {
  348. if (delim == '\'')
  349. {
  350. while ((delim = format[formatPos++]) && delim != '\'') {}
  351. }
  352. else if (delim != 'z')
  353. {
  354. return delim;
  355. }
  356. }
  357. }
  358. while (delim > ' ');
  359. return 0;
  360. }